[cdi-dev] Enabling programmatic/synthetic decorators added by extension

arjan tijms arjan.tijms at gmail.com
Wed Mar 2 10:31:56 EST 2016


Hi,

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));

afterBeanDiscovery.addBean(bean);

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20160302/5d9e4b83/attachment.html 


More information about the cdi-dev mailing list