This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Pipeline as Code and have Mohamed Labouardy on-line!
See this thread for details.
Win a copy of Pipeline as Code this week in the Cloud/Virtualization 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

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
 
What's a year in metric? Do you know this metric stuff tiny ad?
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic