[英]Annotation-based interceptors on EJBs
是否可以像在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 "";
}
}
是的,有可能。 您可以像對待其他CDI bean一樣對待EJB。 您需要激活beans.xml中的攔截器或添加@Interceptor綁定。 有關更多信息,請參見焊接文檔https://docs.jboss.org/weld/reference/1.0.0/en-US/html/interceptors.html
從src或上述文檔鏈接中可以看到,標准EJB注釋也是如此實現的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.