Interface Filter<C extends Context>

Type Parameters:
C - Type of the context associated with this command
All Superinterfaces:
Command<C>
All Known Implementing Classes:
DispatchLookupCommand, LookupCommand, PathInfoMapper, PathInfoMapper, RequestParameterMapper, RequestParameterMapper, ServletPathMapper, ServletPathMapper

public interface Filter<C extends Context> extends Command<C>
A Filter is a specialized Command that also expects the Chain that is executing it to call the postprocess() method if it called the execute() method. This promise must be fulfilled in spite of any possible exceptions thrown by the execute() method of this Command, or any subsequent Command whose execute() method was called. The owning Chain must call the postprocess() method of each Filter in a Chain in reverse order of the invocation of their execute() methods.

The most common use case for a Filter, as opposed to a Command, is where potentially expensive resources must be acquired and held until the processing of a particular request has been completed, even if execution is delegated to a subsequent Command via the execute() returning false. A Filter can reliably release such resources in the postprocess() method, which is guaranteed to be called by the owning Chain.

Version:
$Revision$ $Date$
Author:
Craig R. McClanahan
  • Field Summary

    Fields inherited from interface org.apache.commons.chain.Command

    CONTINUE_PROCESSING, PROCESSING_COMPLETE
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    postprocess(C context, Exception exception)
    Execute any cleanup activities, such as releasing resources that were acquired during the execute() method of this Filter instance.

    Methods inherited from interface org.apache.commons.chain.Command

    execute
  • Method Details

    • postprocess

      boolean postprocess(C context, Exception exception)
      Execute any cleanup activities, such as releasing resources that were acquired during the execute() method of this Filter instance.
      Parameters:
      context - The Context to be processed by this Filter
      exception - The Exception (if any) that was thrown by the last Command that was executed; otherwise null
      Returns:
      If a non-null exception was "handled" by this method (and therefore need not be rethrown), return true; otherwise return false
      Throws:
      IllegalArgumentException - if context is null