org.apache.commons.chain
Interface Filter

All Superinterfaces:
Command
All Known Implementing Classes:
DispatchLookupCommand, LookupCommand, PathInfoMapper, RequestParameterMapper, ServletPathMapper

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 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: 480477 $ $Date: 2006-11-29 08:34:52 +0000 (Wed, 29 Nov 2006) $
Author:
Craig R. McClanahan

Field Summary
 
Fields inherited from interface org.apache.commons.chain.Command
CONTINUE_PROCESSING, PROCESSING_COMPLETE
 
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

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-2008 The Apache Software Foundation. All Rights Reserved.