Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java CDI: Do interceptors have scope?

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 {
...
    }
like image 206
Jonathan S. Fisher Avatar asked Jul 19 '14 16:07

Jonathan S. Fisher


1 Answers

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.

like image 125
jpangamarca Avatar answered Sep 28 '22 01:09

jpangamarca