Resource (Common Annotations 2.1 API Documentation - Apache Tomcat 10.1.39)
Description: declaration: package: jakarta.annotation, annotation type: Resource

# 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 Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `Resource.AuthenticationType`
  The AuthenticationType, either CONTAINER or APPLICATION

- ## Optional Element Summary

  Optional Elements
  Modifier and Type
  Optional Element
  Description
  `Resource.AuthenticationType`
  `authenticationType`
  `String`
  `description`
  `String`
  `lookup`
  `String`
  `mappedName`
  `String`
  `name`
  `boolean`
  `shareable`
  `Class<?>`
  `type`
  Uses generics since Common Annotations 1.2.

- ## Element Details

  - ### name

    String name
    Returns:
      a String with the name of the resource
    Default:
      `""`

  - ### type

    Class<?> type
    Uses generics since Common Annotations 1.2.
    Returns:
      The type for instances of this resource
    Default:
      `java.lang.Object.class`

  - ### authenticationType

    Resource.AuthenticationType authenticationType
    Returns:
      the AuthenticationType of the resource default CONTAINER
    Default:
      `CONTAINER`

  - ### shareable

    boolean shareable
    Returns:
      true (default) if the resource is shareable, or false if not
    Default:
      `true`

  - ### description

    String description
    Returns:
      a string with the description for the resource
    Default:
      `""`

  - ### mappedName

    String mappedName
    Returns:
      a string with the mappedName of the resource
    Default:
      `""`

  - ### lookup

    String lookup
    Returns:
      The name of the entry, if any, to use for this resource
    Since:
      Common Annotations 1.1
    Default:
      `""`