Пример #1
0
  /**
   * Invoke the user defined static method in the nested "Duck" class so that the user can define
   * convenience methods on the config beans.
   */
  Object invokeDuckMethod(Method method, Object proxy, Object[] args) throws Exception {
    Method duckMethod = model.getDuckMethod(method);

    Object[] duckArgs;
    if (args == null) {
      duckArgs = new Object[] {proxy};
    } else {
      duckArgs = new Object[args.length + 1];
      duckArgs[0] = proxy;
      System.arraycopy(args, 0, duckArgs, 1, args.length);
    }

    try {
      return duckMethod.invoke(null, duckArgs);
    } catch (InvocationTargetException e) {
      Throwable t = e.getTargetException();
      if (t instanceof Exception) throw (Exception) t;
      if (t instanceof Error) throw (Error) t;
      throw e;
    }
  }