我们可以在不同的ejb-jar中的ejb-jar中使用基于注解的拦截器吗? 我使用@Logged示例尝试了它,但用它进行了删除。有人可以帮我吗?CDI - 使用库中的拦截器类
在core.jar添加:
@Inherited
@InterceptorBinding
@Retention(RUNTIME)
@Target({METHOD, TYPE})
public @interface Logged {}
和
@Logged
@Interceptor
public class LoggedInterceptor implements Serializable {
private static final long serialVersionUID = 1L;
public LoggedInterceptor() {
}
@AroundInvoke
public Object logMethodEntry(InvocationContext invocationContext)
throws Exception {
System.out.println("Entering method: "
+ invocationContext.getMethod().getName() + " in class "
+ invocationContext.getMethod().getDeclaringClass().getName());
return invocationContext.proceed();
}
}
的问题是:如何使用从另一个EJB-JAR这个拦截器(企业应用程序中)?例如:伐木业务方法调用,其中的方法可以在不同的模块中找到:
module1.jar:
public class ModuleClass{
@Logged public void doSomething(){...}
}
我试图把<拦截> <类.....豆类.xml,但它不适合我。
感谢您的任何建议!
感谢您的帮助,但我在Glassfish的JIRA上发现,这是一个“功能”,只会在v4(v3.2被跳过)中修复。 http://java.net/jira/browse/GLASSFISH-15119 – user1451106
感谢您发布此更新 –