I’ve the following case:
@Interceptors(MyInterceptClass.class)
public void ejbMethod1()
{
}
@Interceptors(MyInterceptClass.class)
public void ejbMethod2()
{
ejbMethod1();
}
Is calling ejbMethod2 causes TWO interceptor calls to be executed?
Thanks.
I’ll assume you mean
@Interceptors(plural) annotation which defines the interceptor class which will be invoked upon annotated method invocation.@Interceptorannotation (singular) is for annotating a class which is an interceptor.If so, then short answer is: no.
The interceptor is executed by the container. If your method invocation will not go through the container, then it will not be intercepted.
Therefore the following call to
ejbMethod1():won’t activate the
MyInterceptClassas it’s the local call (non-EJB one).If you’d like to call the interceptor once again, you should use business interface, so something like:
This will make the EJB-aware call and will hit the interceptor while invoking
ejbMethod1().