Contexts and Dependency Injection 1.2 overview

Liberty provides support for contexts and dependency injection in applications using the Liberty features cdi-1.0 and cdi-1.2.

The Contexts and Dependency Injection (CDI) 1.2 feature provides full support for the CDI 1.2 specification. Full descriptions of the CDI 1.2 functions are provided in the CDI 1.2 specification, see Contexts and Dependency Injection for the Java EE platform.

The set of services provided by the CDI 1.2 feature includes a well-defined lifecycle for stateful objects that are bound to lifecycle contexts and a typesafe dependency injection mechanism.


Use Contexts and Dependency Injection 1.2 with JavaServer Faces applications

We can use the CDI 1.2 feature with the JavaServer Faces (JSF) 2.2 feature to enable JSF applications to take advantage of the sophisticated context and dependency injection model provided in the CDI 1.2 feature. This service is provided through integration with the Unified Expression Language (EL) which enables any contextual object to be used directly within a JSF or JavaServer Pages (JSP) page.


Use Contexts and Dependency Injection 1.2 with Enterprise JavaBeans (EJB)

We can use the CDI 1.2 feature with the Enterprise JavaBeans (EJB) 3.2 feature to enhance the EJB component model with contextual lifecycle management. The services provided by the CDI 1.2 feature integrate the Java EE web tier with Java EE enterprise services. In particular, this enables EJB components to be used as JSF managed beans, thus integrating the programming models of EJB and JSF.


Use Contexts and Dependency Injection 1.2 with Servlet 3.1

We can use the CDI 1.2 feature with the Servlet 3.1 feature to enable servlet applications to take full advantage of the services provided by the CDI 1.2 feature. Use both features enables contextual managed beans to be injected into servlet applications using field, method or constructor injection. The CDI 1.2 feature also provides automatic registration of servlet listeners, filters, and interceptors.


Java Interceptors in Contexts and Dependency Injection 1.2 applications

The CDI 1.2 feature extends the Java model for interceptors. The CDI 1.2 feature provides the ability to associate interceptors with beans. The interceptors are bound using typesafe interceptor bindings. This model can be extended to EJB beans when both the CDI 1.2 and EJB 3.2 features are loaded onto the Liberty server.