<p dir="ltr">I agree with you bit also the default should be smoother. Just trying to have side by side 2 confusing methods.</p>
<p dir="ltr">Like the AutoCloseable idea btw.<br>
</p>
<div class="gmail_quote">Le 16 mai 2016 11:20, &quot;Martin Kouba&quot; &lt;<a href="mailto:mkouba@redhat.com">mkouba@redhat.com</a>&gt; a écrit :<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dne 16.5.2016 v 11:08 Romain Manni-Bucau napsal(a):<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Le 16 mai 2016 10:42, &quot;Martin Kouba&quot; &lt;<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a><br>
&lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;&gt; a écrit :<br>
 &gt;<br>
 &gt;<br>
 &gt;<br>
 &gt; Dne 16.5.2016 v 10:36 Romain Manni-Bucau napsal(a):<br>
 &gt;<br>
 &gt;&gt; I see, thks.<br>
 &gt;&gt;<br>
 &gt;&gt; I dont like having 2 methods with the same semantic there but agree the<br>
 &gt;&gt; default is misleading for such cases.<br>
 &gt;&gt;<br>
 &gt;&gt; 1. Cant we change the default? looks like current one can break apps if<br>
 &gt;&gt; misunderstood and not sure changing it is worse.<br>
 &gt;<br>
 &gt;<br>
 &gt; I think we cannot due to backward compatibility.<br>
 &gt;<br>
 &gt;<br>
 &gt;&gt;<br>
 &gt;&gt; If not<br>
 &gt;&gt;<br>
 &gt;&gt; 2. Maybe we can type the returned type with a release method in the<br>
 &gt;&gt; instance  wrapper instead of enriching Instance API making it contextual<br>
 &gt;&gt; by nature?: w=instance...get();w.getValue().work();w.release(/*no<br>
param*/);<br>
 &gt;<br>
 &gt;<br>
 &gt; Sorry, I don&#39;t get it. Do you want to change Instance.get() signature<br>
and return some kind of wrapper? A simple snippet might help.<br>
 &gt;<br>
<br>
Yes get a method to have the wrapper to manage a single instance:<br>
<br>
@Inject Instance i;<br>
<br>
...<br>
<br>
Wrapper w = i.getSelected();<br>
...<br>
w.getValue().businessmetd();<br>
...<br>
w.release();<br>
</blockquote>
<br>
Well, we could introduce a new wrapper and even make is AutoCloseable, e.g. something like discussed here: <a href="http://lists.jboss.org/pipermail/cdi-dev/2016-May/008241.html" rel="noreferrer" target="_blank">http://lists.jboss.org/pipermail/cdi-dev/2016-May/008241.html</a><br>
<br>
But still you would have to distinguish between destroy() and release(). My original proposal was to allow a user to inspect the Bean metadata, see also <a href="https://issues.jboss.org/browse/CDI-515" rel="noreferrer" target="_blank">https://issues.jboss.org/browse/CDI-515</a>. But guys convinced me ;-)<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
 &gt;&gt;<br>
 &gt;&gt; That is what most framework did finally to integrate with CDI so looks<br>
 &gt;&gt; natural.<br>
 &gt;&gt;<br>
 &gt;&gt; Le 16 mai 2016 10:23, &quot;Martin Kouba&quot; &lt;<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a><br>
&lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;<br>
 &gt;&gt; &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a> &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;&gt;&gt; a écrit :<br>
 &gt;&gt;<br>
 &gt;&gt;     Dne 16.5.2016 v 10:20 Romain Manni-Bucau napsal(a):<br>
 &gt;&gt;<br>
 &gt;&gt;<br>
 &gt;&gt;         Le 16 mai 2016 10:01, &quot;Martin Kouba&quot; &lt;<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a><br>
&lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;<br>
 &gt;&gt;         &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a> &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;&gt;<br>
 &gt;&gt;         &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a> &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;<br>
&lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a> &lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;&gt;&gt;&gt; a écrit :<br>
 &gt;&gt;<br>
 &gt;&gt;           &gt;<br>
 &gt;&gt;           &gt; Dne 15.5.2016 v 16:14 John D. Ament napsal(a):<br>
 &gt;&gt;           &gt; &gt; Hey guys<br>
 &gt;&gt;           &gt; &gt;<br>
 &gt;&gt;           &gt; &gt; Seems like we have some issues in JIRA all focused on<br>
 &gt;&gt;         managing the<br>
 &gt;&gt;           &gt; &gt; lifecycle of Dependent scoped beans.  It also seems like<br>
 &gt;&gt;         we have many<br>
 &gt;&gt;           &gt; &gt; differing opinions about how to manage them.<br>
 &gt;&gt;           &gt; &gt;<br>
 &gt;&gt;           &gt; &gt; - Martin raised a PR to add a release() method to Instance<br>
 &gt;&gt;         to help<br>
 &gt;&gt;           &gt; &gt; destroy a dependent bean<br>
 &gt;&gt; <a href="https://github.com/cdi-spec/cdi/pull/286" rel="noreferrer" target="_blank">https://github.com/cdi-spec/cdi/pull/286</a><br>
 &gt;&gt;           &gt; &gt; - I raised a PR <a href="https://github.com/cdi-spec/cdi/pull/289" rel="noreferrer" target="_blank">https://github.com/cdi-spec/cdi/pull/289</a><br>
 &gt;&gt;         to update the<br>
 &gt;&gt;           &gt; &gt; spec to clarify how to manage a dependent scoped bean.<br>
 &gt;&gt;           &gt; &gt;<br>
 &gt;&gt;           &gt; &gt; Right now, it seems that the big disagreement is whether<br>
 &gt;&gt;           &gt; &gt; Instance.destroy() can destroy objects not created by it<br>
 &gt;&gt;         (the case<br>
 &gt;&gt;         being<br>
 &gt;&gt;           &gt; &gt; around the CDI utility class, being an impl of<br>
Instance).  I&#39;m<br>
 &gt;&gt;         currently<br>
 &gt;&gt;           &gt; &gt; heavily against Martin&#39;s proposed changes, but want to get<br>
 &gt;&gt;         input from<br>
 &gt;&gt;           &gt; &gt; others on the group to understand their perspective.<br>
 &gt;&gt;           &gt; &gt;<br>
 &gt;&gt;           &gt; &gt; - Does the spec require destroy() to be called only on<br>
 &gt;&gt;         instances<br>
 &gt;&gt;         that it<br>
 &gt;&gt;           &gt; &gt; created?  When I read 5.6.1 the only requirement I see is<br>
 &gt;&gt;         that it<br>
 &gt;&gt;         has to<br>
 &gt;&gt;           &gt; &gt; be a dependent scoped bean.  Note when I ask this I&#39;m<br>
 &gt;&gt;         asking from the<br>
 &gt;&gt;           &gt; &gt; spec perspective, its a different problem if there&#39;s some<br>
 &gt;&gt;         issues with<br>
 &gt;&gt;           &gt; &gt; implementations following suite (I would imagine there<br>
 &gt;&gt;         needs to be some<br>
 &gt;&gt;           &gt; &gt; shared global registry of dependent scoped beans for this<br>
 &gt;&gt;         to work).<br>
 &gt;&gt;           &gt; &gt;<br>
 &gt;&gt;           &gt; &gt; - Do we want two methods that effectively do the same<br>
 &gt;&gt;         thing?  I don&#39;t<br>
 &gt;&gt;           &gt; &gt; see a strong difference between the two.<br>
 &gt;&gt;           &gt;<br>
 &gt;&gt;           &gt; Instance.destroy() currently always destroys the contextual<br>
 &gt;&gt;         instance.<br>
 &gt;&gt;           &gt; Which is not always what users expect. That&#39;s why I proposed<br>
 &gt;&gt;         to add<br>
 &gt;&gt;           &gt; Instance.release() -<br>
<a href="https://github.com/cdi-spec/cdi/pull/286" rel="noreferrer" target="_blank">https://github.com/cdi-spec/cdi/pull/286</a>,<br>
 &gt;&gt;           &gt; previously Instance.getBean() -<br>
 &gt;&gt; <a href="https://github.com/cdi-spec/cdi/pull/273" rel="noreferrer" target="_blank">https://github.com/cdi-spec/cdi/pull/273</a>.<br>
 &gt;&gt;           &gt;<br>
 &gt;&gt;<br>
 &gt;&gt;         Since you give the instance to both I guess the intention<br>
