This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question about @Resource annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Question about @Resource annotation" Watch "Question about @Resource annotation" New topic

Question about @Resource annotation

Peter Bugyi

Joined: Mar 09, 2011
Posts: 3

Could somebody explain to me what is the difference between the mappedName and the lookup property?

package javax.annotation;
@Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
public @interface Resource
public enum AuthenticationType {
String name( ) default "";
Class type( ) default Object.class;
AuthenticationType authenticationType( ) default AuthenticationType.CONTAINER;
boolean shareable( ) default true;
String description( ) default "";
String mappedName( ) default "";
String lookup( ) default "";
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

The "mappedName" is used to identify the resource in JNDI, but it is container specific. The way you write it depends on the container, so it's not portable. To come over this problem, the "lookup" attribute was added to J2EE6. You can use it to specify the complete JNDI path to your resource, and this will work with any containers.

[My Blog]
All roads lead to JavaRanch
I agree. Here's the link:
subject: Question about @Resource annotation
jQuery in Action, 3rd edition