Enum DispatchStrategy

    • Enum Constant Detail

      • 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 Detail

      • values

        public static DispatchStrategy[] values​()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (DispatchStrategy c : DispatchStrategy.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static DispatchStrategy valueOf​(String name)
        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 name
        NullPointerException - if the argument is null