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 ofIoHandlerCommands.- Author:
- Apache MINA Project
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classIoHandlerChain.EntryRepresents a name-command pair that anIoHandlerChaincontains.-
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 ofIoHandlerCommands.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAfter(String baseName, String name, IoHandlerCommand command)Adds a name-command after a given name-command in the chainvoidaddBefore(String baseName, String name, IoHandlerCommand command)Adds a name-command before a given name-command in the chainvoidaddFirst(String name, IoHandlerCommand command)Adds a name-command pair into the chainvoidaddLast(String name, IoHandlerCommand command)Adds a name-command at the end of the chainvoidclear()Remove all theIoHandlerCommandfrom the chainbooleancontains(Class<? extends IoHandlerCommand> commandType)Checks if the chain ofIoHandlerCommandcontains a specificIoHandlerCommandbooleancontains(String name)Checks if the chain ofIoHandlerCommandcontains aIoHandlerCommandby its namebooleancontains(IoHandlerCommand command)Checks if the chain ofIoHandlerCommandcontains a specificIoHandlerCommandvoidexecute(IoHandlerCommand.NextCommand next, IoSession session, Object message)Execute a unit of processing work to be performed.IoHandlerCommandget(String name)Retrieve aIoHandlerCommandby its nameList<IoHandlerChain.Entry>getAll()List<IoHandlerChain.Entry>getAllReversed()IoHandlerChain.EntrygetEntry(String name)Retrieve a name-command pair by its nameIoHandlerCommand.NextCommandgetNextCommand(String name)Retrieve theIoHandlerCommandfollowing theIoHandlerCommandwe fetched by its nameIoHandlerCommandremove(String name)Removes aIoHandlerCommandby its nameStringtoString()
-
-
-
Constructor Detail
-
IoHandlerChain
public IoHandlerChain()
Creates a new, empty chain ofIoHandlerCommands.
-
-
Method Detail
-
getEntry
public IoHandlerChain.Entry getEntry(String name)
Retrieve a name-command pair by its name- Parameters:
name- The name of theIoHandlerCommandwe are looking for- Returns:
- The associated name-command pair, if any, null otherwise
-
get
public IoHandlerCommand get(String name)
Retrieve aIoHandlerCommandby its name- Parameters:
name- The name of theIoHandlerCommandwe are looking for- Returns:
- The associated
IoHandlerCommand, if any, null otherwise
-
getNextCommand
public IoHandlerCommand.NextCommand getNextCommand(String name)
Retrieve theIoHandlerCommandfollowing theIoHandlerCommandwe fetched by its name- Parameters:
name- The name of theIoHandlerCommand- Returns:
- The
IoHandlerCommandwhich 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- TheIoHandlerCommandname after which we will inject a new name-commandname- The name The namecommand- The command The command
-
remove
public IoHandlerCommand remove(String name)
Removes aIoHandlerCommandby its name- Parameters:
name- The name- Returns:
- The removed
IoHandlerCommand
-
clear
public void clear() throws ExceptionRemove all theIoHandlerCommandfrom 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
IoHandlerCommandmay either complete the required processing and just return to stop the processing, or delegate remaining processing to the nextIoHandlerCommandin aIoHandlerChaincontaining thisIoHandlerCommandby callingIoHandlerCommand.NextCommand.execute(IoSession,Object).- Specified by:
executein interfaceIoHandlerCommand- Parameters:
next- an indirect reference to the nextIoHandlerCommandthat provides a way to forward the request to the nextIoHandlerCommand.session- theIoSessionwhich 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 ofIoHandlerCommandcontains aIoHandlerCommandby its name- Parameters:
name- TheIoHandlerCommandname- Returns:
TRUEif theIoHandlerCommandis found in the chain
-
contains
public boolean contains(IoHandlerCommand command)
Checks if the chain ofIoHandlerCommandcontains a specificIoHandlerCommand- Parameters:
command- TheIoHandlerCommandwe are looking for- Returns:
TRUEif theIoHandlerCommandis found in the chain
-
contains
public boolean contains(Class<? extends IoHandlerCommand> commandType)
Checks if the chain ofIoHandlerCommandcontains a specificIoHandlerCommand- Parameters:
commandType- The type ofIoHandlerCommandwe are looking for- Returns:
TRUEif theIoHandlerCommandis found in the chain
-
-