@Named
@ConversationScoped
@Interceptors(MyInterceptor.class)
public class BeanWeb implements Serializable {
public String methodThrowException throws Exception() {
throws new Exception();
}
}
public class MyInterceptor {
@AroundInvoke
public Object intercept(InvocationContext ic) throws Exception {
try {
return ic.proceed();
} catch (Exception e) {
return null;
}
}
}
对于 @Stateless bean拦截器工作,但对于 BeanWeb 拦截器不起作用。我们从未进入“拦截”方法。
P.S。:在Glassfish 3.x下的所有旋转。
答案 0 :(得分:0)
这是工作:
@Named
@Stateful
@ConversationScoped
@Interceptors(MyInterceptor.class)
public class BeanWeb implements Serializable {
public String methodThrowException throws Exception() {
throws new Exception();
}
}
public class MyInterceptor implements Serializable {
@AroundInvoke
public Object intercept(InvocationContext ic) throws Exception {
try {
return ic.proceed();
} catch (Exception e) {
return null;
}
}
}
我希望这是正确的。