[cdi-dev] Portable decorable Bean<T> instances

arjan tijms arjan.tijms at gmail.com
Tue Jul 10 07:45:12 EDT 2018


Hi,

Thanks for the reply. I already feared that to be the answer.

This would probably be a good enhancement request for CDI 2.1. At the very
least the BeanConfigurator could have a method like
BeanConfigurator#setDecorators<Decorator<?>... decorators. That's seemingly
doable to implement by the CDI implementations.

Kind regards,
Arjan





On Tue, Jul 10, 2018 at 11:04 AM Matej Novotny <manovotn at redhat.com> wrote:

> Hi,
>
> yes, there is no portable way.
> It is a similar situation as was with interceptors before
> InterceptionFactory was added.
>
> [impl 'details']
> In principle, to implement this, you need to create a "wrapper class"
> around the object which is to be intercepted/decorated.
> If you provide a custom way to create the bean, it is very difficult to
> create this wrapper on-the-fly.
> Even the solution for interceptors has some shortcomings and flaws and
> decorators seem even more complex (less restrictions on how does a
> decorator look like).
>
> Matej
>
> ----- Original Message -----
> > From: "arjan tijms" <arjan.tijms at gmail.com>
> > To: cdi-dev at lists.jboss.org
> > Sent: Tuesday, July 10, 2018 11:30:54 AM
> > Subject: [cdi-dev] Portable decorable Bean<T> instances
> >
> > Hi,
> >
> > When adding a manually constructed Bean<T> instance using
> > AfterBeanDiscovery.addBean(Bean<?>), or using the
> > AfterBeanDiscovery.addBean() method and the BeanConfigurator, the
> resulting
> > bean can't be decorated.
> >
> > This is because seemingly CDI expects the create() method of Bean<T> to
> > locate the decorators itself and apply them to the instance it returns.
> >
> > Using BeanManager.resolveDecorators one can obtain the Decorator<T>
> > instances, but am I right that there's no portable way to actually apply
> > those decorators to the bean instance?
> >
> > Kind regards,
> > Arjan
> >
> >
> >
> > _______________________________________________
> > cdi-dev mailing list
> > cdi-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/cdi-dev
> >
> > Note that for all code provided on this list, the provider licenses the
> code
> > under the Apache License, Version 2
> > (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
> > provided on this list, the provider waives all patent and other
> intellectual
> > property rights inherent in such information.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20180710/df6ec1f4/attachment.html 


More information about the cdi-dev mailing list