Contexts and Dependency Injection (CDI) defines a set of
complementary services that help improve the structure of application
code.
Core CDI specification is split into Lite and Full. Lite includes
most of the features and is tailored for runtimes that don't intend
to implement the entire Jakarta EE platform. Full includes features
that are not deemed necessary for all CDI implementations. Jakarta EE
implementations are required to support Full.
- A well-defined lifecycle for stateful
{@linkplain jakarta.enterprise.inject beans} bound to well-defined
lifecycle {@linkplain jakarta.enterprise.context contexts}, where
the set of contexts is {@linkplain jakarta.enterprise.context.spi
extensible}
- A sophisticated, typesafe {@linkplain jakarta.enterprise.inject
dependency injection mechanism}, including the ability to select
dependencies at either {@linkplain jakarta.inject.Qualifier development}
or {@linkplain jakarta.enterprise.inject.Alternative deployment} time,
without verbose configuration
- Support for Jakarta EE modularity and the Jakarta EE component
architecture—the modular structure of a Jakarta EE application is
taken into account when resolving dependencies between Jakarta EE
components
- {@linkplain jakarta.enterprise.inject Integration} with the
Unified Expression Language, allowing any bean to be used directly
within a JSF or JSP page (only in Full)
- The ability to {@linkplain jakarta.decorator decorate} injected
beans (only in Full)
- The ability to associate
{@code jakarta.interceptor.Interceptor} with beans via typesafe
{@linkplain jakarta.enterprise.inject interceptor bindings}
- An {@linkplain jakarta.enterprise.event event} notification model
- A web {@linkplain jakarta.enterprise.context.ConversationScoped
conversation context} in addition to the three standard
web contexts defined by the Java Servlets specification (only in Full)
- A {@linkplain jakarta.enterprise.inject.build.compatible.spi build-compatible SPI}
and a {@linkplain jakarta.enterprise.inject.spi runtime SPI} allowing portable
extensions to integrate cleanly with the container (runtime SPI only in Full)
CDI allows objects to be bound to lifecycle contexts, to be
injected, to be associated with interceptors and decorators, and to
interact in a loosely coupled fashion by
{@linkplain jakarta.enterprise.event.Event firing} and
{@linkplain jakarta.enterprise.event.Observes observing} events.
{@linkplain jakarta.enterprise.inject Various kinds} of objects are
injectable, including EJB 3 session beans, managed beans,
{@linkplain jakarta.enterprise.inject.Produces producer methods} and
Jakarta EE resources. We refer to these objects in general terms as beans
and to instances of beans that are bound to contexts as contextual
instances.