File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes ejb-reference vs. jndi look up Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejb-reference vs. jndi look up" Watch "ejb-reference vs. jndi look up" New topic
Author

ejb-reference vs. jndi look up

Yan Zhou
Ranch Hand

Joined: Sep 02, 2003
Posts: 136
I understand that when look up a EJB A, I can either by its ejb-reference entry in deployment descriptor or its JNDI entry.

It is my understanding that if I look up a bean from a remote client, I must use the JNDI entry; and if I do that from a remote EJB B, I can do either way provided that the deployment descriptor for B defines ejb-reference to A, and use ejb-reference is preferred over a direct JNDI look up.

If I have a delegate class that wraps up the look up logic, and this delegate can be called by either a remote client or another EJB, then, I wil l have to supply two methods, one to look up JNDI for the client to use, and another to look up ejb-reference for other EJBs to use, right? I do not like that, but is there a one-function-fits-all solution?

what is the advantage of using ejb-reference vs. a direct JNDI lookup?

My thought is that, according to EJB spec, the deployer sets JNDI entry, therefore, when we code EJB to call another EJB, we as bean developer do NOT know the JNDI yet. However, the client developer always sees the JNDI, since they get the deployment descriptor after the deployer fills in JNDI. Is my understanding correct? In other words, there really is no difference whether to use ejb-reference or a direct JNDI lookup.

Thanks.
Yan
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ejb-reference vs. jndi look up
 
Similar Threads
Local Client Vs. Remote Client
EJB ref
Question ? - What do you think and Why
regarding JNDI
DI with @Resource adnotation understanding