Package org.apache.mina.handler.chain
Class IoHandlerChain
- java.lang.Object
-
- org.apache.mina.handler.chain.IoHandlerChain
-
- All Implemented Interfaces:
IoHandlerCommand
public class IoHandlerChain extends Object implements IoHandlerCommand
A chain ofIoHandlerCommand
s.- Author:
- Apache MINA Project
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
IoHandlerChain.Entry
Represents a name-command pair that anIoHandlerChain
contains.-
Nested classes/interfaces inherited from interface org.apache.mina.handler.chain.IoHandlerCommand
IoHandlerCommand.NextCommand
-
-
Constructor Summary
Constructors Constructor Description IoHandlerChain()
Creates a new, empty chain ofIoHandlerCommand
s.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAfter(String baseName, String name, IoHandlerCommand command)
Adds a name-command after a given name-command in the chainvoid
addBefore(String baseName, String name, IoHandlerCommand command)
Adds a name-command before a given name-command in the chainvoid
addFirst(String name, IoHandlerCommand command)
Adds a name-command pair into the chainvoid
addLast(String name, IoHandlerCommand command)
Adds a name-command at the end of the chainvoid
clear()
Remove all theIoHandlerCommand
from the chainboolean
contains(Class<? extends IoHandlerCommand> commandType)
Checks if the chain ofIoHandlerCommand
contains a specificIoHandlerCommand
boolean
contains(String name)
Checks if the chain ofIoHandlerCommand
contains aIoHandlerCommand
by its nameboolean
contains(IoHandlerCommand command)
Checks if the chain ofIoHandlerCommand
contains a specificIoHandlerCommand
void
execute(IoHandlerCommand.NextCommand next, IoSession session, Object message)
Execute a unit of processing work to be performed.IoHandlerCommand
get(String name)
Retrieve aIoHandlerCommand
by its nameList<IoHandlerChain.Entry>
getAll()
List<IoHandlerChain.Entry>
getAllReversed()
IoHandlerChain.Entry
getEntry(String name)
Retrieve a name-command pair by its nameIoHandlerCommand.NextCommand
getNextCommand(String name)
Retrieve theIoHandlerCommand
following theIoHandlerCommand
we fetched by its nameIoHandlerCommand
remove(String name)
Removes aIoHandlerCommand
by its nameString
toString()
-
-
-
Constructor Detail
-
IoHandlerChain
public IoHandlerChain()
Creates a new, empty chain ofIoHandlerCommand
s.
-
-
Method Detail
-
getEntry
public IoHandlerChain.Entry getEntry(String name)
Retrieve a name-command pair by its name- Parameters:
name
- The name of theIoHandlerCommand
we are looking for- Returns:
- The associated name-command pair, if any, null otherwise
-
get
public IoHandlerCommand get(String name)
Retrieve aIoHandlerCommand
by its name- Parameters:
name
- The name of theIoHandlerCommand
we are looking for- Returns:
- The associated
IoHandlerCommand
, if any, null otherwise
-
getNextCommand
public IoHandlerCommand.NextCommand getNextCommand(String name)
Retrieve theIoHandlerCommand
following theIoHandlerCommand
we fetched by its name- Parameters:
name
- The name of theIoHandlerCommand
- Returns:
- The
IoHandlerCommand
which is next to teh ngiven name, if any, null otherwise
-
addFirst
public void addFirst(String name, IoHandlerCommand command)
Adds a name-command pair into the chain- Parameters:
name
- The namecommand
- The command
-
addLast
public void addLast(String name, IoHandlerCommand command)
Adds a name-command at the end of the chain- Parameters:
name
- The namecommand
- The command
-
addBefore
public void addBefore(String baseName, 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-commandname
- The name The namecommand
- The command The command
-
addAfter
public void addAfter(String baseName, String name, IoHandlerCommand command)
Adds a name-command after a given name-command in the chain- Parameters:
baseName
- TheIoHandlerCommand
name after which we will inject a new name-commandname
- The name The namecommand
- The command The command
-
remove
public IoHandlerCommand remove(String name)
Removes aIoHandlerCommand
by its name- Parameters:
name
- The name- Returns:
- The removed
IoHandlerCommand
-
clear
public void clear() throws Exception
Remove all theIoHandlerCommand
from the chain- Throws:
Exception
- If we faced some exception during the cleanup
-
execute
public void execute(IoHandlerCommand.NextCommand next, IoSession session, Object message) throws Exception
Execute a unit of processing work to be performed. This
IoHandlerCommand
may either complete the required processing and just return to stop the processing, or delegate remaining processing to the nextIoHandlerCommand
in aIoHandlerChain
containing thisIoHandlerCommand
by callingIoHandlerCommand.NextCommand.execute(IoSession,Object)
.- Specified by:
execute
in interfaceIoHandlerCommand
- Parameters:
next
- an indirect reference to the nextIoHandlerCommand
that provides a way to forward the request to the nextIoHandlerCommand
.session
- theIoSession
which is associated with this requestmessage
- the message object of this request- Throws:
Exception
- general purpose exception return to indicate abnormal termination
-
getAll
public List<IoHandlerChain.Entry> getAll()
- Returns:
- The list of name-commands registered into the chain
-
getAllReversed
public List<IoHandlerChain.Entry> getAllReversed()
- Returns:
- A reverted list of the registered name-commands
-
contains
public boolean contains(String name)
Checks if the chain ofIoHandlerCommand
contains aIoHandlerCommand
by its name- Parameters:
name
- TheIoHandlerCommand
name- Returns:
TRUE
if theIoHandlerCommand
is found in the chain
-
contains
public boolean contains(IoHandlerCommand command)
Checks if the chain ofIoHandlerCommand
contains a specificIoHandlerCommand
- Parameters:
command
- TheIoHandlerCommand
we are looking for- Returns:
TRUE
if theIoHandlerCommand
is found in the chain
-
contains
public boolean contains(Class<? extends IoHandlerCommand> commandType)
Checks if the chain ofIoHandlerCommand
contains a specificIoHandlerCommand
- Parameters:
commandType
- The type ofIoHandlerCommand
we are looking for- Returns:
TRUE
if theIoHandlerCommand
is found in the chain
-
-