List of utility methods to do Method Call
Object | invoke(Object bean, Method method, Object value) invoke try { return method.invoke(bean, value); } catch (Exception e) { return value; |
void | invoke(Object bean, Method method, Object value) invoke Object[] values = { value }; invoke(bean, method, values); |
Object | invoke(Object bean, String methodName, Object args, Class> parameterType) invoke Class<?> serviceClass = null; Method businessMethod = null; Object obj = null; try { serviceClass = bean.getClass(); businessMethod = serviceClass.getMethod(methodName, parameterType); obj = businessMethod.invoke(bean, args); } catch (Exception e) { ... |
Object | invoke(Object buffer, String methodName, Class[] paramTypes, Object... args) invoke Method method = null; try { method = buffer.getClass().getMethod(methodName, paramTypes); } catch (Exception e) { Method[] methods = buffer.getClass().getMethods(); for (Method m : methods) { if (m.getName().equals(methodName)) { method = m; ... |
Object | invoke(Object clazzInstance, String method, Class invoke Method _m = clazzInstance.getClass().getMethod(method, paramClasses);
return _m.invoke(clazzInstance, params);
|
void | invoke(Object context, String methodName, Object parameter) invoke try { Class methodHodler = context.getClass(); Method method = methodHodler.getMethod(methodName, parameter.getClass()); method.invoke(context, parameter); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); ... |
Object | invoke(Object host, String method, Object[] args) invoke Class clz = host.getClass(); for (Method m : clz.getMethods()) { if (m.getName().equals(method) && m.getParameterCount() == args.length) { Class[] paramTypes = m.getParameterTypes(); for (int i = 0; i < paramTypes.length; ++i) args[i] = rectifyValue(paramTypes[i], args[i]); return m.invoke(host, args); return null; |
Object | invoke(Object instance, java.lang.reflect.Method method, Object... args) invoke try { return method.invoke(instance, args); } catch (IllegalAccessException iae) { throw new RuntimeException(getDetail(instance, method, args), iae); } catch (java.lang.reflect.InvocationTargetException ite) { throw new RuntimeException(getDetail(instance, method, args), ite); } catch (RuntimeException re) { throw new RuntimeException(getDetail(instance, method, args), re); ... |
Object | invoke(Object instance, Method method, Object... params) Invokes the given object Method . return method.invoke(instance, params);
|
Object | invoke(Object instance, String method, Class[] paramTypes, Object... parameters) invoke Class clazz = instance.getClass(); for (Method m : clazz.getMethods()) { if (m.getName().equals(method) && Arrays.equals(m.getParameterTypes(), paramTypes)) { try { return m.invoke(instance, parameters); } catch (Exception e) { throw new RuntimeException("Can't invoke method", e); throw new RuntimeException("Can't find method"); |