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

arjan tijms arjan.tijms at gmail.com
Tue Aug 25 07:38:28 EDT 2015


On Tue, Aug 25, 2015 at 1:19 PM, John D. Ament <john.d.ament at gmail.com> wrote:
> Technically speaking, I can have a bean like this:
>
> @ApplicationScoped
> public class Foo {
>     public void onStart(@Observes @initialized(ApplicationScoped.class)
> Object obj) {
>        // do some work here
>     }
> }
>
> That bean will get instantiated by the container, even if it doesn't have
> any injection targets.

Indeed, that's what I meant above with the reference to the
@Initialized and @Destroyed annotations. With that construct a JMS
Listener bean can be "started" without it having to be referenced from
other code.


More information about the cdi-dev mailing list