Class IoHandlerChain

    • Field Detail

      • nextId

        private static volatile int nextId
      • id

        private final int id
      • NEXT_COMMAND

        private final java.lang.String NEXT_COMMAND
    • Constructor Detail

      • IoHandlerChain

        public IoHandlerChain()
        Creates a new, empty chain of IoHandlerCommands.
    • Method Detail

      • getEntry

        public IoHandlerChain.Entry getEntry​(java.lang.String name)
        Retrieve a name-command pair by its name
        Parameters:
        name - The name of the IoHandlerCommand we are looking for
        Returns:
        The associated name-command pair, if any, null otherwise
      • addFirst

        public void addFirst​(java.lang.String name,
                             IoHandlerCommand command)
        Adds a name-command pair into the chain
        Parameters:
        name - The name
        command - The command
      • addLast

        public void addLast​(java.lang.String name,
                            IoHandlerCommand command)
        Adds a name-command at the end of the chain
        Parameters:
        name - The name
        command - The command
      • addBefore

        public void addBefore​(java.lang.String baseName,
                              java.lang.String name,
                              IoHandlerCommand command)
        Adds a name-command before a given name-command in the chain
        Parameters:
        baseName - The IoHandlerCommand name before which we will inject a new name-command
        name - The name The name
        command - The command The command
      • addAfter

        public void addAfter​(java.lang.String baseName,
                             java.lang.String name,
                             IoHandlerCommand command)
        Adds a name-command after a given name-command in the chain
        Parameters:
        baseName - The IoHandlerCommand name after which we will inject a new name-command
        name - The name The name
        command - The command The command
      • clear

        public void clear()
                   throws java.lang.Exception
        Remove all the IoHandlerCommand from the chain
        Throws:
        java.lang.Exception - If we faced some exception during the cleanup
      • checkOldName

        private IoHandlerChain.Entry checkOldName​(java.lang.String baseName)
        Throws an exception when the specified filter name is not registered in this chain.
        Returns:
        An filter entry with the specified name.
      • checkAddable

        private void checkAddable​(java.lang.String name)
        Checks the specified filter name is already taken and throws an exception if already taken.
      • callNextCommand

        private void callNextCommand​(IoHandlerChain.Entry entry,
                                     IoSession session,
                                     java.lang.Object message)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getAll

        public java.util.List<IoHandlerChain.Entry> getAll()
        Returns:
        The list of name-commands registered into the chain
      • getAllReversed

        public java.util.List<IoHandlerChain.Entry> getAllReversed()
        Returns:
        A reverted list of the registered name-commands
      • toString

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