1 29 30 package com.caucho.quercus.env; 31 32 import com.caucho.quercus.QuercusException; 33 import com.caucho.quercus.module.ModuleContext; 34 import com.caucho.util.L10N; 35 36 import java.lang.reflect.*; 37 38 41 public class JavaMethod extends JavaInvoker { 42 private static final L10N L = new L10N(JavaMethod.class); 43 44 private final Method _method; 45 46 51 public JavaMethod(ModuleContext moduleContext, Method method) 52 { 53 super(moduleContext, 54 method.getName(), 55 method.getParameterTypes(), 56 method.getParameterAnnotations(), 57 method.getAnnotations(), 58 method.getReturnType()); 59 60 _method = method; 61 } 62 63 68 public Method getMethod() 69 { 70 return _method; 71 } 72 73 @Override 74 public Object invoke(Object obj, Object []args) 75 { 76 try { 77 return _method.invoke(obj, args); 78 } catch (InvocationTargetException e) { 79 Throwable e1 = e.getCause(); 80 81 throw new QuercusException(_method.getName() + ": " + e1.getMessage(), e1); 82 } catch (Exception e) { 83 throw new QuercusException(_method.getName() + ": " + e.getMessage(), e); 84 } 85 } 86 87 public String toString() 88 { 89 return "JavaMethod[" + _method + "]"; 90 } 91 } 92 | Popular Tags |