2
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 ...
Get Jakarta EE Application Development - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.