Hi All
I would like to know whats the use of ejb-reference . How does it actually simplify things.
I have read it is used for intra bean calls. but the way it is done there seems no difference in the way a normal look up is done . We have to do a JNDI look up in the very same way as we do it from web clients like a
servlet.
normally from a client we access the JNDI for
ejb home reference
public class ABean implements SessionBean {
public void businessMethod(...) {
...
InitialContext namingContext = new InitialContext();
Object ref = namingContext.lookup("java:comp/env/ejb/myBean");
BHome home = (BHome)PortableRemoteObject(ref);
B bean = home.create(pk);
...
}
}
is this "java:comp/env/" necessary cant i just say
Object ref = namingContext.lookup("ejb/myBean");
in the above code. As far as i know we can (correct me if i m wrong)
So how does ejb-ref tag simplify things.
Normally from any client we access the jndi as shown above so how does the JNDi access differ if say the client access the EJB is a local client say an SLSB.
So how is a local client different in terms of JNDI access not mentioning the local interfaces & call by reference advantage.
Why we need an ejb-ref tag for clients which are local for an EJB.
or is it that we require an ejb-ref tag for every ejb we deploy to give it a JNDI name so client can look up on that name.
Kidly clarify
Rgrds