2.1.11 List of supported CDI annotations

The following table lists and describes the supported CDI annotations.

PackageIncluded 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.

Organization of this subsection
(1) WAR file (Servlet 3.0 compliant)
(2) EJB-JAR file (EJB3.1 compliant)
(3) Library JAR (Servlet/JSP)
(4) Library JAR (Enterprise Bean/ Exception class/ Other classes)

(1) WAR file (Servlet 3.0 compliant)

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 nameServlet specificationsJSP specificationsException classManagedBean (JSF)Other class
ServletServlet (API)Servlet filterServlet filter (API)Event listenerEvent listener (API)JSP FILETag handlerTag library event listener
Classic tag handlerSimple tag handler
@InjectY--Y--Y--NNNNNYY#
Legend:
Y: Supported.
--: Not supported by standard specifications.
N: Not supported by Application Server.
#
You can use corresponding components only if the components include CDI functions.

(2) EJB-JAR file (EJB3.1 compliant)

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 nameEnterprise BeanException classOther class
InterfaceSession BeanEntity BeanMessage-driven BeanInterceptor
Other than default InterceptorDefault Interceptor
@InjectNYNNNNNY#
Legend:
Y: Supported.
N: Not supported by Application Server.
#
You can use corresponding components only if the components include CDI functions.

(3) Library JAR (Servlet/JSP)

Annotation that can be coded in Servlet or JSP of library JAR is not available.

(4) Library JAR (Enterprise Bean/ Exception class/ Other classes)

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 nameEnterprise BeanException classOther classes
InterfaceSession BeanEntity BeanMessage-driven BeanInterceptor
@InjectNNNNNNY#
Legend:
Y: Supported.
N: Not supported by Application Server.
#
You can use corresponding components only if the components include CDI functions.