| 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: 14685
|
|
|
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
|
 |
 |
|
|
subject: Question about @Resource annotation
|
|
|