Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Local and Remote Interfaces

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For local just do
LocalMyEntityBeanHome hom=(LocalMyEntityBeanHome)obj;
 
Sheriff
Posts: 3036
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
These are the worst of times and these are the best of times. And this is the best tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic