- Type Parameters:
T
- type of the event object
- Enclosing class:
Event
To publish an event, simply inject an instance of this type (correctly typed with your event object) into your service,
and call
emit(Object, Qualifier...)
on it when needed.
A single service can inject more than one instance, if it wants to publish events of different types. The type of the event is determining which events are published (i.e. qualifiers or any other annotation are not relevant, only the type of the object).
-
Method Summary
-
Method Details
-
emit
Emit an event. The method blocks until all observers are processed.Only observers with the same qualifiers as specified will be notified.
- Parameters:
eventObject
- event object to deliver to the observersqualifiers
- qualifiers (zero or more) that qualify this event instance- Throws:
EventDispatchException
- if any exception is encountered, the first one is the cause, and all others are added as a suppressed exception to the thrown exception
-
emitAsync
Emit an event. The method returns immediately with a completion stage that will get completed when all observers are notified. If any observer throws an exception, anEventDispatchException
is created, all exceptions are added as suppressed to it, and it is thrown, soCompletionStage.exceptionally(java.util.function.Function)
is invoked on the returned stage.Only observers with the same qualifiers as specified will be notified.
- Parameters:
eventObject
- event object to deliver to the listenersqualifiers
- qualifiers (zero or more) that qualify this event instance- Returns:
- completion stage to observe completion events
-