What is the scope of an interceptor in CDI?
aka, is this legal? Would I get the same instance of this interceptor every place it's invoked?
@RequestScoped
public class SalesForceControllerInterceptor {
@Inject
private Logger log;
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
...
}
CDI 1.1 spec says that interceptors should be Dependent, otherwise, non portable behavior results. Weld 2.2.6, for instance, disallows interceptors with a scope other than Dependent and treats them as definition errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With