<div dir="ltr">John,<div><br></div><div>During AfterDeploymentValidation, you can use BeanManager.createInstance() to retrieve a bean instance. It was added for that.</div><div><br></div><div>Antoine</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Apr 4, 2017 at 9:12 AM Martin Kouba <<a href="mailto:mkouba@redhat.com">mkouba@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">FYI I've created <a href="https://issues.jboss.org/browse/WELD-2371" rel="noreferrer" class="gmail_msg" target="_blank">https://issues.jboss.org/browse/WELD-2371</a>.<br class="gmail_msg">
<br class="gmail_msg">
Martin<br class="gmail_msg">
<br class="gmail_msg">
Dne 3.4.2017 v 14:59 Martin Kouba napsal(a):<br class="gmail_msg">
> John,<br class="gmail_msg">
><br class="gmail_msg">
> that's not true. I'm saying that calling CDI.current() and<br class="gmail_msg">
> CDI.getBeanManager() is valid. However, it is not portable (and NOT<br class="gmail_msg">
> supported by Weld ATM) to call other CDI methods (CDI.select() etc.)<br class="gmail_msg">
> before the application initialization is completed.<br class="gmail_msg">
><br class="gmail_msg">
> See also 11.3.1. Obtaining a reference to the CDI container:<br class="gmail_msg">
> "A portable extension or other object may obtain a reference to the<br class="gmail_msg">
> current container by calling CDI.current(). CDI.getBeanManager() may be<br class="gmail_msg">
> called at any time after the container fires the BeforeBeanDiscovery<br class="gmail_msg">
> container lifecycle event until the container fires the BeforeShutdown<br class="gmail_msg">
> container lifecycle event. Other methods on CDI may be called after the<br class="gmail_msg">
> application initialization is completed until the application shutdown<br class="gmail_msg">
> starts. If methods on CDI are called at any other time, non-portable<br class="gmail_msg">
> behavior results."<br class="gmail_msg">
><br class="gmail_msg">
> I believe the spec is clear...<br class="gmail_msg">
><br class="gmail_msg">
> Martin<br class="gmail_msg">
><br class="gmail_msg">
> Dne 3.4.2017 v 14:49 John Ament napsal(a):<br class="gmail_msg">
>> All,<br class="gmail_msg">
>><br class="gmail_msg">
>><br class="gmail_msg">
>> So Martin below is saying its valid, but then in the ticket is saying<br class="gmail_msg">
>> its not valid. I'll wait for others to voice opinions on this one.<br class="gmail_msg">
>><br class="gmail_msg">
>><br class="gmail_msg">
>> John<br class="gmail_msg">
>><br class="gmail_msg">
>><br class="gmail_msg">
>><br class="gmail_msg">
>><br class="gmail_msg">
>> ------------------------------------------------------------------------<br class="gmail_msg">
>> *From:* Martin Kouba <<a href="mailto:mkouba@redhat.com" class="gmail_msg" target="_blank">mkouba@redhat.com</a>><br class="gmail_msg">
>> *Sent:* Monday, April 3, 2017 2:48 AM<br class="gmail_msg">
>> *To:* John Ament; cdi-dev<br class="gmail_msg">
>> *Subject:* Re: [cdi-dev] CDI.current() in AfterDeploymentValidation<br class="gmail_msg">
>><br class="gmail_msg">
>> Hi John,<br class="gmail_msg">
>><br class="gmail_msg">
>> I think it's valid to call CDI.current() from within an extension. WRT<br class="gmail_msg">
>> Weld - what version and environment do you use? There was an issue in<br class="gmail_msg">
>> Weld SE which should be fixed in 2.4.2 (see also WELD-2256 [1]).<br class="gmail_msg">
>><br class="gmail_msg">
>> Martin<br class="gmail_msg">
>><br class="gmail_msg">
>> [1]<br class="gmail_msg">
>> <a href="https://issues.jboss.org/browse/WELD-2256" rel="noreferrer" class="gmail_msg" target="_blank">https://issues.jboss.org/browse/WELD-2256</a><br class="gmail_msg">
>><br class="gmail_msg">
>> Dne 3.4.2017 v 04:36 John Ament napsal(a):<br class="gmail_msg">
>>> So I know during the reception of AfterDeploymentValidation, the<br class="gmail_msg">
>>> container isn't fully bootstrapped. However, its valid to look up<br class="gmail_msg">
>>> beans. I would therefore expect that CDI.current().select()... to work<br class="gmail_msg">
>>> fine. However, at least in Weld it doesn't. This is because<br class="gmail_msg">
>>> CDI.current() cannot figure out what container to use (it's not fully<br class="gmail_msg">
>>> bootstrapped yet). So my question - is this a Weld issue, or a spec<br class="gmail_msg">
>>> clarification?<br class="gmail_msg">
>>><br class="gmail_msg">
>>><br class="gmail_msg">
>>> John<br class="gmail_msg">
>>><br class="gmail_msg">
>>> ------------------------------------------------------------------------<br class="gmail_msg">
>>> NOTICE: This e-mail message and any attachments may contain<br class="gmail_msg">
>>> confidential, proprietary, and/or privileged information which should be<br class="gmail_msg">
>>> treated accordingly. If you are not the intended recipient, please<br class="gmail_msg">
>>> notify the sender immediately by return e-mail, delete this message, and<br class="gmail_msg">
>>> destroy all physical and electronic copies. Thank you.<br class="gmail_msg">
>>><br class="gmail_msg">
>>><br class="gmail_msg">
>>> _______________________________________________<br class="gmail_msg">
>>> cdi-dev mailing list<br class="gmail_msg">
>>> <a href="mailto:cdi-dev@lists.jboss.org" class="gmail_msg" target="_blank">cdi-dev@lists.jboss.org</a><br class="gmail_msg">
>>> <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br class="gmail_msg">
>>><br class="gmail_msg">
>>> Note that for all code provided on this list, the provider licenses<br class="gmail_msg">
>>> the code under the Apache License, Version 2<br class="gmail_msg">
>>> (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" class="gmail_msg" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas<br class="gmail_msg">
>> provided on this list, the provider waives all patent and other<br class="gmail_msg">
>> intellectual property rights inherent in such information.<br class="gmail_msg">
>>><br class="gmail_msg">
>><br class="gmail_msg">
>> --<br class="gmail_msg">
>> Martin Kouba<br class="gmail_msg">
>> Senior Software Engineer<br class="gmail_msg">
>> Red Hat, Czech Republic<br class="gmail_msg">
>> ------------------------------------------------------------------------<br class="gmail_msg">
>> NOTICE: This e-mail message and any attachments may contain<br class="gmail_msg">
>> confidential, proprietary, and/or privileged information which should be<br class="gmail_msg">
>> treated accordingly. If you are not the intended recipient, please<br class="gmail_msg">
>> notify the sender immediately by return e-mail, delete this message, and<br class="gmail_msg">
>> destroy all physical and electronic copies. Thank you.<br class="gmail_msg">
><br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
Martin Kouba<br class="gmail_msg">
Senior Software Engineer<br class="gmail_msg">
Red Hat, Czech Republic<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
cdi-dev mailing list<br class="gmail_msg">
<a href="mailto:cdi-dev@lists.jboss.org" class="gmail_msg" target="_blank">cdi-dev@lists.jboss.org</a><br class="gmail_msg">
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br class="gmail_msg">
<br class="gmail_msg">
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" class="gmail_msg" 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 class="gmail_msg">
</blockquote></div>