CDI 1.1

CDI 1.1 focuses on improving CDI 1.0:

  • Add global enablement of interceptors (see the Java Interceptors Specification 1.2), global enablement of decorators (read more) and alternatives (read more) using the @Priority annotation
  • Add support for @AroundConstruct lifecycle callback for constructors (see the Java Interceptors Specification 1.2)
  • Allow binding interceptors to constructors
  • Moved interceptor binding to interceptors spec, allowing for reuse by other specifications
  • Support decorators on built in beans (read more)
  • Add EventMetadata (read more) to allow inspection of event metadata
  • Add @Vetoed annotation allowing easy programmatic disablement of classes (read more)
  • Many improvements for passivation capable beans, including @TransientReference allowing instances to be retained only for use within the invoked method or constructor (read more and read more)
  • Add scope activation and destruction callback events (read more)
  • Add AlterableContext allowing bean instances to be explicitly destroyed (read more)
  • Add automatic enablement of CDI for beans with a scope annotation, and EJBs, in Java EE (read more)
  • Add class exclusion filters to beans.xml to prevent scanning of classes and packages (read more)
  • Add Unmanaged allowing easy access to non-contexutal instances of beans (read more)
  • Add CDI allowing easy accesss to the current CDI container (read more)
  • Add AfterTypeDiscovery event, allowing extensions to register additional types after type discovery (read more)
  • Add @WithAnnotations as a way of improving extension loading performance (read more)
  • Many minor improvements to portable extensions (read more)

What is CDI?

Contexts and Dependency Injection for Java EE (CDI) 1.0 was introduced as part of the Java EE 6 platform, and has quickly become one of the most important and popular components of the platform.

CDI defines a powerful set of complementary services that help improve the structure of application code.

  • A well-defined lifecycle for stateful objects bound to lifecycle contexts, where the set of contexts is extensible
  • A sophisticated, typesafe dependency injection mechanism, including the ability to select dependencies at either development or deployment time, without verbose configuration
  • Support for Java EE modularity and the Java EE component architecture?the modular structure of a Java EE application is taken into account when resolving dependencies between Java EE components
  • Integration with the Unified Expression Language (EL), allowing any contextual object to be used directly within a JSF or JSP page
  • The ability to decorate injected objects
  • The ability to associate interceptors to objects via typesafe interceptor bindings
  • An event notification model
  • A web conversation context in addition to the three standard web contexts defined by the Java Servlets specification
  • An SPI allowing portable extensions to integrate cleanly with the container

Latest Release

The latest release of CDI is 1.1. You can download the spec or browse the javadoc.

CDI 1.0

Contexts and Dependency Injection for Java EE (CDI) 1.0 was introduced as part of the Java EE 6 platform, and has quickly become one of the most important and popular components of the platform.

CDI defines a powerful set of complementary services that help improve the structure of application code.

  • A well-defined lifecycle for stateful objects bound to lifecycle contexts, where the set of contexts is extensible
  • A sophisticated, typesafe dependency injection mechanism, including the ability to select dependencies at either development or deployment time, without verbose configuration
  • Support for Java EE modularity and the Java EE component architecture?the modular structure of a Java EE application is taken into account when resolving dependencies between Java EE components
  • Integration with the Unified Expression Language (EL), allowing any contextual object to be used directly within a JSF or JSP page
  • The ability to decorate injected objects
  • The ability to associate interceptors to objects via typesafe interceptor bindings
  • An event notification model
  • A web conversation context in addition to the three standard web contexts defined by the Java Servlets specification
  • An SPI allowing portable extensions to integrate cleanly with the container

Below is the current list of servers supporting CDI, also listed is the implementation used.

Oracle GlassFish 3.x

using Weld

TMAX JEUS 7

using Weld

IBM WebSphere 8.x / Community Edition 3.0

using OpenWebBeans

Fujitsu Interstage v10.1 / Windows Azure

using Weld

Oracle WebLogic 12

using Weld

Apache Geronimo 3.0-beta-1

using OpenWebBeans

JBoss AS7

using Weld

Hitachi uCosminexus v 9.0

using Weld

JBoss EAP 6

using Weld

Caucho Resin 4.0.17

using CanDI

Apache TomEE 1.0

using OpenWebBeans

SAP NetWeaver Cloud

using OpenWebBeans

JOnAS

using Weld