Class AbstractDispatcher

java.lang.Object
org.springframework.integration.dispatcher.AbstractDispatcher
All Implemented Interfaces:
MessageDispatcher
Direct Known Subclasses:
BroadcastingDispatcher, UnicastingDispatcher

public abstract class AbstractDispatcher
extends java.lang.Object
implements MessageDispatcher
Base class for MessageDispatcher implementations.

The subclasses implement the actual dispatching strategy, but this base class manages the registration of MessageHandlers. Although the implemented dispatching strategies may invoke handles in different ways (e.g. round-robin vs. failover), this class does maintain the order of the underlying collection. See the OrderedAwareCopyOnWriteArraySet for more detail.

  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected org.apache.commons.logging.Log logger  
  • Constructor Summary

    Constructors 
    Constructor Description
    AbstractDispatcher()  
  • Method Summary

    Modifier and Type Method Description
    boolean addHandler​(org.springframework.messaging.MessageHandler handler)
    Add the handler to the internal Set.
    int getHandlerCount()
    Return the current handler count.
    protected java.util.Set<org.springframework.messaging.MessageHandler> getHandlers()
    Returns an unmodifiable Set of this dispatcher's handlers.
    boolean removeHandler​(org.springframework.messaging.MessageHandler handler)
    Remove the handler from the internal handler Set.
    void setMaxSubscribers​(int maxSubscribers)
    Set the maximum subscribers allowed by this dispatcher.
    java.lang.String toString()  
    protected boolean tryOptimizedDispatch​(org.springframework.messaging.Message<?> message)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.integration.dispatcher.MessageDispatcher

    dispatch
  • Field Details

    • logger

      protected final org.apache.commons.logging.Log logger
  • Constructor Details

  • Method Details

    • setMaxSubscribers

      public void setMaxSubscribers​(int maxSubscribers)
      Set the maximum subscribers allowed by this dispatcher.
      Parameters:
      maxSubscribers - The maximum number of subscribers allowed.
    • getHandlers

      protected java.util.Set<org.springframework.messaging.MessageHandler> getHandlers()
      Returns an unmodifiable Set of this dispatcher's handlers. This is provided for access by subclasses.
      Returns:
      The message handlers.
    • addHandler

      public boolean addHandler​(org.springframework.messaging.MessageHandler handler)
      Add the handler to the internal Set.
      Specified by:
      addHandler in interface MessageDispatcher
      Parameters:
      handler - The handler to add.
      Returns:
      the result of Set.add(Object)
    • removeHandler

      public boolean removeHandler​(org.springframework.messaging.MessageHandler handler)
      Remove the handler from the internal handler Set.
      Specified by:
      removeHandler in interface MessageDispatcher
      Parameters:
      handler - the handler.
      Returns:
      the result of Set.remove(Object)
    • tryOptimizedDispatch

      protected boolean tryOptimizedDispatch​(org.springframework.messaging.Message<?> message)
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getHandlerCount

      public int getHandlerCount()
      Description copied from interface: MessageDispatcher
      Return the current handler count.
      Specified by:
      getHandlerCount in interface MessageDispatcher
      Returns:
      the handler count.