Почему перехватчик не вызывается в одном классе обслуживания?
Я хочу использовать перехватчики в приложении Java-SE, и я использую сварку как реализацию CDI, и я проверяю это здесь:
Основной класс:
public static void main(String[] args) {
WeldContainer weldContainer = new Weld().initialize();
Service service = weldContainer.instance().select(Service.class).get();
service.methodCall();
service.methodCallNumberTwo();
}
Сервис-класс:
public class Service {
@TestAnnotation
public void methodCall(){
System.out.println("methodCall...!");
methodCallNumberTwo();
}
@TestAnnotation
public void methodCallNumberTwo(){
System.out.println("methodCallNumberTwo...!");
}
}
Класс перехватчика:
@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();
}
}
Аааа и вывод:
I'm the TestInterceptor of public void Service.methodCall()
methodCall...!
methodCallNumberTwo...!
I'm the TestInterceptor of public void Service.methodCallNumberTwo()
methodCallNumberTwo...!
Мои вопросы
Первое: почему перехватчик не вызывается в methodCall (), когда я вызываю methodCallNumberTwo ()?
Второе: есть ли способ изменить это?
Я только изучаю поведение перехватчиков и хочу понять. Заранее спасибо!