Jakarta Contexts and Dependency Injection (CDI) defines a set of
complementary services that help improve the structure of application
code.
- A well-defined lifecycle for stateful
{@linkplain javax.enterprise.inject beans} bound to well-defined
lifecycle {@linkplain javax.enterprise.context contexts}, where
the set of contexts is {@linkplain javax.enterprise.context.spi
extensible}
- A sophisticated, typesafe {@linkplain javax.enterprise.inject
dependency injection mechanism}, including the ability to select
dependencies at either {@linkplain javax.inject.Qualifier development}
or {@linkplain javax.enterprise.inject.Alternative deployment} time,
without verbose configuration
- Support for Jakarta EE modularity and the Jakarta EE component
architecture—the modular structure of a Java EE application is
taken into account when resolving dependencies between Java EE
components
- {@linkplain javax.enterprise.inject Integration} with the
Jakarta Expression Language, allowing any bean to be used directly
within a Jakarta Server Faces or Jakarta Server Page page
- The ability to {@linkplain javax.decorator decorate} injected
beans
- The ability to associate
{@linkplain javax.interceptor interceptors} with beans via typesafe
{@linkplain javax.enterprise.inject interceptor bindings}
- An {@linkplain javax.enterprise.event event} notification model
- A web {@linkplain javax.enterprise.context.ConversationScoped
conversation context} in addition to the three standard
web contexts defined by the Jakarta Servlet specification
- An {@linkplain javax.enterprise.inject.spi SPI} allowing portable
extensions to integrate cleanly with the container
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 javax.enterprise.event.Event firing} and
{@linkplain javax.enterprise.event.Observes observing} events.
{@linkplain javax.enterprise.inject Various kinds} of objects are
injectable, including EJB 3 session beans, managed beans,
{@linkplain javax.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.