[cdi-dev] JMS 2.1: Proposal to allow any CDI managed bean in a Java EE application to listen for JMS messages

Nigel Deakin nigel.deakin at oracle.com
Tue Aug 25 13:20:18 EDT 2015


On 25/08/2015 00:18, arjan tijms wrote:
> Hi,

Hi Arjan,

> On Mon, Aug 24, 2015 at 9:47 PM, Nigel Deakin <nigel.deakin at oracle.com> wrote:
>
>> If I understand things correctly, if this is a normal CDI bean then this
>> alone is not sufficient to cause an instance of the bean to be created.
>>
>> You also need to
>> (1) inject it into some other bean
>> (2) create that other bean and
>> (3) call a method on the MyListenerBean to trigger lazy initialisation.
>
> This is one way for sure, but one alternative worth mentioning is to
> eagerly instantiatie the scoped bean whenever its scope starts. For
> OmniFaces we have implemented a separate annotation for this for CDI
> 1.0, see http://showcase.omnifaces.org/cdi/Eager

Someone over on the JMS user alias told me about this yesterday. So that would avoid the need to call a method to 
trigger lazy initialisation on normal-scoped bean proxies. I presume the application still has to inject the bean.

If so then it sounds useful. Is it going to be included as a standard feature of CDI 2.0? I see someone has proposed 
https://issues.jboss.org/browse/CDI-473 .

Nigel




More information about the cdi-dev mailing list