Search code examples
jakarta-eecdiweld

Register CDI interceptor without using beans.xml


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


Solution

  • There is no way to enable an interceptor globally in CDI 1.0 (Weld 1.x), as far as I know.