<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">2015-10-19 9:17 GMT+02:00 Martin Kouba <span dir="ltr">&lt;<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dne 19.10.2015 v 08:44 Romain Manni-Bucau napsal(a):<span class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
would be super cool to not have to write an extension for that, cant we<br>
use applicationscope init event or an prioritized event at this moment -<br>
avoiding the spi is a must for end user usage IMO?<br>
</blockquote>
<br></span>
Not possible, it&#39;s too late. ApplicationScoped init event is fired after the deployment validation. Well, maybe it&#39;s not that explicitly defined but it wouldn&#39;t make much sense to fire it before validation as you have to resolve a set of validated observers, usually declared on validated beans.<br>
<br></blockquote><div><br></div><div>we speak about cdi 2.0 so all is possible, i think all places would work but to be used it should respect the lightweight programmatic model of business beans of CDI. The SPI is always a &quot;let&#39;s do differently&quot; - was only my point. </div><div><br></div><div>Side note: since you add beans you should do it before the validation as well but means you cant skip Extension which is a pain :(</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
Romain Manni-Bucau<br>
@rmannibucau &lt;<a href="https://twitter.com/rmannibucau" rel="noreferrer" target="_blank">https://twitter.com/rmannibucau</a>&gt; | Blog<br>
&lt;<a href="http://rmannibucau.wordpress.com" rel="noreferrer" target="_blank">http://rmannibucau.wordpress.com</a>&gt; | Github<br>
&lt;<a href="https://github.com/rmannibucau" rel="noreferrer" target="_blank">https://github.com/rmannibucau</a>&gt; | LinkedIn<br>
&lt;<a href="https://www.linkedin.com/in/rmannibucau" rel="noreferrer" target="_blank">https://www.linkedin.com/in/rmannibucau</a>&gt; | Tomitriber<br>
&lt;<a href="http://www.tomitribe.com" rel="noreferrer" target="_blank">http://www.tomitribe.com</a>&gt;<span class=""><br>
<br>
2015-10-19 8:40 GMT+02:00 Martin Kouba &lt;<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a><br></span>
&lt;mailto:<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;&gt;:<span class=""><br>
<br>
    In CDI 2.0 we propose to support lambdas in the bean builder API -<br>
    currently available as a weld experimental feature in AfterBeanDiscovery<br>
    and Weld SE - see also [1] and [2].<br>
<br>
    For observers a similar builder might be useful.<br>
<br>
    Martin<br>
<br>
    [1]<br>
    <a href="http://weld.cdi-spec.org/news/2015/02/25/weld-300Alpha5/#_bean_builder_api" rel="noreferrer" target="_blank">http://weld.cdi-spec.org/news/2015/02/25/weld-300Alpha5/#_bean_builder_api</a><br>
<br>
    [2]<br>
    <a href="https://github.com/weld/core/blob/master/tests-arquillian/src/test/java/org/jboss/weld/tests/extensions/custombeans/BuilderExtension.java" rel="noreferrer" target="_blank">https://github.com/weld/core/blob/master/tests-arquillian/src/test/java/org/jboss/weld/tests/extensions/custombeans/BuilderExtension.java</a><br>
