Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Local and Remote Interfaces  RSS feed

 
rastin purr
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For local just do
LocalMyEntityBeanHome hom=(LocalMyEntityBeanHome)obj;
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, I think the two interfaces would be stored under different JNDI names. At least that's true under WebLogic.
 
rastin purr
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Greg,
Could you explain further about the different JNDI names between local and remote references?
What about J2ee ri, Orion and OC4j?
Thanks
rastin
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JNDI entries can only be bound to a single object. Therefore the Local and Remote Home interfaces must be bound to different JNDI names, regardless of application server.
 
Paulo Aquino
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;

 
rastin purr
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!