Hello,
I am currently studying ejbs and I came across the ejb-ref element of the ejb-jar.xml file. I am in reference to O'Reilly Entreprise JavaBeans book. The book says that, thanks to the ejb-ref element it is possible to access one ejb from another ejb with the following client code:
[code]
InitialContext jndiContext = new InitialContext();
Object ref = jndiContext.lookup("java:comp/env/ejb/ProcessPaymentHomeRemote");
ProcessPaymentHomeRemote home = (ProcessPaymentHomeRemote) PortableRemoteObject.narrow(ref, ProcessPaymentHomeRemote.class);
[/code]
I thought one could invoke the above client code without the ejb-ref element being present in the ejb-jar.xml... I am right or wrong?
Then why the need for the ejb-ref element? Can anyone give me a concrete example of usage of the ejb-ref element where the ejb-ref element really is useful? What are the advantages of using the ejb-ref element?
Thanks in advance,
Julien Martin.
Discussions
EJB programming & troubleshooting: More information about the ejb-ref element of ejb-jar.xml
-
More information about the ejb-ref element of ejb-jar.xml (2 messages)
- Posted by: Julien Martin
- Posted on: July 13 2004 14:00 EDT
Threaded Messages (2)
- More information about the ejb-ref element of ejb-jar.xml by Senthil Chinnaiyan on July 13 2004 16:18 EDT
- ejb-ref by Julien Martin on July 14 2004 16:52 EDT
-
More information about the ejb-ref element of ejb-jar.xml[ Go to top ]
- Posted by: Senthil Chinnaiyan
- Posted on: July 13 2004 16:18 EDT
- in response to Julien Martin
You can access EJB without ejb-ref, in that case you have to hardcode the other bean's JNDI name in your bean's code.
This might help you: http://www.theserverside.com/discussions/thread.tss?thread_id=25668
Senthil -
ejb-ref[ Go to top ]
- Posted by: Julien Martin
- Posted on: July 14 2004 16:52 EDT
- in response to Senthil Chinnaiyan
Thanks a lot for your reply Senthil,
If I understand you, ejb-ref avoids us to have to re-specify the following information for inter ejb calls:
******************************
Context.INITIAL_CONTEXT_FACTORY
Context.PROVIDER_URL
Context.SECURITY_PRINCIPAL
Context.SECURITY_CREDENTIALS
******************************
but instead of having one information hardcoded we have another hardcoded (e.g. java:comp/env/ejb/AddressHomeLocal).
Am I right?
Julien.