CDI Events

CDI events allow your application components to communicate with each other in a loosely coupled manner. Those more familiar with JMS can also think of CDI events as a Synchronous equivalent of JMS (with Java EE 8, CDI 2.0 will offer asynchronous event mechanism).

Event Qualifiers

Events can be enriched using qualifiers. Think of these as message selectors (the concept is not very different from Message Selectors in JMS).

Using Dynamic CDI event qualifiers

The above example demonstrates the static way of declaring qualifiers. CDI also provides a more dynamic version of the same feature (qualifier declaration).

Please note that you can specify multiple qualifiers with this mechanism

Other options

Although not discussed here, the Event interface also exposes couple of other methods to allow dynamic qualifier selection.

The benefits are obvious…

The select method (and its overloaded counterparts) provide a flexible way of handling qualified events and helps avoid proliferation of injected Event instances for specific set of qualifiers.

Cheers!