Annotation Type Resource
@Target({TYPE,FIELD,METHOD})
@Retention(RUNTIME)
@Repeatable(Resources.class)
public @interface Resource
Indicates a resource required by the application. Annotated classes will be used as resources. Annotated fields
and/or methods will have resources injected.
- Since:
- Common Annotations 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe AuthenticationType, either CONTAINER or APPLICATION -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionSpecifies the authentication type for the resource.Provides a human-readable description of the resource for documentation and administrative purposes.Specifies the JNDI lookup name for the resource.Specifies a product-dependent name for the resource, allowing the container to map the logical resource name to a physical resource in a vendor-specific manner.Specifies the logical name of the resource.booleanIndicates whether the resource can be shared among multiple injection points.Class<?> Uses generics since Common Annotations 1.2.
-
Element Details
-
name
String nameSpecifies the logical name of the resource. If not specified, the container derives the name from the field or method to which the annotation is applied.- Returns:
- the logical name of the resource
- Default:
""
-
type
Class<?> typeUses generics since Common Annotations 1.2.- Returns:
- The type for instances of this resource
- Default:
java.lang.Object.class
-
authenticationType
Resource.AuthenticationType authenticationTypeSpecifies the authentication type for the resource. Container authentication means the container handles authentication, while application authentication means the application code is responsible for authentication.- Returns:
- the authentication type, defaulting to
Resource.AuthenticationType.CONTAINER
- Default:
CONTAINER
-
description
String descriptionProvides a human-readable description of the resource for documentation and administrative purposes.- Returns:
- the resource description
- Default:
""
-
mappedName
String mappedNameSpecifies a product-dependent name for the resource, allowing the container to map the logical resource name to a physical resource in a vendor-specific manner. This is typically used for environment-specific configuration.- Returns:
- the product-specific mapped name for the resource
- Default:
""
-
lookup
String lookupSpecifies the JNDI lookup name for the resource. This attribute allows explicit control over the JNDI name used to locate the resource, overriding the default name derivation. The lookup name is typically prefixed with "java:comp/env/" for component environment entries.- Returns:
- the JNDI lookup name for the resource
- Since:
- Common Annotations 1.1
- Default:
""
-