I am searching for a way to load a given interceptor programmatically.
I've seen a way to dynamically set an interceptor binding for a given bean, but the interceptor for that binding must be defined in the beans.xml. I know I can use the @Interceptors
annotation but that way I am tied to a specific implementation.
Is there a way to load an interceptor (probably through a CDI extension)?
Or a way to make interceptors enabled by default without the need to declare the <interceptors></interceptors>
?
I am using Weld-1.1.24
For anyone coming here via a search, like I did, and not being limited to CDI 1.0:
You can add an @Priority() annotation to your interceptor so you don't have to to add it to the beans.xml
@MyAnnotation @Interceptor @Priority(Interceptor.Priority.LIBRARY_BEFORE)
public class MyAnnotationInterceptor{...}
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