Class ChainBase

  • All Implemented Interfaces:
    Chain, Command

    public class ChainBase
    extends java.lang.Object
    implements Chain

    Convenience base class for Chain implementations.

    Version:
    $Revision: 480477 $ $Date: 2006-11-29 08:34:52 +0000 (Wed, 29 Nov 2006) $
    • 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:
        java.lang.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:
        java.lang.IllegalArgumentException - if commands, or one of the individual Command elements, is null
      • ChainBase

        public ChainBase​(java.util.Collection commands)

        Construct a Chain configured with the specified Commands.

        Parameters:
        commands - The Commands to be configured
        Throws:
        java.lang.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:
        java.lang.IllegalArgumentException - if command is null
        java.lang.IllegalStateException - if no further configuration is allowed
      • execute

        public boolean execute​(Context context)
                        throws java.lang.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:
        java.lang.Exception - if thrown by one of the Commands in this Chain but not handled by a postprocess() method of a Filter
        java.lang.IllegalArgumentException - if context is null
      • getCommands

        Command[] getCommands()

        Return an array of the configured Commands for this Chain. This method is package private, and is used only for the unit tests.