org.apache.commons.chain
Interface Filter

All Superinterfaces:
Command
All Known Implementing Classes:
LookupCommand

public interface Filter
extends Command

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 it 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: 1.6 $ $Date: 2004/11/30 05:52:23 $
Author:
Craig R. McClanahan

Method Summary
 boolean postprocess(Context 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 Detail

postprocess

public boolean postprocess(Context 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


Copyright © 2003-2005 The Apache Software Foundation. All Rights Reserved.