<div dir="ltr"><div class="gmail_extra"><div><div class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div></div></div></div></div></div><div class="gmail_quote">2016-02-12 18:18 GMT+01:00 Mark Struberg <span dir="ltr">&lt;<a href="mailto:struberg@yahoo.de" target="_blank">struberg@yahoo.de</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think that would need a multi-pass ‚coercion‘ like it’s done in the jvm.<br></blockquote><div><br></div><div>Nop cause of the constraint I associated to @generic</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Currently it’s a getBeans(type) (+ resolve).<br>
And after that only a single candidate must be left.<br>
<br>
To support your desired case we would need to do a ’nearest’ search means if you have the following producers<br>
<br>
@Produces List&lt;String&gt; ..<br>
@Produces List&lt;?&gt; ..<br>
@Produces Object ..<br>
<br></blockquote><div><br></div><div>This would fail at deploy time if they all have @generic, if not then the @Generic producer is just ignored and overriden with the rules with have today if it matches (see @Generic as a fallback if nothing matched but the qualifier).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
@Inject List&lt;String&gt; x; // first producer would be taken<br>
@Inject List&lt;Integer&gt; x; // second producer would be taken<br>
@Inject BlaBla x; // third producer would be taken;<br>
<br>
We’ve discussed similar things back then in CDI-304 I think.<br>
<br>
Of course that would only work if the producer has a chance to inspect the injection point. Means those producers would need to be @Dependent I guess?<br>
<br></blockquote><div><br></div><div>Yep</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Do we go down this route? Or is this an overkill? No idea yet… Might be very powerful but maybe also very fragile?<br>
<br>
LieGrue,<br>
strub<br>
<div><div class="h5"><br>
<br>
&gt; Am 12.02.2016 um 17:56 schrieb Romain Manni-Bucau &lt;<a href="mailto:rmannibucau@gmail.com">rmannibucau@gmail.com</a>&gt;:<br>
&gt;<br>
&gt; Hi guys,<br>
&gt;<br>
&gt; could CDI 2 do step forward for generic producers?<br>
&gt;<br>
&gt; The need is to produce any type (with a particular qualifier) without the need of an extension:<br>
&gt;<br>
&gt; @Produces<br>
&gt; @MyQualifier<br>
&gt; Object create(InjectionPoint ip) { ... }<br>
&gt;<br>
&gt; This is actually a common pattern (for configuration, or to integrate with 3rd party libs) and today the only hope to do so is to write an extension which is a bit technical and verbose for the result IMO.<br>
&gt;<br>
&gt; I guess for compatibility reason we would need to do something like:<br>
&gt;<br>
&gt; @Produces<br>
&gt; @MyQualifier<br>
&gt; @Generic<br>
&gt; Object create(InjectionPoint ip) { ... }<br>
&gt;<br>
&gt; and say that if there is a unique resolved bean thanks to qualifiers which is annotated @Generic then use this producer.<br>
&gt;<br>
&gt; wdyt?<br>
&gt;<br>
&gt; Romain Manni-Bucau<br>
&gt; @rmannibucau |  Blog | Github | LinkedIn | Tomitriber<br>
</div></div>&gt; _______________________________________________<br>
&gt; cdi-dev mailing list<br>
&gt; <a href="mailto:cdi-dev@lists.jboss.org">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 under the Apache License, Version 2 (<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 provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.<br>
<br>
</blockquote></div><br></div></div>