From: Francisco R. <rev...@us...> - 2002-08-21 23:13:10
|
User: reverbel Date: 02/08/21 16:13:10 Modified: iiop/src/main/org/jboss/proxy/ejb HandleImplIIOP.java HomeHandleImplIIOP.java IIOPHomeFactory.java Log: Problem: home factory, handle impl, and home handle impl issued ORB.init() calls to get an ORB. so these classes never used the same ORB instance as the CorbaORBService MBean. As a consequence, some in-VM IIOP invocations were handled as remote invocations (the "local call path" optimization was not performed). Solution: a singleton CorbaORB was introduced. Home factory, handle impl, and home handle impl now get an ORB via CorbaORB.getInstance(). If called in the same VM as the JBoss server, CorbaORB.getInstance() returns the ORB instance used by the CorbaORBService MBean. Otherwise it performs an ORB.init() call. Revision Changes Path 1.2 +9 -12 contrib/iiop/src/main/org/jboss/proxy/ejb/HandleImplIIOP.java Index: HandleImplIIOP.java =================================================================== RCS file: /cvsroot/jboss/contrib/iiop/src/main/org/jboss/proxy/ejb/HandleImplIIOP.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HandleImplIIOP.java 17 May 2002 02:04:50 -0000 1.1 +++ HandleImplIIOP.java 21 Aug 2002 23:13:09 -0000 1.2 @@ -14,7 +14,8 @@ import javax.ejb.EJBObject; import javax.ejb.Handle; import javax.rmi.PortableRemoteObject; -import org.omg.CORBA.ORB; + +import org.jboss.iiop.CorbaORB; /** * A CORBA-based EJBObject handle implementation. @@ -22,17 +23,11 @@ * @author <a href="mailto:ric...@te...">Rickard Öberg</a>. * @author <a href="mailto:ja...@pl...">Jason Dillon</a> * @author <a href="mailto:rev...@im...">Francisco Reverbel</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class HandleImplIIOP implements Handle { - private static ORB orb; - - static { - Properties props = System.getProperties(); - orb = ORB.init(new String[0], props); - } /** * This handle encapsulates an stringfied CORBA reference for an @@ -67,7 +62,7 @@ */ public HandleImplIIOP(org.omg.CORBA.Object obj) { - this.ior = orb.object_to_string(obj); + this.ior = CorbaORB.getInstance().object_to_string(obj); } // Public -------------------------------------------------------- @@ -84,14 +79,16 @@ public EJBObject getEJBObject() throws RemoteException { - try { + try + { return (EJBObject)PortableRemoteObject.narrow( - orb.string_to_object(ior), EJBObject.class); + CorbaORB.getInstance().string_to_object(ior), + EJBObject.class); } - catch (Exception e) { + catch (Exception e) + { throw new RemoteException("Could not get EJBObject from Handle"); } } } - 1.2 +11 -14 contrib/iiop/src/main/org/jboss/proxy/ejb/HomeHandleImplIIOP.java Index: HomeHandleImplIIOP.java =================================================================== RCS file: /cvsroot/jboss/contrib/iiop/src/main/org/jboss/proxy/ejb/HomeHandleImplIIOP.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HomeHandleImplIIOP.java 17 May 2002 02:04:50 -0000 1.1 +++ HomeHandleImplIIOP.java 21 Aug 2002 23:13:09 -0000 1.2 @@ -14,7 +14,8 @@ import javax.ejb.EJBHome; import javax.ejb.HomeHandle; import javax.rmi.PortableRemoteObject; -import org.omg.CORBA.ORB; + +import org.jboss.iiop.CorbaORB; /** * A CORBA-based EJB home handle implementation. @@ -22,18 +23,11 @@ * @author <a href="mailto:ric...@te...">Rickard Öberg</a>. * @author <a href="mailto:ja...@pl...">Jason Dillon</a> * @author <a href="mailto:rev...@im...">Francisco Reverbel</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class HomeHandleImplIIOP implements HomeHandle { - private static ORB orb; - - static { - Properties props = System.getProperties(); - orb = ORB.init(new String[0], props); - } - /** * This handle encapsulates an stringfied CORBA reference for an * <code>EJBHome</code>. @@ -67,7 +61,7 @@ */ public HomeHandleImplIIOP(org.omg.CORBA.Object home) { - this.ior = orb.object_to_string(home); + this.ior = CorbaORB.getInstance().object_to_string(home); } // Public -------------------------------------------------------- @@ -84,11 +78,14 @@ public EJBHome getEJBHome() throws RemoteException { - try { - return (EJBHome)PortableRemoteObject.narrow(orb.string_to_object(ior), - EJBHome.class); + try + { + return (EJBHome)PortableRemoteObject.narrow( + CorbaORB.getInstance().string_to_object(ior), + EJBHome.class); } - catch (Exception e) { + catch (Exception e) + { throw new RemoteException("Could not get EJBHome from HomeHandle"); } } 1.2 +3 -4 contrib/iiop/src/main/org/jboss/proxy/ejb/IIOPHomeFactory.java Index: IIOPHomeFactory.java =================================================================== RCS file: /cvsroot/jboss/contrib/iiop/src/main/org/jboss/proxy/ejb/IIOPHomeFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- IIOPHomeFactory.java 17 May 2002 02:04:50 -0000 1.1 +++ IIOPHomeFactory.java 21 Aug 2002 23:13:09 -0000 1.2 @@ -16,7 +16,8 @@ import javax.naming.Reference; import javax.naming.spi.ObjectFactory; import javax.rmi.PortableRemoteObject; -import org.omg.CORBA.ORB; + +import org.jboss.iiop.CorbaORB; /** * An <code>ObjectFactory</code> implementation that translates @@ -25,13 +26,11 @@ * <code>Reference</code>s in the JRMP/JNDI namespace. * * @author <a href="mailto:rev...@im...">Francisco Reverbel</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class IIOPHomeFactory implements ObjectFactory { - private static ORB orb = ORB.init(new String[0], System.getProperties()); - public IIOPHomeFactory() { } @@ -43,7 +42,7 @@ throws Exception { return (EJBHome)PortableRemoteObject.narrow( - orb.string_to_object( + CorbaORB.getInstance().string_to_object( (String)((Reference)obj).get("IOR").getContent()), EJBHome.class); } |