Por que o interceptor não é chamado na mesma classe de serviço?
Eu quero usar interceptores em um aplicativo Java-SE e estou usando solda como implementação de CDI e estou testando isso aqui:
A classe principal:
public static void main(String[] args) {
WeldContainer weldContainer = new Weld().initialize();
Service service = weldContainer.instance().select(Service.class).get();
service.methodCall();
service.methodCallNumberTwo();
}
A classe de serviço:
public class Service {
@TestAnnotation
public void methodCall(){
System.out.println("methodCall...!");
methodCallNumberTwo();
}
@TestAnnotation
public void methodCallNumberTwo(){
System.out.println("methodCallNumberTwo...!");
}
}
A classe do interceptor:
@Interceptor
@TestAnnotation
public class TestInterceptor {
@AroundInvoke
public Object interceptorMethod(InvocationContext invocationContext) throws Exception {
System.out.println("I'm the TestInterceptor of "+invocationContext.getMethod());
return invocationContext.proceed();
}
}
Aaa e a saída:
I'm the TestInterceptor of public void Service.methodCall()
methodCall...!
methodCallNumberTwo...!
I'm the TestInterceptor of public void Service.methodCallNumberTwo()
methodCallNumberTwo...!
Minhas perguntas
Primeiro: Por que o interceptor não é chamado em methodCall () quando estou chamando methodCallNumberTwo ()?
Segundo: Existe uma maneira de mudar isso?
Estou apenas estudando o comportamento dos interceptadores e quero entender. Agradeço antecipadamente!