1 23 package com.sun.ejb.containers; 24 25 import java.io.Serializable ; 26 import java.lang.reflect.InvocationHandler ; 27 import java.lang.reflect.InvocationTargetException ; 28 import java.lang.reflect.Proxy ; 29 import java.lang.reflect.Method ; 30 31 import javax.ejb.EJBException ; 32 33 import com.sun.ejb.containers.util.InvocationHandlerUtil; 34 35 45 46 public final class RemoteBusinessIntfInvocationHandler 47 implements InvocationHandler , Serializable { 48 49 private Class businessInterface; 50 private java.rmi.Remote delegate; 51 52 public RemoteBusinessIntfInvocationHandler(Class businessIntf, 53 java.rmi.Remote stub) { 54 businessInterface = businessIntf; 55 delegate = stub; 56 } 57 58 public Object invoke(Object proxy, Method method, Object [] args) 59 throws Throwable { 60 61 64 Class methodClass = method.getDeclaringClass(); 65 if( methodClass == java.lang.Object .class ) { 66 return InvocationHandlerUtil. 67 invokeJavaObjectMethod(this, method, args); 68 } 69 70 Object returnValue = null; 71 Throwable t = null; 72 try { 73 Method m = delegate.getClass().getMethod 74 (method.getName(), method.getParameterTypes()); 75 76 returnValue = m.invoke(delegate, args); 77 } catch(NoSuchMethodException nsme) { 78 t = nsme; 79 } catch(InvocationTargetException ite) { 80 t = ite.getCause(); 81 } catch(Throwable c) { 82 t = c; 83 } 84 85 if( t != null ) { 86 if( t instanceof java.rmi.RemoteException ) { 87 EJBException ejbEx = new EJBException (); 88 ejbEx.initCause(t); 89 throw ejbEx; 90 } else { 91 throw t; 92 } 93 } 94 95 return returnValue; 96 } 97 98 } 99 | Popular Tags |