Examples of GroovyObject


Examples of groovy.lang.GroovyObject

*/
@NoConventionMapping
public class DefaultTask extends AbstractTask {
    public DefaultTask() {
        if (this instanceof GroovyObject) {
            GroovyObject groovyObject = (GroovyObject) this;
            if (groovyObject.getMetaClass() == null) {
                groovyObject.setMetaClass(InvokerHelper.getMetaClass(getClass()));
            }
        }
    }
View Full Code Here

Examples of groovy.lang.GroovyObject

    @Test
    public void mixesInGroovyObjectInterface() throws Exception {
        Class<? extends Bean> generatedClass = generator.generate(Bean.class);
        assertTrue(GroovyObject.class.isAssignableFrom(generatedClass));
        Bean bean = generatedClass.newInstance();
        GroovyObject groovyObject = (GroovyObject) bean;
        assertThat(groovyObject.getMetaClass(), notNullValue());

        groovyObject.setProperty("prop", "value");
        assertThat(bean.getProp(), equalTo("value"));
        assertThat(groovyObject.getProperty("prop"), equalTo((Object) "value"));
        assertThat(groovyObject.invokeMethod("doStuff", new Object[]{"some value"}), equalTo((Object) "{some value}"));
    }
View Full Code Here

Examples of groovy.lang.GroovyObject

            final GroovyClassLoader grooveyClassLoader = new GroovyClassLoader(this.getClassLoader());
            final Class groovyClass =
                grooveyClassLoader.parseClass(
                    this.getContents(new File(this.scriptPath)),
                    scriptPath);
            final GroovyObject groovyObject = (GroovyObject)groovyClass.newInstance();

            this.copyProperties(
                this.stub,
                groovyObject);
            return groovyObject.invokeMethod(
                methodName,
                args);
        }
        catch (final Throwable throwable)
        {
View Full Code Here

Examples of groovy.lang.GroovyObject

        ObjectName name = new ObjectName("groovy.test:role=TestMBean,type=Dummy");
        mbeanServer.registerMBean(new Dummy(), name);

        assertEquals("JMX value of Name", "James", mbeanServer.getAttribute(name, "Name"));

        GroovyObject object = new GroovyMBean(mbeanServer, name);

        Object value = object.getProperty("Name");
        assertEquals("Name property", "James", value);

        object.setProperty("Name", "Bob");
        assertEquals("Name property", "Bob", object.getProperty("Name"));

        // now let's look up the name via JMX to check
        assertEquals("JMX value of Name", "Bob", mbeanServer.getAttribute(name, "Name"));
    }
View Full Code Here

Examples of groovy.lang.GroovyObject

    if (file.lastModified() != lastModified) {
      compileScriptClass(scriptSource);
    }
    try {

      GroovyObject goo = (GroovyObject) scriptClass.newInstance();
      UIComponent ann = AnnotationUtils.findAnnotation(scriptClass, UIComponent.class);
      if (ann != null) {
        UIComponentMixin.applyMixin(ann.value(), goo, applicationContext);
      }
      Context context = Context.getCurrentContext();
View Full Code Here

Examples of groovy.lang.GroovyObject

    try
    {
      ClassLoader parent = WrapperGroovyMain.class.getClassLoader();
      GroovyClassLoader loader = new GroovyClassLoader(parent);
      Class groovyClass = loader.parseClass(scriptFile);
      GroovyObject script = (GroovyObject) groovyClass.newInstance();
      script.invokeMethod("main", mainMethodArgs);
    }
    catch (Throwable e)
    {
      e.printStackTrace();
      exception = e;
View Full Code Here

Examples of groovy.lang.GroovyObject

  @SuppressWarnings("unchecked")
  protected Object getValue() {
    Object config = null;
    if (context.containsViewBean(configId)) {
      GroovyObject bean = (GroovyObject) context.getViewBean(configId);
      config = bean.invokeMethod("getComponentDefinition", null);
    } else {
      config = configService.getConfig(configId);
    }
    if (config instanceof Map) {
      return mapWrapperFactory.createWrapper(getScope(), getModelScope(), (Map<String, Object>) config);
View Full Code Here

Examples of groovy.lang.GroovyObject

  @Override
  protected Object getValue() {
    Object config = null;
    Context context = Context.getCurrentContext();
    if (context.containsViewBean(extendedId)) {
      GroovyObject bean = (GroovyObject) context.getViewBean(extendedId);
      config = bean.invokeMethod("getComponentDefinition", null);
    } else {
      config = configService.getConfig(extendedId);
    }
    if (Map.class.isAssignableFrom(config.getClass())) {
      Map<String, Object> result = new LinkedHashMap<String, Object>();
View Full Code Here

Examples of groovy.lang.GroovyObject

* @version $Revision: 21496 $
*/
public class ConstructorTest extends TestSupport {

    public void testConstructor() throws Exception {
        GroovyObject object = compile("src/test/groovy/NewExpressionTest.groovy");
        object.invokeMethod("testNewInstance", null);
    }
View Full Code Here

Examples of groovy.lang.GroovyObject

* @version $Revision: 21496 $
*/
public class RunGroovyTest extends TestSupport {

    public void testArrayBug() throws Exception {
        GroovyObject object = compile("src/test/groovy/ToArrayBugTest.groovy");
        object.invokeMethod("testToArrayBug", null);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.