package org.jfox.ejb;
import java.rmi.RemoteException;
import java.lang.reflect.Proxy;
import javax.ejb.Handle;
import javax.ejb.EJBObject;
import org.jfox.ejb.invoker.ContainerInvokerSupport;
public class HandleImpl implements Handle {
private ContainerInvokerSupport invocationHandler = null;
public HandleImpl(ContainerInvokerSupport invocationHandler) {
this.invocationHandler = invocationHandler;
}
public EJBObject getEJBObject() throws RemoteException {
try {
ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
ObjectId objectId = invocationHandler.getObjectId();
String remoteInterfaceName = objectId.getRemoteInterfaceName();
Class remoteInterface = ctxLoader.loadClass(remoteInterfaceName);
return (EJBObject)Proxy.newProxyInstance(ctxLoader,
new Class[]{remoteInterface},
invocationHandler);
}
catch(Exception e){
e.printStackTrace();
return null;
}
}
public static void main(String[] args) {
}
}