*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Question about @Resource annotation" Watch "Question about @Resource annotation" New topic
Author

Question about @Resource annotation

Peter Bugyi
Greenhorn

Joined: Mar 09, 2011
Posts: 3
Hi!

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 {
CONTAINER,
APPLICATION
}
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é
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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
 
jQuery in Action, 2nd edition
 
subject: Question about @Resource annotation
 
Similar Threads
jndi name in ejb3?
Using Tomcat Standard Resource Factories
Doubt with DI & JNDI
JMS in Stateless Bean
Error when deploying an EAR on JBoss 5.1.0