I'm trying to add decorators and/or interceptors to a Bean<T> that's added via an extension. There doesn't seem to be any way to add interceptors, but decorators seem almost possible.

I've added a decorator in the following way:

AnnotatedType<AutoApplySessionDecorator> annotatedType = beanManager.createAnnotatedType(AutoApplySessionDecorator.class);
BeanAttributes<AutoApplySessionDecorator> beanAttributes = beanManager.createBeanAttributes(annotatedType);
Bean<AutoApplySessionDecorator> bean = beanManager.createBean(beanAttributes, AutoApplySessionDecorator.class, beanManager.getInjectionTargetFactory(annotatedType));

Where the "AutoApplySessionDecorator" is an existing (non-scanned) decorator just used as an example.

While this seems to work, the problem is with the enablement. @Priority is not processed in this way, since it's only read from an AnnotatedType that's been added to the deployment (see e.g. in Weld org.jboss.weld.bootstrap.BeanDeployer.processPriority(AnnotatedType<?>)).

beans.xml is not really an option here due to the static nature of that and the fact that the decorator needs to be enabled dynamically here, plus that the implementation class of the decorator is a detail I would not like to expose to the application.

Is there any other way to either enable a (synthetic) decorator programmatically, or to add Interceptors to a programmatically added Bean<T>?

Kind regards,
Arjan Tijms