/**
   * Use reflection to invoke the requested method. Cache the method object to speed up the process
   *
   * @param methodName The method to invoke.
   * @param clazz The class where the method is.
   * @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);
      } catch (Throwable t) {
        handleThrowable(t);
        throw new RuntimeException(t.getMessage());
      }
      return null;
    } finally {
      params = 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(
      ServletContextImpl 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);
      return null;
    } finally {
      params = null;
    }
  }