The two most fundamental services provided by CDI are as follows:
Contexts: The ability to bind the lifecycle and interactions of stateful components to well-defined but extensible lifecycle contexts
Dependency injection: The ability to inject components into an application in a type-safe way, including the ability to choose at deployment time which implementation of a particular interface to inject
In addition, CDI provides the following services:
Integration with the Unified Expression Language (EL), which allows any component to be used directly within a JavaServer Faces page (or a JavaServer PagesTM page)
The ability to decorate injected components
The ability to associate interceptors with components using type-safe interceptor bindings
An event notification model
A web conversation scope in addition to the three standard scopes (request, session, and application) defined by the Java Servlet specification
A complete Service Provider Interface (SPI) that allows third-party frameworks to integrate cleanly in the Java EE 6 environment
A major theme of CDI is loose coupling. CDI does the following:
It decouples the server and the client by means of well-defined types and qualifiers, so that the server implementation may vary.
It decouples the lifecycles of collaborating components by doing the following:
Making components contextual, with automatic lifecycle management
Allowing stateful components to interact like services, purely by message passing
It completely decouples message producers from consumers, by means of events.
It decouples orthogonal concerns by means of Java EE interceptors.
Along with loose coupling, CDI provides strong typing, as follows:
It eliminates lookup using string-based names for wiring and correlations, so that the compiler will detect typing errors.
It allows the use of declarative Java annotations to specify everything, largely eliminating the need for XML deployment descriptors, and making it easy to provide tools that introspect the code and understand the dependency structure at development time.