/** * Use reflection to invoke the requested method. Cache the method object to speed up the process * * @param methodName The method to call. * @param clazz The list of argument classes for the given method * @param params The arguments passed to the called method. */ private Object doPrivileged(final String methodName, final Class<?>[] clazz, Object[] params) { try { Method method = context.getClass().getMethod(methodName, clazz); return executeMethod(method, context, params); } catch (Exception ex) { try { handleException(ex, methodName); } catch (Throwable t) { throw new RuntimeException(t.getMessage()); } return null; } }
/** * Use reflection to invoke the requested method. Cache the method object to speed up the process * * @param appContext The AppliationContext object on which the method will be invoked * @param methodName The method to call. * @param params The arguments passed to the called method. */ private Object invokeMethod( ApplicationContext appContext, final String methodName, Object[] params) throws Throwable { try { Method method = objectCache.get(methodName); if (method == null) { method = appContext.getClass().getMethod(methodName, classCache.get(methodName)); objectCache.put(methodName, method); } return executeMethod(method, appContext, params); } catch (Exception ex) { handleException(ex, methodName); return null; } }