I created a custom annotation like below
@InterceptorBinding
@Retention(RUNTIME)
@Target(TYPE, METHOD)
public @interface Traceable {}
I wrote an interceptor like below
@Traceable
@Interceptor
public class EnterExitLogger {
@AroundInvoke
public Object aroundInvoke(InvocatiobContext c) {}
}
The interceptor and the annotation are in a module called common-utils.
I annotated a my target class with @Traceable at class level like below
@Traceable
public class CDIManagedBean {
}
I declared the interceptor entry in my beans.xml file like below
<interceptors>
<class>my.package.EnterExitLogger</class>
</interceptors>
The target class is in a separate module. beans.xml is in META-INF directory of the target class's module.
The target class's methods are called from a rest class. When I invoke the methods the interceptor's AroundInvoke method is not called.
I read the docs and understood that the interceptor should contain a public no argument constructor. I added it. But still the interceptor was not called.
I added @Inherited on the custom annotation after reading the docs. But still the interceptor was not called.
From the docs I noticed the interceptor implementing Serializable interface. Although not mentioned I implemented Serializable also. Still did not work.
Then I removed the custom annotation from the interceptor, beans.xml file and the target class. I also removed the public no argument constructor from the interceptor and removed Serializable.
Then I annotated the target class with @Interceptors(EnterExitLogger.class)
and invoked the flow. My interceptor was called.
Can anyone tell me how do I do with an InterceptorBinding?
P.S.
I am deploying my ear in WAS 8.5 server.