Enum Class DispatchStrategy

java.lang.Object
java.lang.Enum<DispatchStrategy>
org.refcodes.eventbus.DispatchStrategy
All Implemented Interfaces:
Serializable, Comparable<DispatchStrategy>, Constable

public enum DispatchStrategy extends Enum<DispatchStrategy>
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 Constants
    Enum Constant
    Description
    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.
    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 use SEQUENTIAL as well).
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • SEQUENTIAL

      public static final DispatchStrategy 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). Any observer (directly or indirectly) invoked by your invoking thread can block your invoking thread.
    • ASYNC

      public static final DispatchStrategy 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. 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

      public static final DispatchStrategy 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). The 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.
    • PARALLEL

      public static final DispatchStrategy PARALLEL
      Each matching observer is invoked in its own thread. No observer can block your invoking thread.
  • Method Details

    • values

      public static DispatchStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DispatchStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null