<div dir="ltr">Hi,<br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 28, 2017 at 9:41 AM, Martin Kouba <span dir="ltr">&lt;<a href="mailto:mkouba@redhat.com" target="_blank">mkouba@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Set&lt;Annotation&gt; bindings = (Set&lt;Annotation&gt;) invocationContext.getContextDa<wbr>ta().get(&quot;org.jboss.weld.<wbr>interceptor.bindings&quot;);<br>
</blockquote>
<br></span>
In fact, a more safe way is to use the Weld API, cast the invocation context to org.jboss.weld.interceptor.Wel<wbr>dInvocationContext and use the appropriate methods.</blockquote><div><br></div><div>Looking in the code that seems to do the same thing, at least in Weld 3.0.1.</div><div><br></div><div>Going via getContextDa<wbr>ta() is much easier though for code that has to support both Weld and OWB.</div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="gmail-"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br></blockquote></span>
Yes. There is already a spec issue: <a href="https://issues.jboss.org/browse/CDI-468" rel="noreferrer" target="_blank">https://issues.jboss.org/brows<wbr>e/CDI-468</a> but this would require a change in interceptors spec.</blockquote><div><br></div><div>I read the issue, thanks for the pointer. I do wonder if the entry in the context data isn&#39;t the easiest option regardless. That might only require an update in the CDI spec. Essentially, just standardise the key being used?</div><div><br></div><div>Currently the interceptor factory is an absolutely fantastic feature, but its usefulness is greatly diminished by the fact that no interceptor at this moment can (reliably) retrieve the interceptor bindings for all CDI implementations.</div><div><br></div><div>The spec even uses dynamically adding @Transactional as an example;</div><div><br></div><div><div> * &lt;pre&gt;</div><div> * &amp;#64;Produces</div><div> * &amp;#64;RequestScoped</div><div> * public MyClass produceMyClass(InterceptionFactory&lt;MyClass&gt; factory) {</div><div> *     factory.configure().add(new AnnotationLiteral&lt;Transactional&gt;() {</div><div> *     });</div><div> *     return factory.createInterceptedInstance(new MyClass());</div><div> * }</div></div><div><br></div><div><br></div><div>But all the current interceptor implementations backing @Transactional do something like:</div><div><br></div><div><div>public Object proceed(InvocationContext ctx) throws Exception {</div><div>        Transactional transactionalAnnotation =</div><div>                ctx.getMethod().getAnnotation(Transactional.class);</div></div><div><br></div><div>So that clearly won&#39;t work.</div><div><br></div><div>The spec text for InterceptionFactory also doesn&#39;t mention this caveat at all. So I wonder, what was the intended approach for   InterceptionFactory and intercepter bindings with attributes?</div><div><br></div><div>Or was InterceptionFactory solely intended for intercepter bindings without (non-binding) attributes?</div><div><br></div><div>Kind regards,</div><div>Arjan Tijms</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="gmail-"><br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
Is there a standard way to get the bindings? Perhaps getting hold of the Bean&lt;T&gt; that represents the current Interceptor?<br>
</blockquote>
<br></span>
You can inject a bean with scope @Dependent, qualifier @Default and type Interceptor into any interceptor instance. However, this will not help for @Nonbinding value members of an interceptor binding.<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
Kind regards,<br>
Arjan Tijms<br>
<br>
<br>
______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://lists.jboss.org/mailma<wbr>n/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" rel="noreferrer" target="_blank">http://www.apache.org/license<wbr>s/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><span class="gmail-HOEnZb"><font color="#888888">
</font></span></blockquote><span class="gmail-HOEnZb"><font color="#888888">
<br>
-- <br>
Martin Kouba<br>
Senior Software Engineer<br>
Red Hat, Czech Republic<br>
</font></span></blockquote></div><br></div></div>