I created a custom annotation as below
@InterceptorBinding @Retention(RUNTIME) @Target(TYPE, METHOD) public @interface Traceable {}
I wrote an interceptor as shown below
@Traceable @Interceptor public class EnterExitLogger { @AroundInvoke public Object aroundInvoke(InvocatiobContext c) {} }
The interceptor and annotation are in a module called common-utils.
I annotated my target class with @Traceable at class level as below
@Traceable public class CDIManagedBean { }
I declared an interceptor entry in the beans.xml file as shown below
<interceptors> <class>my.package.EnterExitLogger</class> </interceptors>
The target class is in a separate module. beans.xml is located in the META-INF directory of the target class module.
The methods of the target class are called from the rest class. When I call methods, the AroundInvoke hook method is not called.
I read the documents and realized that the interceptor should contain a public argument constructor. I added. But still the interceptor was not called.
I added @ Mentioned custom annotation after reading documents. But still the interceptor was not called.
In the docs, I noticed that the interceptor implements the Serializable interface. Although not mentioned, I also implemented Serializable. Still not working.
Then I removed the user annotation from the interceptor, the beans.xml file and the target class. I also removed the public argument constructor from the interceptor and removed Serializable.
Then I annotated the target class @Interceptors(EnterExitLogger.class) and called the thread. My interceptor was called.
Can someone tell me how to do with InterceptorBinding?
PS
I am deploying my ear to a WAS 8.5 server.