<div dir="ltr"><div>All,</div><div><br></div><div>The Java EE 8 EG (which at least Antonio and myself, but also Antoine and others representing CDI Spec Lead Red Hat are also EG members) has this paragraph on CDI: </div><div><br></div><div><span style="color:rgb(102,102,102);font-family:Arial,Helvetica,sans-serif;font-size:11px">We plan to enhance the managed bean model to make ease of use features that are currently available only to selected components available to all managed beans via the mechanisms provided by CDI. In particular, we plan to consider enhancements for declarative security by means of CDI interceptors and for notifications for timed events by means of the CDI event and observer mechanism.</span><br></div><br><div class="gmail_extra"><br></div><div class="gmail_extra">I understand, it mostly aims at using CDI in other JSRs like 375 (somewhere along the lines of Agorava or its precursor JSR 357;-) </div><div class="gmail_extra"><br></div><div class="gmail_extra">If it&#39;s a completely new annotation (at least for CDI) would it be totally wrong to define this by CDI itself?</div><div class="gmail_extra"><br></div><div class="gmail_extra">Of course it&#39;s already in EJB (javax.ejb) and given Java EE 8 plans to prune some of the EJB Spec, that is most clearly one to be touched in EE 8.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Unless it&#39;s something to be pruned of javax.ejb it won&#39;t go away from there either. javax.enterprise.concurrent is so tiny and (unless using others already;-) doesn&#39;t declare a single annotation of its own so far, so why bother doing so for this one?</div><div class="gmail_extra"><br></div><div class="gmail_extra">If it feels wrong in javax.ejb or should work entirely without EJB then consider some place where CDI already has annotations (not just under its main packages) </div><div class="gmail_extra">CDI 2 aims at a &quot;Standard/Desktop&quot; variant and another one like &quot;Full/Enterprise&quot; depending on which of these benefit from such annotation that may influence where to put it.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><span lang="EN-US" style="font-size:13px;font-family:Calibri">Werner Keil </span><span style="font-size:13px"><font face="Arial"><span style="font-family:arial,sans-serif"><span lang="EN-US" style="font-family:Calibri">| <font face="Arial"><span style="color:rgb(0,0,0);border-collapse:separate;font-stretch:normal"><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse"><span lang="EN-US" style="font-family:Calibri">JCP Executive Committee Member, JSR 363 Co Spec Lead | Eclipse </span></span></span></font></span><font face="Arial"><span style="font-family:arial,sans-serif"><span lang="EN-US" style="font-family:Calibri"><font face="Arial"><span style="color:rgb(0,0,0);border-collapse:separate;font-stretch:normal"><span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse"><span lang="EN-US" style="font-family:Calibri">UOMo Lead, Babel Language Champion</span></span></span></font></span></span></font></span></font></span><span style="font-size:13px;font-family:Calibri"> </span><span style="font-size:13px;font-family:Calibri">| Apache Committer | Advisory Board Member, Java Track Chair, DWX &#39;15</span><br></div><div class="gmail_extra"><div><div class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font face="Arial"><span style="font-family:arial,sans-serif"> <p style="margin:0px;font-size:13px;border-collapse:collapse"><span style="font-family:arial,sans-serif"><font face="Arial"><span style="font-family:arial,sans-serif"><span style="font-family:Helvetica;font-size:medium;border-collapse:separate"><span style="font-family:Calibri;font-size:12px">Twitter @wernerkeil </span></span><span style="font-family:arial,sans-serif"><font face="Arial"><span style="font-family:arial,sans-serif"><span style="font-family:Helvetica;font-size:medium;border-collapse:separate"><span style="font-family:Calibri;font-size:12px"><span style="font-size:13px;border-collapse:collapse"></span>|</span></span></span></font></span></span></font></span><span style="font-family:Helvetica;font-size:medium;border-collapse:separate"><span style="font-family:Calibri;font-size:12px"><span style="font-size:13px;border-collapse:collapse"></span> @UnitAPI | @JSR354 | @AgoravaProj | </span><span style="font-family:Calibri;font-size:12px">#EclipseUOMo | #D</span></span><span style="font-family:Calibri;font-size:12px">eviceMap |</span><span style="font-family:Calibri;font-size:12px"> </span><span style="font-family:Calibri;font-size:12px">#DevOps</span></p></span></font><span lang="EN-GB"> <div style="font-family:arial,helvetica,sans-serif"><span style="font-family:arial,sans-serif"><font face="Arial"><span style="font-family:arial,sans-serif"><span style="font-family:Helvetica;font-size:medium;border-collapse:separate"><span style="font-family:Calibri;font-size:12px">Skype </span><span style="font-family:Calibri;font-size:12px"><span style="font-size:13px;border-collapse:collapse">werner.keil | Google+ <a href="http://gplus.to/wernerkeil" target="_blank"><font color="#1155cc">gplus.to/wernerkeil</font></a></span></span></span></span></font></span></div></span></div></div></div></div></div></div>
<br><div class="gmail_quote">On Sat, Jan 17, 2015 at 4:58 PM,  <span dir="ltr">&lt;<a href="mailto:cdi-dev-request@lists.jboss.org" target="_blank">cdi-dev-request@lists.jboss.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Send cdi-dev mailing list submissions to<br>
        <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
