示例#1
0
 /** Try to create a Java object using a one-string-param constructor. */
 public static Object newStringConstructor(String type, String param) throws Exception {
   Constructor c = Utils.getClass(type).getConstructor(String.class);
   try {
     return c.newInstance(param);
   } catch (InvocationTargetException e) {
     Throwable t = e.getTargetException();
     if (t instanceof Exception) {
       throw (Exception) t;
     } else {
       throw e;
     }
   }
 }
示例#2
0
 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
   final String methodName = method.getName();
   if (methodName.equals("getAttribute")) {
     return getAttribute((ObjectName) args[0], (String) args[1]);
   } else if (methodName.equals("getAttributes")) {
     return getAttributes((ObjectName) args[0], (String[]) args[1]);
   } else if (methodName.equals("flush")) {
     flush();
     return null;
   } else {
     try {
       return method.invoke(conn, args);
     } catch (InvocationTargetException e) {
       throw e.getCause();
     }
   }
 }