org.apache.struts.chain.commands
Class ExceptionCatcher

java.lang.Object
  extended by org.apache.struts.chain.commands.ActionCommandBase
      extended by org.apache.struts.chain.commands.ExceptionCatcher
All Implemented Interfaces:
org.apache.commons.chain.Command, org.apache.commons.chain.Filter, ActionCommand

public class ExceptionCatcher
extends ActionCommandBase
implements org.apache.commons.chain.Filter

Intercept any exception thrown by a subsequent Command in this processing chain, and fire the configured exception handler chain after storing the exception that has occurred into the Context.

Version:
$Rev: 471754 $ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005) $

Field Summary
 
Fields inherited from interface org.apache.commons.chain.Command
CONTINUE_PROCESSING, PROCESSING_COMPLETE
 
Constructor Summary
ExceptionCatcher()
           
 
Method Summary
 boolean execute(ActionContext actionCtx)
          Clear any existing stored exception and pass the context on to the remainder of the current chain.
 java.lang.String getCatalogName()
           Return the name of the Catalog in which to perform lookups, or null for the default Catalog.
 java.lang.String getExceptionCommand()
           Return the name of the command to be executed if an exception occurs.
protected  org.apache.commons.chain.Command lookupExceptionCommand()
           Return the command to be executed if an exception occurs.
 boolean postprocess(org.apache.commons.chain.Context context, java.lang.Exception exception)
          If an exception was thrown by a subsequent Command, pass it on to the specified exception handling chain.
 void setCatalogName(java.lang.String catalogName)
          Set the name of the Catalog in which to perform lookups, or null for the default Catalog.
 void setExceptionCommand(java.lang.String exceptionCommand)
          Set the name of the command to be executed if an exception occurs.
 
Methods inherited from class org.apache.struts.chain.commands.ActionCommandBase
execute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.chain.Command
execute
 

Constructor Detail

ExceptionCatcher

public ExceptionCatcher()
Method Detail

getCatalogName

public java.lang.String getCatalogName()

Return the name of the Catalog in which to perform lookups, or null for the default Catalog.

Returns:
Name of catalog to use, or null

setCatalogName

public void setCatalogName(java.lang.String catalogName)

Set the name of the Catalog in which to perform lookups, or null for the default Catalog.

Parameters:
catalogName - The new catalog name or null

getExceptionCommand

public java.lang.String getExceptionCommand()

Return the name of the command to be executed if an exception occurs.

Returns:
The name of the command to be executed on an exception

setExceptionCommand

public void setExceptionCommand(java.lang.String exceptionCommand)

Set the name of the command to be executed if an exception occurs.

Parameters:
exceptionCommand - The name of the chain to be executed

execute

public boolean execute(ActionContext actionCtx)
                throws java.lang.Exception

Clear any existing stored exception and pass the context on to the remainder of the current chain.

Specified by:
execute in interface ActionCommand
Specified by:
execute in class ActionCommandBase
Parameters:
actionCtx - The Context for the current request
Returns:
false so that processing continues
Throws:
java.lang.Exception - On any error

postprocess

public boolean postprocess(org.apache.commons.chain.Context context,
                           java.lang.Exception exception)

If an exception was thrown by a subsequent Command, pass it on to the specified exception handling chain. Otherwise, do nothing.

Specified by:
postprocess in interface org.apache.commons.chain.Filter
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:
TRUE if post processing an exception occurred and the exception processing chain invoked
Throws:
java.lang.IllegalStateException - If exception throws exception

lookupExceptionCommand

protected org.apache.commons.chain.Command lookupExceptionCommand()

Return the command to be executed if an exception occurs.

Returns:
The command to be executed if an exception occurs
Throws:
java.lang.IllegalArgumentException - If catalog cannot be found
java.lang.IllegalStateException - If command property is not specified


Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.