1 package dynaop.remote; 2 3 import java.io.Serializable ; 4 import java.lang.reflect.InvocationTargetException ; 5 import java.lang.reflect.Method ; 6 7 import dynaop.util.NestedException; 8 9 14 class InvocationHandle implements Serializable { 15 16 static final long serialVersionUID = 0; 17 18 private Class remoteClass; 19 private String methodName; 20 private Class [] parameterTypes; 21 private Object [] parameters; 22 23 InvocationHandle(Method method, Object [] parameters) { 24 this.remoteClass = method.getDeclaringClass(); 25 this.methodName = method.getName(); 26 this.parameterTypes = method.getParameterTypes(); 27 this.parameters = parameters; 28 } 29 30 Object invoke(Object ejbObject) { 31 try { 32 Method method = 33 remoteClass.getMethod(this.methodName, this.parameterTypes); 34 return method.invoke(ejbObject, this.parameters); 35 } 36 catch (InvocationTargetException e) { 37 return new ThrowableWrapper(e.getTargetException()); 38 } 39 catch (Exception e) { 40 throw NestedException.wrap(e); 41 } 42 } 43 } 44 | Popular Tags |