public Object invokeMethod(String name, Object obj) { if (obj instanceof Object[]) { final Object[] args = (Object[]) obj; if (args.length == 1 && args[0] instanceof Closure) { registerStaticMethod(name, (Closure) args[0]); return null; } } throw new MissingMethodException(name, getClass(), obj instanceof Object[] ? (Object[]) obj : new Object[]{obj}); } }
public Object invokeMethod(String name, Object obj) { if (obj instanceof Object[]) { Object args[] = (Object[]) obj; if (args.length == 1 && args[0] instanceof Closure) { registerSubclassInstanceMethod(name, klazz, (Closure) args[0]); return null; } } throw new MissingMethodException(name, getClass(), new Object[]{obj}); } }
private Object callGlobal(String name, Object[] args, ScriptContext ctx) { Closure<?> closure = globalClosures.get(name); if (closure != null) { return closure.call(args); } else { // Look for closure valued variable in the // given ScriptContext. If available, call it. Object value = ctx.getAttribute(name); if (value instanceof Closure) { return ((Closure) value).call(args); } // else fall thru.. } throw new MissingMethodException(name, getClass(), args); }
@Override public Object invokeMethod(String name, Object[] args) { if (args.length != 1 || !(args[0] instanceof Closure)) throw new MissingMethodException(name, this.getClass(), args); Object config = configurationRegistry.getConfigurationByName(name); if (config == null) throw new MissingMethodException(name, this.getClass(), args); ClosureBlueprint blueprint = new ClosureBlueprint((Closure)args[0], config); IGestalt gestalt = new PojoGestalt(config, config.getClass(), blueprint, slotFactories); new Sculpturer().$form(gestalt); return null; } }
private Object invokeStaticMissingMethod(Class sender, String methodName, Object[] arguments) { MetaMethod metaMethod = getStaticMetaMethod(STATIC_METHOD_MISSING, METHOD_MISSING_ARGS); if (metaMethod != null) { return metaMethod.invoke(sender, new Object[]{methodName, arguments}); } throw new MissingMethodException(methodName, sender, arguments, true); }
/** * This method is invoked by Groovy when a method that's not defined in Java is invoked. * We use that as a syntax for bean definition. */ public Object methodMissing(String name, Object arg) { Object[] args = (Object[])arg; if(args.length == 0) throw new MissingMethodException(name,getClass(),args); if(args[0] instanceof Closure) { // abstract bean definition return invokeBeanDefiningMethod(name, args); } else if(args[0] instanceof Class || args[0] instanceof RuntimeBeanReference || args[0] instanceof Map) { return invokeBeanDefiningMethod(name, args); } else if (args.length > 1 && args[args.length -1] instanceof Closure) { return invokeBeanDefiningMethod(name, args); } WebApplicationContext ctx = springConfig.getUnrefreshedApplicationContext(); MetaClass mc = DefaultGroovyMethods.getMetaClass(ctx); if(!mc.respondsTo(ctx, name, args).isEmpty()){ return mc.invokeMethod(ctx,name, args); } return this; }
protected Object noSuchMethod(CachedMethod method, Object object, Object[] arguments) { throw new MissingMethodException(method.getName(), method.getDeclaringClass().getTheClass(), arguments, false); } }
public static Throwable unwrap(GroovyRuntimeException gre) { if (gre.getCause()==null) { if (gre instanceof MissingPropertyExceptionNoStack) { MissingPropertyExceptionNoStack noStack = (MissingPropertyExceptionNoStack) gre; return new MissingPropertyException(noStack.getProperty(), noStack.getType()); } if (gre instanceof MissingMethodExceptionNoStack) { MissingMethodExceptionNoStack noStack = (MissingMethodExceptionNoStack) gre; return new MissingMethodException(noStack.getMethod(), noStack.getType(), noStack.getArguments(), noStack.isStatic()); } } Throwable th = gre; if (th.getCause() != null && th.getCause() != gre) th = th.getCause(); if (th != gre && (th instanceof GroovyRuntimeException)) return unwrap((GroovyRuntimeException) th); return th; }
public Object invokeMethod(String name, Object args) { final Object[] argsArr = args instanceof Object[] ? (Object[]) args : new Object[]{args}; MetaMethod metaMethod = myMetaClass.getMetaMethod(name, argsArr); if (metaMethod != null) { // we have to use doMethodInvoke here instead of simply invoke, // because getMetaMethod may provide a method that can not be called // without further argument transformation, which is done only in // doMethodInvoke return metaMethod.doMethodInvoke(this, argsArr); } if (argsArr.length == 2 && argsArr[0] instanceof Class && argsArr[1] instanceof Closure) { if (argsArr[0] == theClass) registerInstanceMethod(name, (Closure) argsArr[1]); else { registerSubclassInstanceMethod(name, (Class) argsArr[0], (Closure) argsArr[1]); } return null; } if (argsArr.length == 1 && argsArr[0] instanceof Closure) { registerInstanceMethod(name, (Closure) argsArr[0]); return null; } throw new MissingMethodException(name, getClass(), argsArr); }
node = proxyBuilder.createNode(name, (Map) object2, object1); } else { throw new MissingMethodException(name.toString(), getClass(), list.toArray(), false); node = proxyBuilder.createNode(name, (Map) arg1, arg0); } else { throw new MissingMethodException(name.toString(), getClass(), list.toArray(), false); throw new MissingMethodException(name.toString(), getClass(), list.toArray(), false);
method = createTransformMetaMethod(pickClosureMethod(newArgClasses)); if (method == null) throw new MissingMethodException(methodName, theClass, arguments, false); throw new MissingMethodException(methodName, theClass, arguments, false);
throw new MissingMethodException((String) normalizedArgs[0], mockConfiguration.getType(), new Object[] {normalizedArgs[1]}, false);
private Object callGlobal(final String name, final Object args[], final ScriptContext ctx) { final Closure closure = globalClosures.get(name); if (closure != null) { return closure.call(args); } final Object value = ctx.getAttribute(name); if (value instanceof Closure) { return ((Closure) value).call(args); } else { throw new MissingMethodException(name, getClass(), args); } }
private Object callGlobal(String name, Object[] args, ScriptContext ctx) { Closure<?> closure = globalClosures.get(name); if (closure != null) { return closure.call(args); } else { // Look for closure valued variable in the // given ScriptContext. If available, call it. Object value = ctx.getAttribute(name); if (value instanceof Closure) { return ((Closure) value).call(args); } // else fall thru.. } throw new MissingMethodException(name, getClass(), args); }
private Object _gdk(String name, Object[] args) { PipeLineClosure find = _sub(name); if (find != null) { return find.call(args); } else { throw new MissingMethodException(name, PipeLineClosure.class, args); } }
/** * Groovy override to pass things off to the delegate. * @param name The name of the method. * @param args The method arguments. * @return The return value of the method. */ public Object methodMissing(String name, Object args) { try { return InvokerHelper.invokeMethod(getDelegate(), name, args); } catch (MissingMethodException mme) { throw new MissingMethodException(name, getClass(), mme.getArguments()); } }
@SuppressWarnings("unused") public Object methodMissing(String name, Object args) { Object[] argsArray = (Object[])args; if (args != null && argsArray.length > 0 && (argsArray[0] instanceof Closure)) { if (current == Environment.CUSTOM && current.getName().equals(name)) { callable = (Closure<?>) argsArray[0]; } return null; } throw new MissingMethodException(name, Environment.class, argsArray); } }
@SuppressWarnings("rawtypes") @Override protected Object createNode(Object name, Map attributes, Object value) { if (IMPORT_FROM_CONSTRAINT.equals(name) && (value instanceof Class)) { return handleImportFrom(attributes, (Class) value); } throw new MissingMethodException((String)name,targetClass,new Object[]{ attributes,value}); }
@SuppressWarnings("rawtypes") @Override protected Object createNode(Object name, Map attributes, Object value) { if (IMPORT_FROM_CONSTRAINT.equals(name) && (value instanceof Class)) { return handleImportFrom(attributes, (Class) value); } throw new MissingMethodException((String)name,targetClass,new Object[]{ attributes,value}); }
private Object callGlobal(final String name, final Object args[], final ScriptContext ctx) { final Closure closure = globalClosures.get(name); if (closure != null) { return closure.call(args); } final Object value = ctx.getAttribute(name); if (value instanceof Closure) { return ((Closure) value).call(args); } else { throw new MissingMethodException(name, getClass(), args); } }