Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

EJB ref

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is EJB ref, while deploying an EJB
Regards,
aakash
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ejb-ref elements in the standard ejb-jar.xml are used to specify logical references to another EJB the one being described is going to use. It's basically a promise/requirement saying "the application deployer must map this reference to a real JNDI name upon deployment".
For example, you have an EJB called CustomerBean that needs to use the AccountBean. You could just lookup the AccountBean from CustomerBean using the JNDI name that was used to deploy AccountBean with. This approach does have its sore points however. What happens if the application deployer finds out that the JNDI name the bean developer had assumed cannot be used in the production environment for some reason? The solution would be to abstract the real JNDI name from the CustomerBean by using ejb-ref.
The ejb-jar.xml of CustomerBean would define an ejb-ref so that CustomerBean code can use "java:comp/env/XXX" to lookup the AccountBean where "XXX" is anything the deployer wills. It is then the application deployer's job to specify the link between ejb-ref and the real JNDI name. With WebLogic, for example, this is done using weblogic-ejb-jar.xml (i.e. using the vendor-specific deployment descriptor).
 
Hey cool! They got a blimp! But I have a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic