Executes a method of any Object by Java reflection.

@param o
an Object
@param methodName
name of the method
@param arg
an Integer
@return the result of the method called
777733
public static <E> E send(Object o, String methodName, Integer arg) {
    return send(o, methodName, (Object) arg);
  }
1021664
@SuppressWarnings("unchecked")
    public static <E> List<E> invoke(final Iterable<E> iterable, final String methodName,
                                  final List<Object> args) {
        final List<E> result = newArrayList();
        final List<Class<?>> argTypes = map(args, new Function<Object, Class<?>>() {
            public Class<?> apply(Object input) {
                return input.getClass();
            }
        });
        try {
            final Method method = iterable.iterator().next().getClass().getMethod(methodName, argTypes.toArray(
                new Class[argTypes.size()]));
            for (E arg : iterable) {
                try {
                    result.add((E) method.invoke(arg, args.toArray(new Object[args.size()])));
                } catch (Exception e) {
                    throw new IllegalArgumentException(e);
                }
            }
        } catch (NoSuchMethodException e) {
            throw new IllegalArgumentException(e);
        }
        return result;
    }
410456
public Object invokeMethod(String name, Object args) {
        try {
            return getMetaClass().invokeMethod(this, name, args);
        } catch (MissingMethodException e) {
            // let's apply the method to each item in the collection
            List answer = new ArrayList(size());
            for (Object element : this) {
                Object value = InvokerHelper.invokeMethod(element, name, args);
                answer.add(value);
            }
            return answer;
        }
    }
1087355
@SuppressWarnings("unchecked")
  public static <E> E send(Object o, String methodName, byte arg) {
    try {
      Method method = o.getClass().getMethod(methodName, byte.class);
      return (E) method.invoke(o, arg);
    } catch (Exception e) {
      return send(o, methodName, (Object) arg);
    }
  }
799947
public static Object executeMethod(Object object, MethodCallFact methodCallFact)
   throws Exception
   {
	if (object == null)
	   throw new RequiredException("object");
	
	if (methodCallFact == null)
	   throw new RequiredException("methodCallFact");
	
	return executeMethod(object, methodCallFact.getMethodName(),methodCallFact.getArguments());
   }
848358
public static Object invokeMethod(Object obj, Method method, Object... parameter) {
        try {
            method.setAccessible(true);
            return method.invoke(obj, parameter);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        return null;
    }
64411
public Object invoke(Method method, Object[] args) throws Throwable {

        return MethodExecutionListenerUtils.invoke(new MethodExecutionListenerUtils.MethodExecutionCallback() {
            @Override
            public Object execute(Object proxyTarget, Method method, Object[] args) throws Throwable {
                return performQueryExecutionListener(method, args);
            }
        }, this.proxyConfig, this.statement, this.connectionInfo, method, args);

    }
1103967
void createMethodBody(String classname, ExecutableElement methodElement, List<String> arguments, Writer writer) throws IOException {
		String methodName = getMethodName(methodElement);
		boolean ws = isWebsocketDataService(methodElement);
		String args = stringJoinAndDecorate(arguments, COMMA, new NothingDecorator());
		String keys = computeKeys(methodElement, arguments);
		createReturnOcelotPromiseFactory(classname, methodName, ws, args, keys, writer);
	}
792911
public Object invokeMethod(String name, Object args) {
        try {
        return getMetaClass().invokeMethod(this, name, args);
        }
        catch (MissingMethodException e) {
            // lets apply the method to each item in the collection
            List answer = new ArrayList(size());
            for (Iterator iter = iterator(); iter.hasNext(); ) {
                Object element = iter.next();
                Object value = InvokerHelper.invokeMethod(element, name, args);
                answer.add(value);
            }
            return answer;
        }
    }
442963
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;
	}
403170
public static <T> T executeGroovyScript(final Resource groovyScript,
                                            final String methodName,
                                            final Class<T> clazz) {
        return executeGroovyScript(groovyScript, methodName, ArrayUtils.EMPTY_OBJECT_ARRAY, clazz, false);
    }
1287267
@SuppressWarnings("unchecked")
  public static <E> E send(Object o, String methodName, Object... args) {
    try {
      for (Method method : o.getClass().getMethods()) {
        if (method.getName().equals(methodName)) {
          boolean isArgsMatched = true;
          for (int i = 0; i < method.getParameterTypes().length; i++) {
            if (i >= args.length || args[i] == null) continue;

            if (!isConvertable(method.getParameterTypes()[i],
                args[i].getClass()))
              isArgsMatched = false;
          }
          if (isArgsMatched && method.getParameterTypes().length == args.length)
            return (E) method.invoke(o, args);
        }
      }
      throw new NoSuchMethodException();
    } catch (NoSuchMethodException e) {
      logger.log(Level.SEVERE, null, e);
      throw new IllegalArgumentException("NoMethodError: undefined method `"
          + methodName + "' for " + o + ":" + o.getClass().getName());
    } catch (Exception e) {
      logger.log(Level.SEVERE, null, e);
      throw new RuntimeException(e);
    }
  }
210057
protected Object doInvokeMethod(String methodName, Object name, Object args) {
        super.doInvokeMethod(methodName, name, args);


        // return the completed node
        return lastCompletedNode;
    }
1374643
public static <T> T invokeMethod(final Object obj, final String methodName, final Object[] args,
			final Class<?>[] parameterTypes) {
		Method method = getMethod(obj.getClass(), methodName, parameterTypes);
		if (method == null) {
			throw new IllegalArgumentException("Could not find method [" + methodName + "] with parameter types:"
					+ ObjectUtil.toPrettyString(parameterTypes) + " on class [" + obj.getClass() + ']');
		}
		return invokeMethod(obj, method, args);
	}
497311
public static void instanceOf(final Object arg, final Class<?> clazz, final String name) {
        
        if(arg == null) {
            throw new IllegalArgumentException(String.format("%s should not be null.", name));
        }
        
        if(!clazz.isAssignableFrom(arg.getClass())) {
            throw new IllegalArgumentException(String.format("%s should not be class with '%s'.", name, clazz.getName()));
        }
        
    }
174777
public static Object invokeMethod(Object target, String method, Object... args) {
		Class<?>[] types = new Class[args.length];
		for(int index = args.length - 1; index >= 0; index--) {
			types[index] = args[index].getClass();
		}
		try {
			return target.getClass().getMethod(method, types).invoke(target, args);
		} catch(Throwable t) {
			throw new MethodInvocationException(t);
		}
	}
1288166
public static function invoke( $oInstance, $methodName, $args=null ){

		//TODO tratar los args.
		$reflectionMethod = new \ReflectionMethod( get_class( $oInstance ) , $methodName);
		$value = $reflectionMethod->invoke( $oInstance, $args );
			
		return $value;
	}