[cdi-dev] Portable decorable Bean<T> instances
Matej Novotny
manovotn at redhat.com
Tue Jul 10 06:04:43 EDT 2018
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.
More information about the cdi-dev
mailing list