Is it possible to inherit interceptors from a super class?

Solution Verified - Updated -

Issue

  • Are interceptors annotated with @Interceptors(MyInterceptor.class) inherited?
  • What is the difference between @Interceptors and @Interceptor | @InterceptorBinding for CDI?
  • Classes structured like followed does not invoke the annotated Interceptors as expected, here an example. If TestCase doGet is invoked it is expected all interceptors are used but only 2 is.
@Path("TestCase")
@Interceptors({ DemoInterceptor2.class })
public class TestCase extends SuperTestCase {}

@Interceptors({ DemoInterceptor1.class})
public abstract class SuperTestCase {
  @GET
  @Produces("text/plain")
  public Object doGet() {
    // do something
  }
}

public class DemoInterceptor# {
  @AroundInvoke
  private Object intercept(final InvocationContext ic) throws Exception {
    // do something
    return ic.proceed();
  }
}
  • I have an interceptor with binding but the application is not invoking it, what is the reason for it?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
  • Context & Dependency Injection (CDI)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content