from user<br>
 &gt;&gt;         point of view is obvious and then we dont need 2 methods. What<br>
 &gt;&gt;         would be<br>
 &gt;&gt;         the other use case?<br>
 &gt;&gt;<br>
 &gt;&gt;<br>
 &gt;&gt; <a href="https://github.com/cdi-spec/cdi/pull/273#issuecomment-179080614" rel="noreferrer" target="_blank">https://github.com/cdi-spec/cdi/pull/273#issuecomment-179080614</a><br>
 &gt;&gt;<br>
 &gt;&gt;<br>
 &gt;&gt;           &gt; &gt;<br>
 &gt;&gt;           &gt; &gt; On the flipside, my change is more a spec clarification.<br>
 &gt;&gt;         I&#39;m thinking<br>
 &gt;&gt;           &gt; &gt; more now that it belongs as a reword of 5.6.1 to clarify<br>
 &gt;&gt;         how to use<br>
 &gt;&gt;           &gt; &gt; destroy() on dependent beans, rather than where I put it.<br>
 &gt;&gt;         I think<br>
 &gt;&gt;           &gt; &gt; realistically we have all of the tools needed to<br>
manage the<br>
 &gt;&gt;         lifecycle of<br>
 &gt;&gt;           &gt; &gt; these classes, just need to clarify them for people to<br>
use.<br>
 &gt;&gt;           &gt; &gt;<br>
 &gt;&gt;           &gt; &gt; John<br>
 &gt;&gt;           &gt; &gt;<br>
 &gt;&gt;           &gt; &gt;<br>
 &gt;&gt;           &gt; &gt; _______________________________________________<br>
 &gt;&gt;           &gt; &gt; cdi-dev mailing list<br>
 &gt;&gt;           &gt; &gt; <a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
&lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt; &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
&lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt;&gt;<br>
 &gt;&gt;         &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
&lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt; &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
&lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt;&gt;&gt;<br>
 &gt;&gt;<br>
 &gt;&gt;           &gt; &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;&gt;           &gt; &gt;<br>
 &gt;&gt;           &gt; &gt; Note that for all code provided on this list, the provider<br>
 &gt;&gt;         licenses<br>
 &gt;&gt;         the code under the Apache License, Version 2<br>
 &gt;&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<br>
 &gt;&gt;         ideas<br>
 &gt;&gt;         provided on this list, the provider waives all patent and other<br>
 &gt;&gt;         intellectual property rights inherent in such information.<br>
 &gt;&gt;           &gt; &gt;<br>
 &gt;&gt;           &gt;<br>
 &gt;&gt;           &gt; --<br>
 &gt;&gt;           &gt; Martin Kouba<br>
 &gt;&gt;           &gt; Software Engineer<br>
 &gt;&gt;           &gt; Red Hat, Czech Republic<br>
 &gt;&gt;           &gt; _______________________________________________<br>
 &gt;&gt;           &gt; cdi-dev mailing list<br>
 &gt;&gt;           &gt; <a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt;<br>
&lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a> &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt;&gt;<br>
 &gt;&gt;         &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
&lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt; &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
&lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt;&gt;&gt;<br>
 &gt;&gt;<br>
 &gt;&gt;           &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;&gt;           &gt;<br>
 &gt;&gt;           &gt; Note that for all code provided on this list, the provider<br>
 &gt;&gt;         licenses<br>
 &gt;&gt;         the code under the Apache License, Version 2<br>
 &gt;&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<br>
 &gt;&gt;         ideas<br>
 &gt;&gt;         provided on this list, the provider waives all patent and other<br>
 &gt;&gt;         intellectual property rights inherent in such information.<br>
 &gt;&gt;<br>
 &gt;&gt;<br>
 &gt;&gt;     --<br>
 &gt;&gt;     Martin Kouba<br>
 &gt;&gt;     Software Engineer<br>
 &gt;&gt;     Red Hat, Czech Republic<br>
 &gt;&gt;<br>
 &gt;<br>
 &gt; --<br>
 &gt; Martin Kouba<br>
 &gt; Software Engineer<br>
 &gt; Red Hat, Czech Republic<br>
<br>
</blockquote>
<br>
-- <br>
Martin Kouba<br>
Software Engineer<br>
Red Hat, Czech Republic<br>
</blockquote></div>