如果 ArroundInvoke 方法是从另一个 ejb 方法调用的,它是否会被调用?
我有以下情况:
@Interceptors(MyInterceptClass.class)
public void ejbMethod1()
{
}
@Interceptors(MyInterceptClass.class)
public void ejbMethod2()
{
ejbMethod1();
}
调用 ejbMethod2 是否会导致执行两个拦截器调用?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您的意思是
@Interceptors
(复数)注释,它定义了将在带注释的方法调用时调用的拦截器类。@Interceptor
注解(单数)用于注解一个拦截器类。如果是这样,那么简短的回答是:否。
拦截器由容器执行。如果您的方法调用不会通过容器,那么它不会被拦截。
因此,以下对
ejbMethod1()
: 的调用不会激活
MyInterceptClass
,因为它是本地调用(非 EJB 调用)。如果您想再次调用拦截器,则应该使用业务接口,例如:
这将进行 EJB 感知调用,并在调用
ejbMethod1()
时命中拦截器。I'll assume you mean
@Interceptors
(plural) annotation which defines the interceptor class which will be invoked upon annotated method invocation.@Interceptor
annotation (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
MyInterceptClass
as 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()
.