Contexts and Dependency Injection
Contexts and Dependency Injection (CDI) is a powerful dependency injection framework that allows us to easily integrate different parts of our Jakarta EE applications. CDI beans can have different scopes, allowing their life cycle to be managed automatically by the Jakarta EE runtime. They can be easily injected as dependencies by using a simple annotation. CDI also includes an event mechanism to allow decoupled communication between different parts of our application.
In this chapter, we will cover the following topics:
- Named beans
- Dependency injection
- Qualifiers
- CDI bean scopes
- CDI events
- CDI Lite
Note
Code samples for this chapter can be found on GitHub at https://github.com/PacktPublishing/Jakarta-EE-Application-Development/tree/main/ch02_src.