This repository holds the sample application which covers the main concepts of the CDI 2.0 specification. After working through the tasks one should be able to understand the main concepts of the CDI 2.0 specification and to use the CDI 2.0 concepts in real time applications.
The application is based on the Jakarta-EE 8.0 (CDI 2.0) specification and the Wildfly 22.0.0.Final application server.
Take a look at these slides for an introduction to CDI.
The following CDI concepts are covered by this example
-
Injection
-
Scopes
-
Initialization (
@PostConstruct, @PreDestroy
) -
Qualifiers
-
Producer Methods/Fields
-
Interceptors
-
Decorators
-
Events
Additionally, to the CDI basics, this sample application provides implementations with explanations for use cases we faced in our projects.
-
Scopes and Concurrency
How to provide request scoped state when using concurrency where we only can use@Dependent, @ApplicationScoped
beans? -
Dynamic Default
How to change the@Default
of an CDI bean during runtime? -
Alternatives
How and when to use@Alternative
beans? -
Specialized
How and when to use@Specialized
beans, and what differs them from@Alternative
beans? -
Registrar
How to use a registrar to capture asynchronous executions results, which are needed by other parts of the application? -
Startup-Event
How to notify the application about that the application has started? -
Lookup-Factory
How to implement a factory to encapsulate the CDI programmatic bean lookup and how to manage@Dependent
scoped beans properly?
To get the application running you need the following software installed:
The application can be accessed via http://localhost:8080/cditraining/welcome
.
Follow the instructions to work through the exercises.
Important
|
When running in an IDE the actual port will depend on your configuration. |
Run the application with ./mvnw wildfly:run
.
Important
|
In this mode you won’t be able to hot-code deploy. |