Chapter 11: Leveraging CDI Beans to Manage Ports and Use Cases
Quarkus provides its own dependency injection solution called Quarkus DI. It stems from the Contexts and Dependency Injection (CDI) for Java 2.0 specification. We employ CDI to delegate the responsibility to provide object instances to an external dependency and manage their life cycle across the application. Several dependency injection solutions in the market take such responsibility. Quarkus DI is one of them.
The value of using a dependency injection mechanism is that we no longer need to worry about how and when to provide an object instance. A dependency injection solution enables us to automatically create and provide objects as dependencies in classes that declare a dependency in those objects, generally using annotation attributes.
In the context of the hexagonal architecture, the Framework and Application hexagons are good candidates to leverage the benefits a CDI solution can provide. Instead of using constructors...