<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">On 12/18/2014 04:33 AM, John D. Ament
wrote:<br>
</div>
<blockquote
cite="mid:CAOqetn_XZweS6mjj5AgH5kUJbYGg+7eGwb9cKhFipd0Tsy3DYQ@mail.gmail.com"
type="cite">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>
</blockquote>
Why BeanManager? I think it would be better to return CDI or its
subclass rather than this low-level SPI. With the CDI class we get
more user-friendly Instance<T> for free. We could also expose
Event<T> similarly.<br>
<blockquote
cite="mid:CAOqetn_XZweS6mjj5AgH5kUJbYGg+7eGwb9cKhFipd0Tsy3DYQ@mail.gmail.com"
type="cite">
<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 moz-do-not-send="true"
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 moz-do-not-send="true"
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>
_______________________________________________<br>
cdi-dev mailing list<br>
<a moz-do-not-send="true"
href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a><br>
<a moz-do-not-send="true"
href="https://lists.jboss.org/mailman/listinfo/cdi-dev"
target="_blank">https://lists.jboss.org/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
moz-do-not-send="true"
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 provided on this list, the provider waives
all patent and other intellectual property rights inherent in
such information.</blockquote>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
cdi-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/cdi-dev">https://lists.jboss.org/mailman/listinfo/cdi-dev</a>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a class="moz-txt-link-freetext" href="http://www.apache.org/licenses/LICENSE-2.0.html">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.</pre>
</blockquote>
<br>
</body>
</html>