Package groovy.lang

Examples of groovy.lang.MetaMethod.invoke()


    B builder = ctx.getBuilder();
    S stack = ctx.getStack();
    Object[] args = ctx.getArgs();
    String name = ctx.getMethodName();
   
    if (method != null) return method.invoke(builder, args);
   
    Object value = null;
    Map<Object, Object> parameters = null;
    Closure closure = null;
   
View Full Code Here


   
    // If we should attempt method calls on the builder first
    // we will do so, only catching MME's, other exceptions mean
    // the method was probably called and should be propagated.
    if (method != null && !callProxyFirst) try {
      return method.invoke(builder, args);
    } catch (MissingMethodException mme) {}

   
    Closure closure = null;
    Object nodeInstance = stack.getCurrent();
View Full Code Here

    }

    // If no node instance could be created then we will
    // do a last attempt (if not already attempted above)
    // to call the method on the builder
    if (method != null && callProxyFirst) return method.invoke(builder, args);
   
    // If we get here we have attempted all methods for valid invocation
    // thus we must throw a MME
    throw new MissingMethodException(name, builder.getClass(), args);
   
View Full Code Here

    }

    public void marshalObject(Object object, JSON converter) throws ConverterException {
        MetaMethod method = getToJSONMethod(object);
        try {
            Object result = method.invoke(object, new Object[]{ converter });
            if (result != null && !(result instanceof JSON) && !(result instanceof JSONWriter)) {
                converter.convertAnother(result);
            }
        }
        catch(Throwable e) {
View Full Code Here

    }

    public void marshalObject(Object object, XML converter) throws ConverterException {
        MetaMethod method = getToXMLMethod(object);
        try {
            Object result = method.invoke(object, new Object[]{ converter });
            if (result != null && !(result instanceof XML)) {
                converter.convertAnother(result);
            }
        }
        catch(Throwable e) {
View Full Code Here

        metaclass = InvokerHelper.getMetaClass(obj);

        MetaMethod mm = metaclass.getMetaMethod("setEvalConfig", new Class[]{EvalConfig.class});
        if (mm != null) {
            mm.invoke(obj, new Object[]{project.getConfig()});
        }

        mm = metaclass.getMetaMethod("setEvalProject", new Class[]{EvalProject.class});
        if (mm == null) {
            mm = metaclass.getMetaMethod("setProject", new Class[]{EvalProject.class});
View Full Code Here

        mm = metaclass.getMetaMethod("setEvalProject", new Class[]{EvalProject.class});
        if (mm == null) {
            mm = metaclass.getMetaMethod("setProject", new Class[]{EvalProject.class});
        }
        if (mm != null) {
            mm.invoke(obj, new Object[]{project});
        }

        if (split.getRight() != null) {
            GroovyUtils.callWithDelegate(split.getRight(), makeConfigDelegate(obj));
        }
View Full Code Here

        MetaMethod getter = getGetter();
        if (getter == null) {
            if (field != null) return field.getProperty(object);
            throw new GroovyRuntimeException("Cannot read write-only property: " + name);
        }
        return getter.invoke(object, MetaClassHelper.EMPTY_ARRAY);
    }

    @Override
    public void setProperty(Object object, Object newValue) {
        InvokerHelper.getMetaClass(object).invokeMethod(object, setterName, new Object[]{newValue});
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.