public class ProxyProcessingChain
extends org.apache.commons.chain.impl.ChainBase
Convenience base class for reverse proxy processing Chain
implementation.
Constructor and Description |
---|
ProxyProcessingChain()
Constructs a
ProxyProcessingChain with no configured Command s. |
ProxyProcessingChain(Collection commands)
Constructs a
ProxyProcessingChain configured with the specified
Command s. |
ProxyProcessingChain(org.apache.commons.chain.Command command)
Constructs a
ProxyProcessingChain configured with the specified
Command . |
ProxyProcessingChain(org.apache.commons.chain.Command[] commands)
Constructs a
ProxyProcessingChain configured with the specified
Command s. |
Modifier and Type | Method and Description |
---|---|
void |
addCommand(int index,
org.apache.commons.chain.Command command)
Add a
Command at the given index of the list of
Command s that will be called in turn when this Chain 's
execute() method is called. |
boolean |
execute(org.apache.commons.chain.Context context) |
List<AbstractProxyCommand> |
getAllProxyCommands()
Return a list including all the descendant
Command s,
type of which is AbstractProxyCommand
in this proxy processing chain. |
org.apache.commons.chain.Command |
getCommand(int index)
Finds and returns the
Command at the given index of the Command list. |
int |
getCommandCount()
Return the size of the internal
Command list. |
int |
getCommandIndex(Class<? extends org.apache.commons.chain.Command> commandType)
Return the index of the given class type of
Command in the command list. |
int |
getCommandIndex(org.apache.commons.chain.Command command)
Return the index of the given
Command in the command list. |
boolean |
removeCommand(org.apache.commons.chain.Command command)
Remove the
Command from the list of
Command s that will be called in turn when this Chain 's
execute() method is called. |
boolean |
removeCommand(int index)
Remove the
Command at the given index of the list of
Command s that will be called in turn when this Chain 's
execute() method is called. |
public ProxyProcessingChain()
ProxyProcessingChain
with no configured Command
s.public ProxyProcessingChain(org.apache.commons.chain.Command command)
ProxyProcessingChain
configured with the specified
Command
.command
- public ProxyProcessingChain(org.apache.commons.chain.Command[] commands)
ProxyProcessingChain
configured with the specified
Command
s.commands
- public ProxyProcessingChain(Collection commands)
ProxyProcessingChain
configured with the specified
Command
s.commands
- public int getCommandCount()
Command
list.public int getCommandIndex(org.apache.commons.chain.Command command)
Command
in the command list.
If not found, it should return -1.command
- public int getCommandIndex(Class<? extends org.apache.commons.chain.Command> commandType)
Command
in the command list.
If not found, it should return -1.commandType
- public org.apache.commons.chain.Command getCommand(int index)
Command
at the given index
of the Command
list.index
- public void addCommand(int index, org.apache.commons.chain.Command command)
Add a Command
at the given index
of the list of
Command
s that will be called in turn when this Chain
's
execute()
method is called.
Once execute()
has been called
at least once, it is no longer possible to add additional
Command
s; instead, an exception will be thrown.
index
- The index at which the command should be insertedcommand
- The Command
to be addedIllegalArgumentException
- if command
is null
, or
index
is negative or greater than the size of the command list.IllegalStateException
- if this Chain
has already
been executed at least once, so no further configuration is allowedpublic boolean removeCommand(int index)
Remove the Command
at the given index
of the list of
Command
s that will be called in turn when this Chain
's
execute()
method is called.
Once execute()
has been called
at least once, it is no longer possible to add additional
Command
s; instead, an exception will be thrown.
index
- The index to add in the command listIllegalArgumentException
- if index
is out of bound.IllegalStateException
- if this Chain
has already
been executed at least once, so no further configuration is allowedpublic boolean removeCommand(org.apache.commons.chain.Command command)
Remove the Command
from the list of
Command
s that will be called in turn when this Chain
's
execute()
method is called.
Once execute()
has been called
at least once, it is no longer possible to add additional
Command
s; instead, an exception will be thrown.
command
- The Command
to be addedIllegalArgumentException
- if index
is out of bound.IllegalStateException
- if this Chain
has already
been executed at least once, so no further configuration is allowedpublic boolean execute(org.apache.commons.chain.Context context) throws ReverseProxyException, IOException
Note: The method implementation takes the strategy to catch all the exceptions thrown while executing commands in the chain in order to proceed to the next commands even when a command throws an exception in an earlier step. This guarantees each of the internal commands are always to execute. So, for example, a command, which is responsible for cleaning up all the resources used during the reverse proxy processing, will always have a chance to do its job in this reverse proxy processing chain.
execute
in interface org.apache.commons.chain.Chain
execute
in interface org.apache.commons.chain.Command
execute
in class org.apache.commons.chain.impl.ChainBase
ReverseProxyException
IOException
public List<AbstractProxyCommand> getAllProxyCommands()
Command
s,
type of which is AbstractProxyCommand
in this proxy processing chain.Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.