• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HFE Page 613 - EJB references (When a bean wants another bean)

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I was going through HFE page 613. It talks about <ejb-ref> to lookup a EJB from a another EJB. I am quite confused here because in the first few chapters it showed how the bean provider used <ejb-name> to lookup the bean's home
i,e ic.lookup("AdviceBean") instead of ic.lookup("java:comp/env/ejb/AdviceBean")

How does this makes a difference when it is the bean provider who is creating the <ejb-ref> and also the <ejb-name> and linking both by <ejb-link>.
I am surely missing something here. Can anybody please explain this to me?
Regards
Mini
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<ejb-ref>/<ejb-local-ref> allows one EJB to reference another EJB by some name that is resolved to JNDI name in deployment descriptor. this avoids hard-coding of referenced EJB's JNDI name in the code.
this feature is not available to non-EJB client.
you may refer to following article -
http://www.huihoo.com/jboss/online_manual/3.0/ch07s13.html
 
mini mehta
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by C Chavan:
<ejb-ref>/<ejb-local-ref> allows one EJB to reference another EJB by some name that is resolved to JNDI name in deployment descriptor. this avoids hard-coding of referenced EJB's JNDI name in the code.
this feature is not available to non-EJB client.
you may refer to following article -
http://www.huihoo.com/jboss/online_manual/3.0/ch07s13.html



Do you mean that for non-EJB clients it the EJB container needs to get the real JNDI context using the vendor specific configuration file.
Whereas if it is for EJB Client(i,e another EJB) it can do it in ejb-jar.xml itself because the real JNDI context is known by the calling EJB.

But does that mean we have to create entry for all the EJBs in the vendor specific configuration file for it to be used effectively?
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
---------------------------------------------------------------------------------
How does this makes a difference when it is the bean provider who is creating the <ejb-ref> and also the <ejb-name> and linking both by <ejb-link>.
I am surely missing something here.
---------------------------------------------------------------------------------
Bean provider specifies the <ejb-name> and <ejb-ref> in the deployment descriptor...Where as application assembler or deployer specifies the <ejb-link> The value of ejb-link element is the name of target enterprise bean.
 
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by mini mehta:
i,e ic.lookup("AdviceBean") instead of ic.lookup("java:comp/env/ejb/AdviceBean")


Mini, I wonder if we start thinking about who's calling the lookup method it will become more clear. When you saw look-ups WITHOUT the "java:comp/env", was that client code? When you saw look-ups WITH the "java:comp/env", was that with bean code?
When we deploy, we will likely choose to expose (via RMI) our home bean class. The 'fakey' client code in the book does NOT say "use this RMI server on this machine, this port, and see if you can find something called "Advisor" (it just uses the "everything's local" shortcut - fine, but doesn't show what it's really doing).
Now, if we are another bean (and not a client), and we want to find some other bean..... Universally we know how to find that other bean because we always put all of our beans in the ejb context using using the naming convention that we as the bean developer choose (posted under <ejb-ref-name> . The deployer might decide to call it something else, but we don't care, we can always find it "our way".
--Dale--
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic