• 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

Why use beanName() OR mappedName() ?

 
Ranch Hand
Posts: 49
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why is there a need for attributes like beanName() OR mappedName() when name() attribute is already available as per the EJB3.1 specification?
According to EJB O'Reily,
1. "The name() attribute refers to what the JNDI ENC name will be for the referenced EJB. This name is relative to the java:comp/env context."
2. "The beanName() is the EJB name of the EJB referenced. It is equal to either the value you specify in the @Stateless.name() or @Stateful.name()
annotation or the value you put in the <ejb-name> field in the XML deployment descriptor."
3. "The mappedName() attribute is a placeholder for a vendor-specific identifier. This identifier may be a key into the vendor’s global registry."

In addition to the above the lookup() attribute adds more to the confusion.
Can someone clarify with an example please?
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Stateless(name="manager")

is a friendly name. Imagine you have the following:



you can just refer to the bean with "manager" instead of the full class name.


mappedName as you stated is vendor specific. So its behaviour depends on the container you will be using.
in Glassfish is used to assign a global name in JNDI

for beanName you can check this thread (i've never used it myself):

Thread Link

You use the Lookup when you need to locate a bean looking in the context.

For instance, check the section related to the RMI (Calling an EJB remotely). In which case you will need
to ask the remote server to look into the context and find your bean.

Normally, when working on the local server with local beans, I don't ask the context to find beans ,
i just inject them and let EJB taking care of finding them.

Regards
Dave
reply
    Bookmark Topic Watch Topic
  • New Topic