Class MessageHandlerManager


  • public class MessageHandlerManager
    extends java.lang.Object
    Manages registered MessageHandlers and checks whether the new ones may be registered.
    Author:
    Stepan Kopriva, Pavel Bucek
    See Also:
    MessageHandler, OnMessage
    • Constructor Detail

      • MessageHandlerManager

        public MessageHandlerManager()
        Construct manager with no decoders.
    • Method Detail

      • fromDecoderClasses

        public static MessageHandlerManager fromDecoderClasses​(java.util.List<java.lang.Class<? extends Decoder>> decoderClasses)
        Construct manager.
        Parameters:
        decoderClasses - registered Decoders.
        Returns:
        constructed message handler manager.
      • addMessageHandler

        public void addMessageHandler​(MessageHandler handler)
                               throws java.lang.IllegalStateException
        Add MessageHandler to the manager.
        Parameters:
        handler - MessageHandler to be added to the manager.
        Throws:
        java.lang.IllegalStateException
      • addMessageHandler

        public <T> void addMessageHandler​(java.lang.Class<T> clazz,
                                          MessageHandler.Whole<T> handler)
                                   throws java.lang.IllegalStateException
        Add MessageHandler.Whole to the manager.
        Type Parameters:
        T - type of message to be handled.
        Parameters:
        clazz - type handled by MessageHandler.
        handler - MessageHandler to be added.
        Throws:
        java.lang.IllegalStateException - when the message handler cannot be added.
      • addMessageHandler

        public <T> void addMessageHandler​(java.lang.Class<T> clazz,
                                          MessageHandler.Partial<T> handler)
                                   throws java.lang.IllegalStateException
        Add MessageHandler.Partial to the manager.
        Type Parameters:
        T - type of message to be handled.
        Parameters:
        clazz - type handled by MessageHandler.
        handler - MessageHandler to be added.
        Throws:
        java.lang.IllegalStateException - when the message handler cannot be added.
      • removeMessageHandler

        public void removeMessageHandler​(MessageHandler handler)
        Remove MessageHandler from the manager.
        Parameters:
        handler - handler which will be removed.
      • getOrderedWholeMessageHandlers

        public java.util.List<java.util.Map.Entry<java.lang.Class<?>,​MessageHandler>> getOrderedWholeMessageHandlers()
      • isReaderHandlerPresent

        public boolean isReaderHandlerPresent()
      • isInputStreamHandlerPresent

        public boolean isInputStreamHandlerPresent()