Serializable
, Comparable<DispatchStrategy>
public enum DispatchStrategy extends Enum<DispatchStrategy>
DispatchStrategy
defines how child events are published within a
parent event publish cycle.Enum Constant | Description |
---|---|
ASYNC |
Same as the
SEQUENTIAL approach with the difference that the
sequential dispatch process is done asynchronously, freeing your parent's
thread immediately after publishing your parent event. |
CASCADE |
The parent (invoker) thread is used to publish the parent's event to all
matching observers (and is blocked till done).
|
PARALLEL |
Each matching observer is invoked in its own thread.
|
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 use
SEQUENTIAL as well). |
Modifier and Type | Method | Description |
---|---|---|
static DispatchStrategy |
valueOf(String name) |
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.
|
public static final DispatchStrategy SEQUENTIAL
SEQUENTIAL
as well).
Any observer (directly or indirectly) invoked by your invoking thread can
block your invoking thread.public static final DispatchStrategy ASYNC
SEQUENTIAL
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.public static final DispatchStrategy CASCADE
CASCADE
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 the SEQUENTIAL
strategy
for publishing their events.public static final DispatchStrategy PARALLEL
public static DispatchStrategy[] values()
for (DispatchStrategy c : DispatchStrategy.values()) System.out.println(c);
public static DispatchStrategy valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullCopyright © 2018. All rights reserved.