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 of providing object instances to an external dependency and managing their life cycle across an application. Several dependency injection solutions on 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 depend on those objects, generally using annotation attributes.
In the context of hexagonal architecture, the Framework and Application hexagons are good candidates to leverage the benefits a CDI solution can provide. Instead of using constructors that inject dependencies...