or, via email, send a message with subject or body &#39;help&#39; to<br>
        <a href="mailto:cdi-dev-request@lists.jboss.org">cdi-dev-request@lists.jboss.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:cdi-dev-owner@lists.jboss.org">cdi-dev-owner@lists.jboss.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of cdi-dev digest...&quot;<br>
<br>
<br>
Today&#39;s Topics:<br>
<br>
   1. Re: Building EJB-like @Asynchronous via interceptor in CDI<br>
      (Antonio Goncalves)<br>
   2. Re: Building EJB-like @Asynchronous via interceptor in CDI<br>
      (Mark Struberg)<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Sat, 17 Jan 2015 15:58:06 +0000 (UTC)<br>
From: Mark Struberg &lt;<a href="mailto:struberg@yahoo.de">struberg@yahoo.de</a>&gt;<br>
Subject: Re: [cdi-dev] Building EJB-like @Asynchronous via interceptor<br>
        in CDI<br>
To: Antonio Goncalves &lt;<a href="mailto:antonio.goncalves@gmail.com">antonio.goncalves@gmail.com</a>&gt;<br>
Cc: &quot;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&quot; &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
Message-ID:<br>
        &lt;<a href="mailto:1807377505.2717120.1421510286847.JavaMail.yahoo@jws11147.mail.ir2.yahoo.com">1807377505.2717120.1421510286847.JavaMail.yahoo@jws11147.mail.ir2.yahoo.com</a>&gt;<br>
