0
是否可以使用拦截器绑定能力的注释在EJB上声明拦截器,就像我们在CDI bean上做的那样?EJB上的基于注释的拦截器
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@InterceptorBinding
public @interface MyInterceptor {
}
@Stateless
@Remote(MyService.class)
public MyServiceImpl implements MyService {
@Override
@MyInterceptor
public String myBusinessMethod() {
return "";
}
}
不仅是可能的,而且也是推荐的做法。什么阻止你简单地尝试它? – Siliarus
我不知道为什么,但它似乎不能在JBoss 7.0上工作。我仍在调查。当@Interceptors(MyInterceptor.class)发现它很丑陋。 –
现在正在工作,添加'@ Priority'后,谢谢。 –