1 6 7 package org.jfox.ejb; 8 9 import java.lang.reflect.Proxy ; 10 import java.rmi.RemoteException ; 11 import javax.ejb.EJBObject ; 12 import javax.ejb.Handle ; 13 14 import org.jfox.ioc.connector.ConnectorInvoker; 15 16 19 20 public class HandleImpl implements Handle { 21 private ConnectorInvoker invocationHandler = null; 22 23 public HandleImpl(ConnectorInvoker invocationHandler) { 24 this.invocationHandler = invocationHandler; 25 } 26 27 public EJBObject getEJBObject() throws RemoteException { 28 try { 29 ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader(); 30 EJBObjectId objectId = (EJBObjectId)invocationHandler.getClientId(); 32 String remoteInterfaceName = objectId.getRemoteInterfaceName(); 33 Class remoteInterface = ctxLoader.loadClass(remoteInterfaceName); 34 return (EJBObject ) Proxy.newProxyInstance(ctxLoader, 36 new Class []{remoteInterface}, 37 invocationHandler); 38 } 39 catch(Exception e) { 40 e.printStackTrace(); 41 return null; 42 } 43 } 44 45 public static void main(String [] args) { 46 47 } 48 } | Popular Tags |