- All Implemented Interfaces:
Serializable
,Comparable<DispatchStrategy>
,java.lang.constant.Constable
The
DispatchStrategy
defines how child events are published within a
parent event publish cycle.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionSame as theSEQUENTIAL
approach with the difference that the sequential dispatch process is done asynchronously, freeing your parent's thread immediately after publishing your parent event.The parent (invoker) thread is used to publish the parent's event to all matching observers (and is blocked till done).Each matching observer is invoked in its own thread.The parent (invoker) thread is used to publish the parent's event as well as the child events published by the matching observers of the parent event (and so on, in case them useSEQUENTIAL
as well). -
Method Summary
Modifier and TypeMethodDescriptionstatic DispatchStrategy
Returns the enum constant of this type with the specified name.static DispatchStrategy[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
SEQUENTIAL
The parent (invoker) thread is used to publish the parent's event as well as the child events published by the matching observers of the parent event (and so on, in case them useSEQUENTIAL
as well). Any observer (directly or indirectly) invoked by your invoking thread can block your invoking thread. -
ASYNC
Same as theSEQUENTIAL
approach with the difference that the sequential dispatch process is done asynchronously, freeing your parent's thread immediately after publishing your parent event. Exactly one extra thread is created to kick off the asynchronous way of doing a sequential dispatch. Any observer (directly or indirectly) invoked by the "asynchronous" thread can block any other observer in that chain, but not your invoking thread. -
CASCADE
The parent (invoker) thread is used to publish the parent's event to all matching observers (and is blocked till done). Child events published by the matching observers invoked with the parent's event are queued until the parent's thread finished dispatching the parent's event. The queued child events then are published in their own separate threads, now considered being parent events with their according parent threads, to all matching observers (dispatching as described above). TheCASCADE
strategy is useful when publishing lifecycle or bootstrapping events to make sure, that any observer was notified before publishing post-lifecycle actions. Observers directly invoked by your invoking thread can block your invoking thread and indirectly invoked observers called by your directly invoked observers using theSEQUENTIAL
strategy for publishing their events. -
PARALLEL
Each matching observer is invoked in its own thread. No observer can block your invoking thread.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-