Forums Register Login

ejb-reference vs. jndi look up

+Pie Number of slices to send: Send
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
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 867 times.
Similar Threads
regarding JNDI
Local Client Vs. Remote Client
DI with @Resource adnotation understanding
EJB ref
Question ? - What do you think and Why
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:04:43.