Package org.apache.commons.chain
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
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 TypeMethodDescriptionboolean
postprocess
(C context, Exception exception) Execute any cleanup activities, such as releasing resources that were acquired during theexecute()
method of thisFilter
instance.
-
Method Details
-
postprocess
Execute any cleanup activities, such as releasing resources that were acquired during theexecute()
method of thisFilter
instance.- Parameters:
context
- TheContext
to be processed by thisFilter
exception
- TheException
(if any) that was thrown by the lastCommand
that was executed; otherwisenull
- Returns:
- If a non-null
exception
was "handled" by this method (and therefore need not be rethrown), returntrue
; otherwise returnfalse
- Throws:
IllegalArgumentException
- ifcontext
isnull
-