The following table lists and describes the supported CDI annotations.
Package | Included annotation |
---|---|
javax.decorator | @Decorator |
@Delegate | |
javax.enterprise.context | @ApplicationScoped |
@ConversationScoped | |
@Dependent | |
@NormalScope | |
@RequestScoped | |
@SessionScoped | |
javax.enterprise.event | @Observes |
javax.enterprise.inject | @Alternative |
@Any | |
@Default | |
@Disposes | |
@Model | |
@New | |
@Produces | |
@Specializes | |
@Stereotype | |
@Typed | |
javax.inject | @inject |
@Named | |
@Qualifier | |
@Scope | |
@Singleton |
The following sections describe the annotations (@inject annotations) that can be coded in each component. Annotations other than @inject depend on CDI. For details on annotations that depend on CDI, see the CDI specification documents.
The following table lists the annotations that you can code in a WAR file:
Table 2-24 Annotations (javax.inject package) that can be coded in WAR file (Servlet 3.0 compliant)
Annotation name | Servlet specifications | JSP specifications | Exception class | ManagedBean (JSF) | Other class | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Servlet | Servlet (API) | Servlet filter | Servlet filter (API) | Event listener | Event listener (API) | JSP FILE | Tag handler | Tag library event listener | |||||
Classic tag handler | Simple tag handler | ||||||||||||
@Inject | Y | -- | Y | -- | Y | -- | N | N | N | N | N | Y | Y# |
The following table lists the annotations that you can code in an EJB-JAR file:
Table 2-25 Annotations (javax. inject package) that can be coded in an EJB-JAR file (Supported by EJB3.0)
Annotation name | Enterprise Bean | Exception class | Other class | |||||
---|---|---|---|---|---|---|---|---|
Interface | Session Bean | Entity Bean | Message-driven Bean | Interceptor | ||||
Other than default Interceptor | Default Interceptor | |||||||
@Inject | N | Y | N | N | N | N | N | Y# |
Annotation that can be coded in Servlet or JSP of library JAR is not available.
The following table lists the annotations that can be coded in Enterprise Bean of library JAR, Exception class, or other classes of library JAR:
Table 2-26 Annotations (javax. inject package) that can be coded in Library JAR (Enterprise Bean/Exception class/Other classes)
Annotation name | Enterprise Bean | Exception class | Other classes | ||||
---|---|---|---|---|---|---|---|
Interface | Session Bean | Entity Bean | Message-driven Bean | Interceptor | |||
@Inject | N | N | N | N | N | N | Y# |