org.apache.commons.chain.impl
Class ChainBase

java.lang.Object
  extended by org.apache.commons.chain.impl.ChainBase
All Implemented Interfaces:
Chain, Command

public class ChainBase
extends Object
implements Chain

Convenience base class for Chain implementations.

Version:
$Revision: 480477 $ $Date: 2006-11-29 08:34:52 +0000 (Wed, 29 Nov 2006) $
Author:
Craig R. McClanahan

Field Summary
protected  Command[] commands
          The list of Commands configured for this Chain, in the order in which they may delegate processing to the remainder of the Chain.
protected  boolean frozen
          Flag indicating whether the configuration of our commands list has been frozen by a call to the execute() method.
 
Fields inherited from interface org.apache.commons.chain.Command
CONTINUE_PROCESSING, PROCESSING_COMPLETE
 
Constructor Summary
ChainBase()
          Construct a Chain with no configured Commands.
ChainBase(Collection commands)
          Construct a Chain configured with the specified Commands.
ChainBase(Command command)
          Construct a Chain configured with the specified Command.
ChainBase(Command[] commands)
          Construct a Chain configured with the specified Commands.
 
Method Summary
 void addCommand(Command command)
          See the Chain JavaDoc.
 boolean execute(Context context)
          See the Chain JavaDoc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commands

protected Command[] commands

The list of Commands configured for this Chain, in the order in which they may delegate processing to the remainder of the Chain.


frozen

protected boolean frozen

Flag indicating whether the configuration of our commands list has been frozen by a call to the execute() method.

Constructor Detail

ChainBase

public ChainBase()

Construct a Chain with no configured Commands.


ChainBase

public ChainBase(Command command)

Construct a Chain configured with the specified Command.

Parameters:
command - The Command to be configured
Throws:
IllegalArgumentException - if command is null

ChainBase

public ChainBase(Command[] commands)

Construct a Chain configured with the specified Commands.

Parameters:
commands - The Commands to be configured
Throws:
IllegalArgumentException - if commands, or one of the individual Command elements, is null

ChainBase

public ChainBase(Collection commands)

Construct a Chain configured with the specified Commands.

Parameters:
commands - The Commands to be configured
Throws:
IllegalArgumentException - if commands, or one of the individual Command elements, is null
Method Detail

addCommand

public void addCommand(Command command)
See the Chain JavaDoc.

Specified by:
addCommand in interface Chain
Parameters:
command - The Command to be added
Throws:
IllegalArgumentException - if command is null
IllegalStateException - if no further configuration is allowed

execute

public boolean execute(Context context)
                throws Exception
See the Chain JavaDoc.

Specified by:
execute in interface Chain
Specified by:
execute in interface Command
Parameters:
context - The Context to be processed by this Chain
Returns:
true if the processing of this Context has been completed, or false if the processing of this Context should be delegated to a subsequent Command in an enclosing Chain
Throws:
Exception - if thrown by one of the Commands in this Chain but not handled by a postprocess() method of a Filter
IllegalArgumentException - if context is null


Copyright 2003-2008 The Apache Software Foundation. All Rights Reserved.