CDI Tutorial – Introduction to Contexts and Dependency Injection

Dependency Injection (DI) is one of the central techniques in today’s applications and targets Separation of concerns. Not only makes this testing easier, but you are also not in charge to know how to construct the instance of a requested class. With Java/Jakarta EE we have a specification which (besides other topics) covers this: Contexts

Read More

Pro CDI 2 in Java EE 8 Book Review

When it comes to creating an application with Java (now Jakarta) EE, the first specification you usually get in touch with is CDI (Contexts and Dependency Injection). Starting with this specification, you’ll probably know it for its dependency injection (DI) capabilities: @Inject. Even besides DI, the CDI spec offers a lot more: events, decorators, interceptors,

Read More

Intercept method calls using CDI interceptors

If you have cross-cutting concerns for several parts of your application you usually don’t want to copy and paste the code. For Java EE applications the CDI (Context and Dependency Injection) spec contains the concept of interceptors which are defined in the Java Interceptor specification. With these CDI interceptors, you can intercept business method, timeouts

Read More