CDI Interceptor functionality is defined in the Java Interceptors specification.

The Interceptors specification defines three kinds of interception points:

  • business method interception,
  • lifecycle callback interception, and
  • timeout method interception (EJB only).

We will explore the basics of using interceptors in CDI. A simple interceptor will be created that initializes a cutomer’s account with 10 USD.

In the above snippet we create the @InterceptorBinding which can be applied to a TYPE or a METHOD.

Next is to create the actual Interceptor class with a binding to the AccountOpeningInterceptor.

Then we apply the Interceptor to the method call that requires interception.

On that note and until the next post; keep doing cool things :smile:.