Hi All, If say I have an Entity Bean with both remote and local interfaces. If i want to used the local interfaces i would do InitialContext ic=new InitialContext(); Object obj=ic.lookup("ejb/MyEntityBean"); LocalMyEntityBeanHome hom=(LocalMyEntityBeanHome)PortableRemoteObject.narrow(obj, LocalMyEntityBeanHome.class); if it is remote interface i would do InitialContext ic=new InitialContext(); Object obj=ic.lookup("ejb/MyEntityBean"); MyEntityBeanHome hom=(MyEntityBeanHome)PortableRemoteObject.narrow(obj, MyEntityBeanHome.class);
to get their home interfaces respectively, is that true? Thanks Ras
I'm just new to EJB but i would like to try to answer your question.....
for local home interface, i think you dont need the PortableRemoteObject class because your interface is already "local" Pradeep is correct in saying that:
For local just do LocalMyEntityBeanHome hom=(LocalMyEntityBeanHome)obj;
Be Afraid...Be very Afraid...
posted 17 years ago
Thanks Chris, So, if I have a remote interface binded to ejb/myEJB then the local interface should be bind to jndi name other than ejb/myEJB, is that right? Assuming that the ejb has both local and remote interfaces. Sorry if this sound like a stupid question.
I have another question, hope someone could answer it. In the ejb specs, it says that remote references are passed by value and local references are passed by reference. But Application server can be set to optimized it (say orion has a pass-by-value tag in orion-ejb-jar file to do that). In the specs it also says that remote references should like obey the RMI-IIOP and local references should obey the normal java rules. So if an object serialized is passed in a remote reference then a copy of it will be pass. What about the object is a remote one? Is it passed by reference? Or the ejb container have the last say of it to either be passed by value or reference? The local object passed, is it going to be passed by reference or determined by the container settings? For primitive types, they are all passed by value regardless of remote or local references, is that right? Thanks Rastin
Bring me the box labeled "thinking cap" ... and then read this tiny ad: