CDI 中拦截器的范围是什么?
aka,这合法吗?我会在每个调用拦截器的地方获得相同的拦截器实例吗?
@RequestScoped
public class SalesForceControllerInterceptor {
@Inject
private Logger log;
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
...
}
最佳答案
CDI 1.1 spec说拦截器应该是依赖的,否则,将导致不可移植的行为。例如,Weld 2.2.6 不允许拦截器的范围不是 Dependent,并将它们视为定义错误。
关于Java CDI : Do interceptors have scope?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24842538/