Class IoHandlerChain
java.lang.Object
org.apache.mina.handler.chain.IoHandlerChain
- All Implemented Interfaces:
IoHandlerCommand
A chain of
IoHandlerCommands.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassRepresents a name-command pair that anIoHandlerChaincontains.Nested classes/interfaces inherited from interface IoHandlerCommand
IoHandlerCommand.NextCommand -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IoHandlerChain.EntryThe head of the IoHandlerCommand chainprivate final intprivate final Map<String, IoHandlerChain.Entry> private final Stringprivate static intprivate final IoHandlerChain.EntryTHe tail of the IoHandlerCommand chain -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAfter(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 chainprivate voidcallNextCommand(IoHandlerChain.Entry entry, IoSession session, Object message) private voidcheckAddable(String name) Checks the specified filter name is already taken and throws an exception if already taken.private IoHandlerChain.EntrycheckOldName(String baseName) Throws an exception when the specified filter name is not registered in this chain.voidclear()Remove all theIoHandlerCommandfrom the chainbooleancontains(Class<? extends IoHandlerCommand> commandType) Checks if the chain ofIoHandlerCommandcontains a specificIoHandlerCommandbooleanChecks if the chain ofIoHandlerCommandcontains aIoHandlerCommandby its namebooleancontains(IoHandlerCommand command) Checks if the chain ofIoHandlerCommandcontains a specificIoHandlerCommandprivate IoHandlerCommandprivate IoHandlerCommandprivate voidderegister(IoHandlerChain.Entry entry) voidexecute(IoHandlerCommand.NextCommand next, IoSession session, Object message) Execute a unit of processing work to be performed.Retrieve aIoHandlerCommandby its namegetAll()Retrieve a name-command pair by its namegetNextCommand(String name) Retrieve theIoHandlerCommandfollowing theIoHandlerCommandwe fetched by its nameprivate voidregister(IoHandlerChain.Entry prevEntry, String name, IoHandlerCommand command) Removes aIoHandlerCommandby its nametoString()
-
Field Details
-
nextId
private static volatile int nextId -
id
private final int id -
NEXT_COMMAND
-
name2entry
-
head
The head of the IoHandlerCommand chain -
tail
THe tail of the IoHandlerCommand chain
-
-
Constructor Details
-
IoHandlerChain
public IoHandlerChain()Creates a new, empty chain ofIoHandlerCommands.
-
-
Method Details
-
createHeadCommand
-
createTailCommand
-
getEntry
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
Retrieve aIoHandlerCommandby its name- Parameters:
name- The name of theIoHandlerCommandwe are looking for- Returns:
- The associated
IoHandlerCommand, if any, null otherwise
-
getNextCommand
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
Adds a name-command pair into the chain- Parameters:
name- The namecommand- The command
-
addLast
Adds a name-command at the end of the chain- Parameters:
name- The namecommand- The command
-
addBefore
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
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
Removes aIoHandlerCommandby its name- Parameters:
name- The name- Returns:
- The removed
IoHandlerCommand
-
clear
Remove all theIoHandlerCommandfrom the chain- Throws:
Exception- If we faced some exception during the cleanup
-
register
-
deregister
-
checkOldName
Throws an exception when the specified filter name is not registered in this chain.- Returns:
- An filter entry with the specified name.
-
checkAddable
Checks the specified filter name is already taken and throws an exception if already taken. -
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
-
callNextCommand
private void callNextCommand(IoHandlerChain.Entry entry, IoSession session, Object message) throws Exception - Throws:
Exception
-
getAll
- Returns:
- The list of name-commands registered into the chain
-
getAllReversed
- Returns:
- A reverted list of the registered name-commands
-
contains
Checks if the chain ofIoHandlerCommandcontains aIoHandlerCommandby its name- Parameters:
name- TheIoHandlerCommandname- Returns:
TRUEif theIoHandlerCommandis found in the chain
-
contains
Checks if the chain ofIoHandlerCommandcontains a specificIoHandlerCommand- Parameters:
command- TheIoHandlerCommandwe are looking for- Returns:
TRUEif theIoHandlerCommandis found in the chain
-
contains
Checks if the chain ofIoHandlerCommandcontains a specificIoHandlerCommand- Parameters:
commandType- The type ofIoHandlerCommandwe are looking for- Returns:
TRUEif theIoHandlerCommandis found in the chain
-
toString
-