I thought today's meeting was pretty good. Based on one of the discussion points, I wanted to try putting together an interface that described the boot paradigm. Unfortunately even in Java 8 it doesn't work too well, I cannot assign a static variable in an interface the way I can in an abstract class. More importantly, it doesn't give us the private level expectation I would look for in this case. I best I could come up with using an interface is:<br><div><br></div><div><div>public interface CDIBooter {</div><div> default BeanManager initialize() {</div><div> return initialize(new HashMap<>());</div><div> }</div><div><br></div><div> BeanManager initialize(Map<?,?> properties);</div><div><br></div><div> void shutdown();</div><div><br></div><div> class BootHolder {</div><div><br></div><div> static CDIBooter instance = null;</div><div><br></div><div> }</div><div><br></div><div> static CDIBooter instance() {</div><div> if(BootHolder.instance == null) {</div><div> ServiceLoader<CDIBooter> serviceLoader = ServiceLoader.load(CDIBooter.class);</div><div> for(CDIBooter booter : serviceLoader) {</div><div> BootHolder.instance = booter;</div><div> break;</div><div> }</div><div> }</div><div> return BootHolder.instance;</div><div> }</div><div>}</div></div><div><br></div><div>where as the abstract class is a bit briefer, while also being private.</div><div><br></div><div><div>public abstract class CDIBooter {</div><div> public BeanManager initialize() {</div><div> return initialize(new HashMap<>());</div><div> }</div><div><br></div><div> public abstract BeanManager initialize(Map<?,?> properties);</div><div><br></div><div> public abstract void shutdown();</div><div><br></div><div> private static CDIBooter instance = null;</div><div> </div><div> public static CDIBooter instance() {</div><div> if(instance == null) {</div><div> ServiceLoader<CDIBooter> serviceLoader = ServiceLoader.load(CDIBooter.class);</div><div> for(CDIBooter booter : serviceLoader) {</div><div> instance = booter;</div><div> break;</div><div> }</div><div> }</div><div> return instance;</div><div> }</div><div>}</div></div><div><br></div><div>Obviously ignore concurrency issues, etc. It does look to be safer to do an abstract class, rather than a factory-interface.</div><div><br></div><div>John</div><div><br></div><br><div class="gmail_quote">On Wed Dec 17 2014 at 10:40:44 AM Antoine Sabot-Durand <<a href="mailto:antoine@sabot-durand.net">antoine@sabot-durand.net</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi all,<div><br></div><div><br></div><div>I have business matter and will have to shorten the meeting tonight (half an hour instead of 1h).</div><div><br></div><div>I updated the SE doc and Antonio added useful annexes : <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></div><div><br></div><div>I propose we focus on this in these 30 mn</div><div><br></div><div>regards,</div><div><br></div><div>Antoine</div></div>______________________________<u></u>_________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/<u></u>mailman/listinfo/cdi-dev</a><br>
<br>
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" target="_blank">http://www.apache.org/<u></u>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.</blockquote></div>