-
1. Re: PortableRemoteObject vs ctx.lookup
jpvasquez Oct 1, 2001 5:43 PM (in response to craigeebach)Craig,
My understanding is that when working over RMI, the ctx.lookup with a cast will work fine. But, according to the newer EJB specs, the system should support RMI/IIOP as a transport--RMI/IIOP requires the call to PortableRemoteObject.narrow(). So, to create the most portable code, use the narrow() call. But, doing a plain lookup anda a cast works fine in JBoss for now.
hope that helps,
jason -
2. Re: PortableRemoteObject vs ctx.lookup
craigeebach Oct 2, 2001 3:56 PM (in response to craigeebach)Thanks Jason. I found some additional information on this I will post should any other rusty ejb programmers stumble on this thread.
-Craig
From Borland:
So what is actually going on? CORBA-based implementations, in general, do not return the "actual" server type from a method invocation. They return the "signature" type which can then be narrowed to a more specific type, if need be. In certain circumstances, determining if an object can be narrowed to the desired type requires an RPC to the server implementing the object. However, although our implementation is built on CORBA, we thought it was more user friendly to support the casting behavior, when possible. This was how our beta Container behaved. However, as stated above, sometimes this behavior requires an RPC to the server.
So, now we can start to answer the question.
Using javax.rmi.PortableRemoteObject.narrow will succeed in all cases, and is preferred. In fact the final EJB 1.1 specification pretty much mandates the use of PortableRemoteObject always.