<br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
@Antonio: and where/how to start this context? Boils down to the exactly same issue.<br>
<br>
Also remember that @RequestScoped IS already almost the same as it must be there for every EJB invocation, @Asynchronous, @Startup @Singleton @PostConstruct methods, JMS invocations, etc, etc<br>
<br>
LieGrue,<br>
strub<br>
On Saturday, 17 January 2015, 16:31, Antonio Goncalves &lt;<a href="mailto:antonio.goncalves@gmail.com">antonio.goncalves@gmail.com</a>&gt; wrote:<br>
<br>
<br>
&gt;<br>
&gt;<br>
&gt;@Arjan, remember the email I sent to the EE EG entitled &quot;Status of the Java EE 8 specifications&quot;. Bill Shannon replied :<br>
&gt;<br>
&gt;<br>
&gt;We agree on the long term vision.  This is almost entirely a resource issue.  In order to do this, we have to stop doing something else, or we have to delay the release.  Based on the feedback we&#39;ve gotten from the community, the things we&#39;ve chosen to work on right now are the most important.  We&#39;d like to do what you suggest below as well, but it&#39;s most likely going to have to be done later.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;So I don&#39;t know how we could &quot;push&quot; for an MR of the EE Concurrency spec. Any idea ? Except harassing Bill to add resources to the EE Concurrency spec and taking other resources out somewhere else... I don&#39;t know how we could do this.<br>
&gt;<br>
&gt;<br>
&gt;@Mark EE Concurreny could also add a @ThreadScoped like the one in Weld (but with a EE meaning).<br>
&gt;<br>
&gt;<br>
&gt;Antonio<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;On Sat, Jan 17, 2015 at 1:53 PM, Mark Struberg &lt;<a href="mailto:struberg@yahoo.de">struberg@yahoo.de</a>&gt; wrote:<br>
&gt;<br>
&gt;EE concurrency spec needs an update anyway. It currently doesn&#39;t explicitly require @RequestScoped beans to be supported on a new Thread. That breaks tons of frameworks and makes it barely usable in EE7.<br>
&gt;&gt;<br>
&gt;&gt;LieGrue,<br>
&gt;&gt;strub<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;On Saturday, 17 January 2015, 13:12, arjan tijms &lt;<a href="mailto:arjan.tijms@gmail.com">arjan.tijms@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;Hi,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;On Sat, Jan 17, 2015 at 11:05 AM, Antonio Goncalves &lt;<a href="mailto:antonio.goncalves@gmail.com">antonio.goncalves@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;@arjan Your example is base on  ManagedExecutorService from the Java EE Concurrency spec. That&#39;s one topic we&#39;ve been wondering about : should the @Asynchronous interceptor go to the Java EE Concurrency spec or not ? But it looks like the spec might not be updated.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;The example I showed here would IMHO best be placed in the Java EE Concurrency spec. That would in my opinion be a perfect analogy to @Transactional and JTA. As given, the interceptor uses CDI/Interceptors and Concurrency, so theoretically it could also be put into a third spec.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;Personally I would find it strange to put something in spec A, when it may better belong in spec B, just because spec B is not updated. What&#39;s holding the update of Java EE Concurrency back? If most of the EG members would be of the opinion that an @Asynchronous interceptor belongs best in Java EE Concurrency, then we can just update that spec, right?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;I know that MR releases can be quite fast and agile process wise, while still packing some punch. JTA 1.2 itself was just such an MR, and JASPIC 1.1 was too. I was somewhat involved with JASPIC 1.1 (as community member) and I think the setup time was pretty fast. Mid feb 2013 we created the JIRA issues, the MR draft was published early march 2013 and the release was with EE 7 end may 2013.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;If it would just be about putting a few interceptors formally in Java EE Concurrency, then why not do such small update for it?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;Kind regards,<br>
&gt;&gt;&gt;Arjan<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;Antonio<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;On Sat, Jan 17, 2015 at 12:32 AM, arjan tijms &lt;<a href="mailto:arjan.tijms@gmail.com">arjan.tijms@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;Hi,<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;On Fri, Jan 16, 2015 at 10:41 PM, Jozef Hartinger &lt;<a href="mailto:jharting@redhat.com">jharting@redhat.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;Hi Arjan,<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;I did some changes recently in Weld interceptors and this usecase<br>
&gt;&gt;    now works smoothly. The code is not part of a release yet. See this<br>
&gt;&gt;    test for a simple implementation of an @Async interceptor (basically<br>
&gt;&gt;    the same as your initial attempt). Note that the chain is repeatable<br>
&gt;&gt;    but at the same time it is not reset after dispatch to a different<br>
&gt;&gt;    thread so you no longer need the ThreadLocal nor any other<br>
&gt;&gt;    workaround.<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;That&#39;s quite a coincidence, it&#39;s indeed rather similar ;)<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;I wonder how it now works though, as the InvocationContext &quot;ctx&quot; does not seem to be made aware that it&#39;s been dispatched to a different thread from within the code. Does it use an internal thread local to keep state or so?<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;I&#39;ll also try to see what this does on OWB. Do you think this is something that should work, or just something that Weld happens to support regardless of the spec?<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;Kind regards,<br>
&gt;&gt;&gt;&gt;&gt;Arjan<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;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;<a href="https://github.com/weld/core/blob/master/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/thread/async/AsyncInterceptor.java" target="_blank">https://github.com/weld/core/blob/master/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/thread/async/AsyncInterceptor.java</a><br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;Jozef<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;On 01/16/2015 06:17 PM, arjan tijms wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;Hi,<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;I&#39;m attempting to emulate EJB&#39;s @Asynchronous in CDI using interceptors.<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;Originally I had defined my interceptor as follows;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;@Interceptor<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;@Asynchronous<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;@Priority(APPLICATION)<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;public class AsynchronousInterceptor implements Serializable {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    private static final long serialVersionUID = 1L;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    @Resource<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    private ManagedExecutorService managedExecutorService;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    @AroundInvoke<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    public Object submitAsync(InvocationContext ctx) throws<br>
&gt;&gt;          Exception {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        return new<br>
&gt;&gt;          FutureDelegator(managedExecutorService.submit( ()-&gt; {<br>
&gt;&gt;          return ctx.proceed(); } ));<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    }<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;}<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;With FutureDelegator as follows:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;public class FutureDelegator implements Future&lt;Object&gt; {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    private Future&lt;?&gt; future;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    public FutureDelegator(Future&lt;?&gt; future) {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        this.future = future;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    }<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    @Override<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    public Object get() throws InterruptedException,<br>
&gt;&gt;          ExecutionException {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        AsyncResult&lt;?&gt; asyncResult =<br>
&gt;&gt;          (AsyncResult&lt;?&gt;) future.get();<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        if (asyncResult == null) {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;            return null;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        }<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        return asyncResult.get();<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    }<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    @Override<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    public Object get(long timeout, TimeUnit unit) throws<br>
&gt;&gt;          InterruptedException,    ExecutionException, TimeoutException<br>
&gt;&gt;          {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        AsyncResult&lt;?&gt; asyncResult =<br>
&gt;&gt;          (AsyncResult&lt;?&gt;) future.get(timeout, unit);<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        if (asyncResult == null) {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;            return null;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        }<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        return asyncResult.get();<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    }<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    @Override<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    public boolean cancel(boolean mayInterruptIfRunning) {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        return future.cancel(mayInterruptIfRunning);<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    }<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    @Override<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    public boolean isCancelled() {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        return future.isCancelled();<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    }<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    @Override<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    public boolean isDone() {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        return future.isDone();<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    }<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;}<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;This of course didn&#39;t quite work, as the InvocationContext will be reset after the @AroundInvoke method returns, and an infinite intercept loop results (on Weld).<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;I got it to work though on Weld by using a thread local check<br>
&gt;&gt;          to break that loop:<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;@Interceptor<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;@Asynchronous<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;@Priority(PLATFORM_BEFORE)<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;public class AsynchronousInterceptor implements Serializable {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    private static final long serialVersionUID = 1L;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    @Resource<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    private ManagedExecutorService managedExecutorService;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    private static final ThreadLocal&lt;Boolean&gt;<br>
&gt;&gt;          asyncInvocation = new ThreadLocal&lt;Boolean&gt;();<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    @AroundInvoke<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    public synchronized Object submitAsync(InvocationContext<br>
&gt;&gt;          ctx) throws Exception {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        if (TRUE.equals(asyncInvocation.get())) {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;            return ctx.proceed();<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        }<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        return new<br>
&gt;&gt;          FutureDelegator(managedExecutorService.submit( ()-&gt; {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;            try {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;                asyncInvocation.set(TRUE);<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;                return ctx.proceed();<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;            } finally {<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;                 asyncInvocation.remove();<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;            }<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;        }));<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;    }<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;}<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;But I&#39;ve got a feeling this works just by chance and not because the workaround is so clever.<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;What do you guys think, what would be the best way to support this with the current CDI version? Or would CDI/Interceptors need something like Servlet&#39;s async support, where the InvocationContext is put into async mode whereafter it &quot;simply&quot; allows an other thread to continue processing on it?<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;Kind regards,<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;Arjan Tijms<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt;&gt;_______________________________________________<br>
&gt;&gt;cdi-dev mailing list <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a> <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">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 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.<br>
&gt;&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 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/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;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;--<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;Antonio Goncalves<br>
&gt;&gt;&gt;&gt;Software architect, Java Champion and Pluralsight author<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;Web site | Twitter | LinkedIn | Pluralsight | Paris JUG | Devoxx France<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;_______________________________________________<br>
&gt;&gt;&gt;cdi-dev mailing list<br>
&gt;&gt;&gt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&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;<br>
&gt;&gt;&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" 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;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;--<br>
&gt;<br>
&gt;Antonio Goncalves<br>
&gt;Software architect, Java Champion and Pluralsight author<br>
&gt;<br>
&gt;Web site | Twitter | LinkedIn | Pluralsight | Paris JUG | Devoxx France<br>
&gt;<br>
&gt;<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a 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 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.<br>
<br>
End of cdi-dev Digest, Vol 50, Issue 37<br>
***************************************<br>
</blockquote></div><br></div></div>