It's not a secret anymore!
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes ejb-link?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "ejb-link??" Watch "ejb-link??" New topic


Senthil Kumar
Ranch Hand

Joined: Mar 13, 2006
Posts: 264
we use ejb-ref, ejb-local-ref to refer other enterprise beans inside the bean class when we don't know the real JNDI name.And the Deployer maps these reference to the real JNDI name.

but what do we get when we use ejb-link here?.

when you really want something, all the universe always conspires in your favour.<br /> <br />SCJP1.5-77%<br />SCWCD-89%
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

To understand more on ejb-link, let's take a look at this simple scenario.

Let's say you have 2 session beans: A and B.

Bean A needs to do a lookup for bean B. Since you don't know what JDNI name for bean B, you can use the <ejb-name> from <ejb-ref> to do the lookup. The <ejb-link> is used to tell that it's actually referring to SessionB.

Inside your bean A, you will have a code like this:
Object o = ctx.lookup("java:comp/env/ejb/SessionB);

The deployer can map the actual JNDI name for session B to a completely different name. If you use Sun Java System Application Server, it's defined in sun-ejb.xml.

SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
I agree. Here's the link:
subject: ejb-link??
It's not a secret anymore!