<div dir="ltr"><div>From what we wrote about async events, ES can be submitted through the fireAsync call, following the patterns of CompletionStage. We can also submit a default ES while building a CDI container (a you wrote), and if we dont the default ES will probably be the default ForkJoinPool. </div><div><br></div>So we may have more than one ES, making things more complicated than the pattern you wrote. I think that having the user to close all the ESes will lead to the same pattern again and again : <div>for (ES es : cdi.getESes()) {</div><div>    myShutdown(es) ;</div><div>}</div><div><br></div><div>I&#39;d prefer to have a cdi.shutdown(), cdi.shudownNow() or cdi.awaitTermination(...) or whatever we call those methods, to encapsulate this code. Seems cleaner to me. It might look like CDI is becoming an ES itself, but it&#39;s delegation, not inheritance. </div><div><div><div><br></div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-12-18 9:28 GMT+01:00 Romain Manni-Bucau <span dir="ltr">&lt;<a href="mailto:rmannibucau@gmail.com" target="_blank">rmannibucau@gmail.com</a>&gt;</span>:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Why exposing them? When not simply exposing the executor service (in<br>
&quot;init&quot; method).<br>
<br>
CDIContainer cdi = CDIContainer.init(singletonMap(ExecutorService.class, myEs));<br>
// do something awesome<br>
shutdownAsIwant(myEs);<br>
cdi.close();<br>
<br>
Would avoid to have a lot of method several users will not care about.<br>
<br>
By default it would do a if (timeout &lt;= 0 ||<br>
!defaultEs.awaitTermination(timeout, MILLISECONDS)) { for (Runnable r<br>
: defaultEs.shutdownNow()) { try { r.cancel(); } catch(e) { log(e); }<br>
} } with timeout a property of the init map with a default in<br>
CDIContainer (constant)<br>
<br>
wdyt?<br>
<span class="im HOEnZb"><br>
<br>
Romain Manni-Bucau<br>
@rmannibucau<br>
<a href="http://www.tomitribe.com" target="_blank">http://www.tomitribe.com</a><br>
<a href="http://rmannibucau.wordpress.com" target="_blank">http://rmannibucau.wordpress.com</a><br>
<a href="https://github.com/rmannibucau" target="_blank">https://github.com/rmannibucau</a><br>
<br>
<br>
</span><div class="HOEnZb"><div class="h5">2014-12-18 9:19 GMT+01:00 José Paumard &lt;<a href="mailto:jose.paumard@gmail.com">jose.paumard@gmail.com</a>&gt;:<br>
&gt; I think we need to think more about how to close the Container.<br>
&gt;<br>
&gt; We need to take into account the fact that there wil be async process<br>
&gt; running in ExecutorServices (SE) or ManagedExecutorServices (EE). So the<br>
&gt; shutting down the container will mean shutting down these ES too.<br>
&gt;<br>
&gt; So I think we should need to carefully look at the way ES are closed. The<br>
&gt; question being : what do we do with async tasks that are still running :<br>
&gt; should we abruptely interrupt them ? give them a chance to complete ? All<br>
&gt; these are exposed in different methods of ES : shutdown(), shutdownNow() and<br>
&gt; awaitTermination(timeout). Since the container will have to call one of<br>
&gt; these methods per ES it will manage, I think we should also expose them.<br>
&gt;<br>
&gt; José<br>
&gt;<br>
&gt;<br>
&gt; 2014-12-18 9:14 GMT+01:00 Romain Manni-Bucau &lt;<a href="mailto:rmannibucau@gmail.com">rmannibucau@gmail.com</a>&gt;:<br>
&gt;&gt;<br>
&gt;&gt; ServiceLoader.load(&lt;api&gt;) = ServiceLoader.load(&lt;api&gt;, tccl)<br>
&gt;&gt;<br>
&gt;&gt; I was thinking to a plain servlet engine (tomcat to not say any name)<br>
&gt;&gt; and CDI container API to boot in webapps. Having cdi API in tomcat<br>
&gt;&gt; itself and CDI impl in webapps (Weld in webapp1, OWB in webapp2 for<br>
&gt;&gt; instance). This would mean using one webapp classloader to find the<br>
&gt;&gt; booter/container. This is fine excepted if the instance is cached.<br>
&gt;&gt;<br>
&gt;&gt; Same thought in more complicated about OSGi but I guess it is not yet<br>
&gt;&gt; the target.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Romain Manni-Bucau<br>
&gt;&gt; @rmannibucau<br>
&gt;&gt; <a href="http://www.tomitribe.com" target="_blank">http://www.tomitribe.com</a><br>
&gt;&gt; <a href="http://rmannibucau.wordpress.com" target="_blank">http://rmannibucau.wordpress.com</a><br>
&gt;&gt; <a href="https://github.com/rmannibucau" target="_blank">https://github.com/rmannibucau</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; 2014-12-18 8:58 GMT+01:00 Jozef Hartinger &lt;<a href="mailto:jharting@redhat.com">jharting@redhat.com</a>&gt;:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On 12/18/2014 08:48 AM, Romain Manni-Bucau wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Hi guys,<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; - why shutdown and not AutoClosable?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I like this idea.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; - about instance: it uses TCCL to load the impls, not sure it is<br>
&gt;&gt; &gt;&gt; intended but depending the deployment it can be an issue (is this api<br>
&gt;&gt; &gt;&gt; 100% JavaSE + flat classpath - ie more constrained than JavaSE?) +<br>
&gt;&gt; &gt;&gt; most of javax SPI creates a new instance each time &quot;creator&quot; is<br>
&gt;&gt; &gt;&gt; called.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I don&#39;t follow. Who uses TCCL?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; - Why Booter and not Container (better than factory IMO)? 1) for<br>
&gt;&gt; &gt;&gt; consistency with other spec, 2) why can I shutdown a booter ;)?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Exactly<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Romain Manni-Bucau<br>
&gt;&gt; &gt;&gt; @rmannibucau<br>
&gt;&gt; &gt;&gt; <a href="http://www.tomitribe.com" target="_blank">http://www.tomitribe.com</a><br>
&gt;&gt; &gt;&gt; <a href="http://rmannibucau.wordpress.com" target="_blank">http://rmannibucau.wordpress.com</a><br>
&gt;&gt; &gt;&gt; <a href="https://github.com/rmannibucau" target="_blank">https://github.com/rmannibucau</a><br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; 2014-12-18 8:37 GMT+01:00 Jozef Hartinger &lt;<a href="mailto:jharting@redhat.com">jharting@redhat.com</a>&gt;:<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; On 12/18/2014 04:33 AM, John D. Ament wrote:<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; I thought today&#39;s meeting was pretty good.  Based on one of the<br>
&gt;&gt; &gt;&gt;&gt; discussion<br>
&gt;&gt; &gt;&gt;&gt; points, I wanted to try putting together an interface that described<br>
&gt;&gt; &gt;&gt;&gt; the<br>
&gt;&gt; &gt;&gt;&gt; boot paradigm.  Unfortunately even in Java 8 it doesn&#39;t work too well,<br>
&gt;&gt; &gt;&gt;&gt; I<br>
&gt;&gt; &gt;&gt;&gt; cannot assign a static variable in an interface the way I can in an<br>
&gt;&gt; &gt;&gt;&gt; abstract<br>
&gt;&gt; &gt;&gt;&gt; class.  More importantly, it doesn&#39;t give us the private level<br>
&gt;&gt; &gt;&gt;&gt; expectation I<br>
&gt;&gt; &gt;&gt;&gt; would look for in this case.  I best I could come up with using an<br>
&gt;&gt; &gt;&gt;&gt; interface<br>
&gt;&gt; &gt;&gt;&gt; is:<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; public interface CDIBooter {<br>
&gt;&gt; &gt;&gt;&gt;      default BeanManager initialize() {<br>
&gt;&gt; &gt;&gt;&gt;          return initialize(new HashMap&lt;&gt;());<br>
&gt;&gt; &gt;&gt;&gt;      }<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;      BeanManager initialize(Map&lt;?,?&gt; properties);<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Why BeanManager? I think it would be better to return CDI or its<br>
&gt;&gt; &gt;&gt;&gt; subclass<br>
&gt;&gt; &gt;&gt;&gt; rather than this low-level SPI. With the CDI class we get more<br>
&gt;&gt; &gt;&gt;&gt; user-friendly<br>
&gt;&gt; &gt;&gt;&gt; Instance&lt;T&gt; for free. We could also expose Event&lt;T&gt; similarly.<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;      void shutdown();<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;      class BootHolder {<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;          static CDIBooter instance = null;<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;      }<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;      static CDIBooter instance() {<br>
&gt;&gt; &gt;&gt;&gt;          if(BootHolder.instance == null) {<br>
&gt;&gt; &gt;&gt;&gt;              ServiceLoader&lt;CDIBooter&gt; serviceLoader =<br>
&gt;&gt; &gt;&gt;&gt; ServiceLoader.load(CDIBooter.class);<br>
&gt;&gt; &gt;&gt;&gt;              for(CDIBooter booter : serviceLoader) {<br>
&gt;&gt; &gt;&gt;&gt;                  BootHolder.instance = booter;<br>
&gt;&gt; &gt;&gt;&gt;                  break;<br>
&gt;&gt; &gt;&gt;&gt;              }<br>
&gt;&gt; &gt;&gt;&gt;          }<br>
&gt;&gt; &gt;&gt;&gt;          return BootHolder.instance;<br>
&gt;&gt; &gt;&gt;&gt;      }<br>
&gt;&gt; &gt;&gt;&gt; }<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; where as the abstract class is a bit briefer, while also being<br>
&gt;&gt; &gt;&gt;&gt; private.<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; public abstract class CDIBooter {<br>
&gt;&gt; &gt;&gt;&gt;      public BeanManager initialize() {<br>
&gt;&gt; &gt;&gt;&gt;          return initialize(new HashMap&lt;&gt;());<br>
&gt;&gt; &gt;&gt;&gt;      }<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;      public abstract BeanManager initialize(Map&lt;?,?&gt; properties);<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;      public abstract void shutdown();<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;      private static CDIBooter instance = null;<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;      public static CDIBooter instance() {<br>
&gt;&gt; &gt;&gt;&gt;          if(instance == null) {<br>
&gt;&gt; &gt;&gt;&gt;              ServiceLoader&lt;CDIBooter&gt; serviceLoader =<br>
&gt;&gt; &gt;&gt;&gt; ServiceLoader.load(CDIBooter.class);<br>
&gt;&gt; &gt;&gt;&gt;              for(CDIBooter booter : serviceLoader) {<br>
&gt;&gt; &gt;&gt;&gt;                  instance = booter;<br>
&gt;&gt; &gt;&gt;&gt;                  break;<br>
&gt;&gt; &gt;&gt;&gt;              }<br>
&gt;&gt; &gt;&gt;&gt;          }<br>
&gt;&gt; &gt;&gt;&gt;          return instance;<br>
&gt;&gt; &gt;&gt;&gt;      }<br>
&gt;&gt; &gt;&gt;&gt; }<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Obviously ignore concurrency issues, etc.  It does look to be safer to<br>
&gt;&gt; &gt;&gt;&gt; do<br>
&gt;&gt; &gt;&gt;&gt; an<br>
&gt;&gt; &gt;&gt;&gt; abstract class, rather than a factory-interface.<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; John<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; On Wed Dec 17 2014 at 10:40:44 AM Antoine Sabot-Durand<br>
&gt;&gt; &gt;&gt;&gt; &lt;<a href="mailto:antoine@sabot-durand.net">antoine@sabot-durand.net</a>&gt; wrote:<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt; Hi all,<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt; I have business matter and will have to shorten the meeting tonight<br>
&gt;&gt; &gt;&gt;&gt;&gt; (half<br>
&gt;&gt; &gt;&gt;&gt;&gt; an hour instead of 1h).<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt; I updated the SE doc and Antonio added useful annexes :<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt; <a href="https://docs.google.com/document/d/1LgsGT-AAlrF72Z5pW4xNQiVjUHGUME46ZmB-wwF35Yw/edit?usp=sharing" target="_blank">https://docs.google.com/document/d/1LgsGT-AAlrF72Z5pW4xNQiVjUHGUME46ZmB-wwF35Yw/edit?usp=sharing</a><br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt; I propose we focus on this in these 30 mn<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt; regards,<br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt; Antoine<br>
&gt;&gt; &gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt; &gt;&gt;&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt; &gt;&gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;&gt; Note that for all code provided on this list, the provider licenses<br>
&gt;&gt; &gt;&gt;&gt;&gt; the<br>
&gt;&gt; &gt;&gt;&gt;&gt; code under the Apache License, Version 2<br>
&gt;&gt; &gt;&gt;&gt;&gt; (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other<br>
&gt;&gt; &gt;&gt;&gt;&gt; ideas<br>
&gt;&gt; &gt;&gt;&gt;&gt; provided on this list, the provider waives all patent and other<br>
&gt;&gt; &gt;&gt;&gt;&gt; intellectual<br>
&gt;&gt; &gt;&gt;&gt;&gt; property rights inherent in such information.<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt; &gt;&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Note that for all code provided on this list, the provider licenses<br>
&gt;&gt; &gt;&gt;&gt; the<br>
&gt;&gt; &gt;&gt;&gt; code<br>
&gt;&gt; &gt;&gt;&gt; under the Apache License, Version 2<br>
&gt;&gt; &gt;&gt;&gt; (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas<br>
&gt;&gt; &gt;&gt;&gt; provided on this list, the provider waives all patent and other<br>
&gt;&gt; &gt;&gt;&gt; intellectual<br>
&gt;&gt; &gt;&gt;&gt; property rights inherent in such information.<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; _______________________________________________<br>
&gt;&gt; &gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt; &gt;&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt; &gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt; &gt;&gt;&gt;<br>
&gt;&gt; &gt;&gt;&gt; Note that for all code provided on this list, the provider licenses<br>
&gt;&gt; &gt;&gt;&gt; the<br>
&gt;&gt; &gt;&gt;&gt; code<br>
&gt;&gt; &gt;&gt;&gt; under the Apache License, Version 2<br>
&gt;&gt; &gt;&gt;&gt; (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas<br>
&gt;&gt; &gt;&gt;&gt; provided on this list, the provider waives all patent and other<br>
&gt;&gt; &gt;&gt;&gt; intellectual<br>
&gt;&gt; &gt;&gt;&gt; property rights inherent in such information.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; cdi-dev mailing list<br>
&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" 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 licenses the<br>
&gt;&gt; code under the Apache License, Version 2<br>
&gt;&gt; (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas<br>
&gt;&gt; provided on this list, the provider waives all patent and other intellectual<br>
&gt;&gt; property rights inherent in such information.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Java le soir Cours Java en ligne<br>
&gt; Twitter Paris JUG Devoxx France<br>
&gt; M : <a href="tel:%2B33%206%2076%2082%2091%2047" value="+33676829147">+33 6 76 82 91 47</a><br>
</div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div><a href="http://blog.paumard.org" target="_blank">Java le soir</a> <a href="http://blog.paumard.org/cours-tutoriaux/" target="_blank">Cours Java en ligne</a></div><div><a href="http://twitter.com/#!/JosePaumard" target="_blank">Twitter</a> <a href="http://www.parisjug.org" target="_blank">Paris JUG</a> <a href="http://www.devoxx.fr" target="_blank">Devoxx France</a></div><div>M : +33 6 76 82 91 47</div></div>
</div>