<div dir="ltr">Hi,<div><br></div><div>Thanks for the reply. I already feared that to be the answer.</div><div><br></div><div>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&lt;Decorator&lt;?&gt;... decorators. That&#39;s seemingly doable to implement by the CDI implementations.</div><div><br></div><div>Kind regards,</div><div>Arjan</div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jul 10, 2018 at 11:04 AM Matej Novotny &lt;<a href="mailto:manovotn@redhat.com">manovotn@redhat.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
yes, there is no portable way.<br>
It is a similar situation as was with interceptors before InterceptionFactory was added.<br>
<br>
[impl &#39;details&#39;]<br>
In principle, to implement this, you need to create a &quot;wrapper class&quot; around the object which is to be intercepted/decorated.<br>
If you provide a custom way to create the bean, it is very difficult to create this wrapper on-the-fly.<br>
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).<br>
<br>
Matej<br>
<br>
----- Original Message -----<br>
&gt; From: &quot;arjan tijms&quot; &lt;<a href="mailto:arjan.tijms@gmail.com" target="_blank">arjan.tijms@gmail.com</a>&gt;<br>
&gt; To: <a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
&gt; Sent: Tuesday, July 10, 2018 11:30:54 AM<br>
&gt; Subject: [cdi-dev] Portable decorable Bean&lt;T&gt; instances<br>
&gt; <br>
&gt; Hi,<br>
&gt; <br>
&gt; When adding a manually constructed Bean&lt;T&gt; instance using<br>
&gt; AfterBeanDiscovery.addBean(Bean&lt;?&gt;), or using the<br>
&gt; AfterBeanDiscovery.addBean() method and the BeanConfigurator, the resulting<br>
&gt; bean can&#39;t be decorated.<br>
&gt; <br>
&gt; This is because seemingly CDI expects the create() method of Bean&lt;T&gt; to<br>
&gt; locate the decorators itself and apply them to the instance it returns.<br>
&gt; <br>
&gt; Using BeanManager.resolveDecorators one can obtain the Decorator&lt;T&gt;<br>
&gt; instances, but am I right that there&#39;s no portable way to actually apply<br>
&gt; those decorators to the bean instance?<br>
&gt; <br>
&gt; Kind regards,<br>
&gt; Arjan<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; _______________________________________________<br>
&gt; cdi-dev mailing list<br>
&gt; <a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt; <br>
&gt; Note that for all code provided on this list, the provider licenses the code<br>
&gt; under the Apache License, Version 2<br>
&gt; (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas<br>
&gt; provided on this list, the provider waives all patent and other intellectual<br>
&gt; property rights inherent in such information.<br>
</blockquote></div>