<br>
<br>
<br>
    Dne 17.10.2015 v 13:51 Sven Linstaedt napsal(a):<br>
    &gt; Just one question: Who is on charge and is able of managing this<br>
    &gt; unmanaged instances, e.g. lifecycle, serialization, concurrency (e.g.<br>
    &gt; when dealing with closures)?<br>
    &gt;<br>
    &gt; Functional programming and DI seem to be somehow disjunct in this case.<br>
    &gt; E.g. manually setting up observers seem to better fit extension than<br>
    &gt; normal application code.<br>
    &gt;<br>
    &gt; On the other side, specifying producer methods or fields, that are<br>
    &gt; injectable and return lambda expressions seems to be a no brainier for<br>
    &gt; CDI, is not it? As long as they are not scoped in a serializable context.<br>
    &gt;<br>
    &gt; Have a nice weekend<br>
    &gt; Sven<br>
    &gt;<br>
    &gt; -- sent by phone<br>
    &gt;<br>
    &gt; Am 17.10.2015 um 11:06 schrieb David Blevins &lt;<a href="mailto:david.blevins@gmail.com" target="_blank">david.blevins@gmail.com</a> &lt;mailto:<a href="mailto:david.blevins@gmail.com" target="_blank">david.blevins@gmail.com</a>&gt;<br></span>
     &gt; &lt;mailto:<a href="mailto:david.blevins@gmail.com" target="_blank">david.blevins@gmail.com</a> &lt;mailto:<a href="mailto:david.blevins@gmail.com" target="_blank">david.blevins@gmail.com</a>&gt;&gt;&gt;:<div><div class="h5"><br>
     &gt;<br>
     &gt;&gt; In brainstorming mode about fun that could be made possible with<br>
    Java<br>
     &gt;&gt; 8 and Java EE.<br>
     &gt;&gt;<br>
     &gt;&gt; Question in my mind is: is there some way we could make it possible<br>
     &gt;&gt; for Lambdas or Method Refs to be CDI beans?<br>
     &gt;&gt;<br>
     &gt;&gt; It goes against the grain obviously as CDI creation is very much a<br>
     &gt;&gt; “Don’t call us, we’ll call you” kind of thing.  The VM dynamically<br>
     &gt;&gt; creates a wrapper object around the Lambda or method reference<br>
    and it<br>
     &gt;&gt; implements the given interface.<br>
     &gt;&gt;<br>
     &gt;&gt; To make it work, there would need to be some non-producer method way<br>
     &gt;&gt; of saying “put this thing in the context with these qualifiers”.<br>
     &gt;&gt;<br>
     &gt;&gt; Imagine a method somewhere that would allow you to:<br>
     &gt;&gt;<br>
     &gt;&gt;    public &lt;T&gt; void addObserver(java.util.function.Consumer&lt;T&gt;<br>
     &gt;&gt; observer, Annotation... qualifiers);<br>
     &gt;&gt;<br>
     &gt;&gt;<br>
     &gt;&gt; Then you could take advantage as follows:<br>
     &gt;&gt;<br>
     &gt;&gt;    final List&lt;URI&gt; uris = new ArrayList&lt;&gt;();<br>
     &gt;&gt;    // @Observes URI<br>
     &gt;&gt;    addObserver((Consumer&lt;URI&gt;) uris::add);<br>
     &gt;&gt;<br>
     &gt;&gt;    // @Observes Thread<br>
     &gt;&gt;    addObserver(Runtime.getRuntime()::addShutdownHook);<br>
     &gt;&gt;<br>
     &gt;&gt;    // @Observes Runnable<br>
     &gt;&gt;    addObserver((Consumer&lt;Runnable&gt;)<br>
     &gt;&gt; Executors.newFixedThreadPool(3)::submit);<br>
     &gt;&gt;<br>
     &gt;&gt;    // @Observes URI<br>
     &gt;&gt;    addObserver((Consumer&lt;URI&gt;) System.out::println, new<br>
     &gt;&gt; AnnotationLiteral&lt;Fine&gt;() {<br>
     &gt;&gt;    });<br>
     &gt;&gt;<br>
     &gt;&gt;    // @Observes Handler<br>
     &gt;&gt;    final Logger logger = Logger.getLogger(&quot;somewhere&quot;);<br>
     &gt;&gt;    addObserver(logger::addHandler); // add handlers via event<br>
     &gt;&gt;<br>
     &gt;&gt;    // @Observes @Fine String<br>
     &gt;&gt;    addObserver((Consumer&lt;String&gt;) logger::fine, new<br>
     &gt;&gt; AnnotationLiteral&lt;Fine&gt;() {});<br>
     &gt;&gt;    }<br>
     &gt;&gt;<br>
     &gt;&gt;<br>
     &gt;&gt;<br>
     &gt;&gt; -David<br>
     &gt;&gt;<br>
     &gt;&gt;<br>
     &gt;&gt;<br>
     &gt;&gt; --<br>
     &gt;&gt; David Blevins<br>
     &gt;&gt; <a href="http://twitter.com/dblevins" rel="noreferrer" target="_blank">http://twitter.com/dblevins</a><br>
     &gt;&gt; <a href="http://www.tomitribe.com" rel="noreferrer" target="_blank">http://www.tomitribe.com</a><br>
     &gt;&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></div></div>
    &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;<span class=""><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 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 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;<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> &lt;mailto:<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>&gt;<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<br>
    ideas provided on this list, the provider waives all patent and<br>
    other intellectual property rights inherent in such information.<br>
    &gt;<br>
<br></span><span class="">
    --<br>
    Martin Kouba<br>
    Software Engineer<br>
    Red Hat, Czech Republic<br>
    _______________________________________________<br>
    cdi-dev mailing list<br></span><span class="">
    <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>
    <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" 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<br>
    the code under the Apache License, Version 2<br>
    (<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>
    ideas provided on this list, the provider waives all patent and<br>
    other intellectual property rights inherent in such information.<br>
<br>
<br>
</span></blockquote><div class="HOEnZb"><div class="h5">
<br>
-- <br>
Martin Kouba<br>
Software Engineer<br>
Red Hat, Czech Republic<br>
</div></div></blockquote></div><br></div></div>