<div dir="ltr"><br>Martin,<div><br></div><div><br><div class="gmail_quote"><div dir="ltr">On Mon, May 16, 2016 at 3:54 AM Martin Kouba &lt;<a href="mailto:mkouba@redhat.com">mkouba@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">Dne 15.5.2016 v 17:14 John D. Ament napsal(a):<br>
&gt; Romain,<br>
&gt;<br>
&gt; On Sun, May 15, 2016 at 11:05 AM Romain Manni-Bucau<br>
&gt; &lt;<a href="mailto:rmannibucau@gmail.com" target="_blank">rmannibucau@gmail.com</a> &lt;mailto:<a href="mailto:rmannibucau@gmail.com" target="_blank">rmannibucau@gmail.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     Hi Jon<br>
&gt;<br>
&gt;     Le 15 mai 2016 16:15, &quot;John D. Ament&quot; &lt;<a href="mailto:john.d.ament@gmail.com" target="_blank">john.d.ament@gmail.com</a><br>
&gt;     &lt;mailto:<a href="mailto:john.d.ament@gmail.com" target="_blank">john.d.ament@gmail.com</a>&gt;&gt; a écrit :<br>
&gt;      &gt;<br>
&gt;      &gt; Hey guys<br>
&gt;      &gt;<br>
&gt;      &gt; Seems like we have some issues in JIRA all focused on managing<br>
&gt;     the lifecycle of Dependent scoped beans.  It also seems like we have<br>
&gt;     many differing opinions about how to manage them.<br>
&gt;      &gt;<br>
&gt;      &gt; - Martin raised a PR to add a release() method to Instance to<br>
&gt;     help destroy a dependent bean <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; - 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> to<br>
&gt;     update the spec to clarify how to manage a dependent scoped bean.<br>
&gt;      &gt;<br>
&gt;      &gt; Right now, it seems that the big disagreement is whether<br>
&gt;     Instance.destroy() can destroy objects not created by it (the case<br>
&gt;     being around the CDI utility class, being an impl of Instance).  I&#39;m<br>
&gt;     currently heavily against Martin&#39;s proposed changes, but want to get<br>
&gt;     input from others on the group to understand their perspective.<br>
&gt;      &gt;<br>
&gt;      &gt; - Does the spec require destroy() to be called only on instances<br>
&gt;     that it created?  When I read 5.6.1 the only requirement I see is<br>
&gt;     that it has to be a dependent scoped bean.  Note when I ask this I&#39;m<br>
&gt;     asking from the spec perspective, its a different problem if there&#39;s<br>
&gt;     some issues with implementations following suite (I would imagine<br>
&gt;     there needs to be some shared global registry of dependent scoped<br>
&gt;     beans for this to work).<br>
&gt;      &gt;<br>
&gt;<br>
&gt;     Sound the only clean impl. Any other is not symmetric and<br>
&gt;     potentially lead to &quot;oops this time it didnt work&quot;. I also not<br>
&gt;     seeing any use case limitation with that so think it is the same<br>
&gt;     solution<br>
&gt;<br>
&gt;<br>
&gt; I&#39;m not sure I follow or if this isn&#39;t an answer to &quot;Does the spec<br>
&gt; require destroy() to be called only on instances that it created?&quot; ?<br>
&gt;<br>
&gt; Anyways I did look a bit closer and it seems that Martin&#39;s statement is<br>
&gt; consistent with how OWB works,<br>
&gt; <a href="https://github.com/apache/openwebbeans/blob/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java#L293" rel="noreferrer" target="_blank">https://github.com/apache/openwebbeans/blob/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java#L293</a> so<br>
&gt; I wonder if there&#39;s a part of the spec I&#39;m missing, or if there was some<br>
&gt; offline agreement on how to understand it.<br>
<br>
John, I believe Instance CANNOT be used to destroy a dependent bean<br>
instance it didn&#39;t created, because a dependent bean instance doesn&#39;t<br>
know the dependent objects it depends on - that&#39;s what CreationalContext<br>
is for.<br>
<br></blockquote><div><br></div><div>This is the area I&#39;m looking for clarification around.  Where in the spec is this mandated?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So if you pass any dependent instance to Instance.destroy() there is no<br>
CreationalContext apart from the one Instance&lt;&gt; has. In other words you<br>
wouldn&#39;t be able to destroy the @Dependent dependencies of a @Dependent<br>
bean instane. Does it make sense?<br>
<br>
See also <a href="https://issues.jboss.org/browse/CDI-519" rel="noreferrer" target="_blank">https://issues.jboss.org/browse/CDI-519</a> (cdi-spec/cdi/pull/278<br>
is already merged).<br>
<br>
<br>
&gt;<br>
&gt; John<br>
&gt;<br>
&gt;      &gt; - Do we want two methods that effectively do the same thing?  I<br>
&gt;     don&#39;t see a strong difference between the two.<br>
&gt;      &gt;<br>
&gt;      &gt; On the flipside, my change is more a spec clarification.  I&#39;m<br>
&gt;     thinking more now that it belongs as a reword of 5.6.1 to clarify<br>
&gt;     how to use destroy() on dependent beans, rather than where I put<br>
&gt;     it.  I think realistically we have all of the tools needed to manage<br>
&gt;     the lifecycle of these classes, just need to clarify them for people<br>
&gt;     to use.<br>
&gt;      &gt;<br>
&gt;      &gt; John<br>
&gt;      &gt;<br>
&gt;<br>
&gt;      &gt; _______________________________________________<br>
&gt;      &gt; cdi-dev mailing list<br>
&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>
&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;<br>
&gt;      &gt; Note that for all code provided on this list, the provider<br>
&gt;     licenses the code 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<br>
&gt;     ideas provided on this list, the provider waives all patent and<br>
&gt;     other intellectual property rights inherent in such information.<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 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>
&gt;<br>
<br>
--<br>
Martin Kouba<br>
Software Engineer<br>
Red Hat, Czech Republic<br>
</blockquote></div></div></div>