org.springframework.webflow.engine.support
Class TransitionExecutingStateExceptionHandler

java.lang.Object
  extended by org.springframework.webflow.engine.support.TransitionExecutingStateExceptionHandler
All Implemented Interfaces:
FlowExecutionExceptionHandler

public class TransitionExecutingStateExceptionHandler
extends java.lang.Object
implements FlowExecutionExceptionHandler

A flow execution exception handler that maps the occurence of a specific type of exception to a transition to a new State.

The handled FlowExecutionException will be exposed in flash scope as STATE_EXCEPTION_ATTRIBUTE. The underlying root cause of that exception will be exposed in flash scope as ROOT_CAUSE_EXCEPTION_ATTRIBUTE.

Author:
Keith Donald

Field Summary
static java.lang.String ROOT_CAUSE_EXCEPTION_ATTRIBUTE
          The name of the attribute to expose a root cause of a handled exception under in flash scope ("rootCauseException").
static java.lang.String STATE_EXCEPTION_ATTRIBUTE
          The name of the attribute to expose a handled exception under in flash scope ("stateException").
 
Constructor Summary
TransitionExecutingStateExceptionHandler()
           
 
Method Summary
 TransitionExecutingStateExceptionHandler add(java.lang.Class exceptionClass, java.lang.String targetStateId)
          Adds an exception->state mapping to this handler.
 TransitionExecutingStateExceptionHandler add(java.lang.Class exceptionClass, TargetStateResolver targetStateResolver)
          Adds a exception->state mapping to this handler.
protected  void exposeException(RequestContext context, FlowExecutionException exception, java.lang.Throwable rootCause)
          Exposes the given flow exception and root cause in flash scope to make them available for response rendering.
protected  java.lang.Throwable findRootCause(java.lang.Throwable t)
          Find the root cause of given throwable.
 ActionList getActionList()
          Returns the list of actions to execute when this handler handles an exception.
protected  TargetStateResolver getTargetStateResolver(FlowExecutionException e)
          Find the mapped target state resolver for given exception.
 ViewSelection handle(FlowExecutionException exception, RequestControlContext context)
          Handle the exception in the context of the current request, optionally making an error view selection that should be rendered.
 boolean handles(FlowExecutionException e)
          Can this handler handle the given exception?
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATE_EXCEPTION_ATTRIBUTE

public static final java.lang.String STATE_EXCEPTION_ATTRIBUTE
The name of the attribute to expose a handled exception under in flash scope ("stateException").

See Also:
Constant Field Values

ROOT_CAUSE_EXCEPTION_ATTRIBUTE

public static final java.lang.String ROOT_CAUSE_EXCEPTION_ATTRIBUTE
The name of the attribute to expose a root cause of a handled exception under in flash scope ("rootCauseException").

See Also:
Constant Field Values
Constructor Detail

TransitionExecutingStateExceptionHandler

public TransitionExecutingStateExceptionHandler()
Method Detail

add

public TransitionExecutingStateExceptionHandler add(java.lang.Class exceptionClass,
                                                    java.lang.String targetStateId)
Adds an exception->state mapping to this handler.

Parameters:
exceptionClass - the type of exception to map
targetStateId - the id of the state to transition to if the specified type of exception is handled
Returns:
this handler, to allow for adding multiple mappings in a single statement

add

public TransitionExecutingStateExceptionHandler add(java.lang.Class exceptionClass,
                                                    TargetStateResolver targetStateResolver)
Adds a exception->state mapping to this handler.

Parameters:
exceptionClass - the type of exception to map
targetStateResolver - the resolver to calculate the state to transition to if the specified type of exception is handled
Returns:
this handler, to allow for adding multiple mappings in a single statement

getActionList

public ActionList getActionList()
Returns the list of actions to execute when this handler handles an exception. The returned list is mutable.


handles

public boolean handles(FlowExecutionException e)
Description copied from interface: FlowExecutionExceptionHandler
Can this handler handle the given exception?

Specified by:
handles in interface FlowExecutionExceptionHandler
Parameters:
e - the exception that occured
Returns:
true if yes, false if no

handle

public ViewSelection handle(FlowExecutionException exception,
                            RequestControlContext context)
Description copied from interface: FlowExecutionExceptionHandler
Handle the exception in the context of the current request, optionally making an error view selection that should be rendered.

Specified by:
handle in interface FlowExecutionExceptionHandler
Parameters:
exception - the exception that occured
context - the execution control context for this request
Returns:
the selected error view that should be displayed (may be null if the handler chooses not to select a view, in which case other exception handlers may be given a chance to handle the exception)

exposeException

protected void exposeException(RequestContext context,
                               FlowExecutionException exception,
                               java.lang.Throwable rootCause)
Exposes the given flow exception and root cause in flash scope to make them available for response rendering. Subclasses can override this if they want to expose the exceptions in a different way or do special processing before the exceptions are exposed.

Parameters:
context - the request control context
exception - the exception being handled
rootCause - root cause of the exception being handled (could be null)
Since:
1.0.2

getTargetStateResolver

protected TargetStateResolver getTargetStateResolver(FlowExecutionException e)
Find the mapped target state resolver for given exception. Returns null if no mapping can be found for given exception. Will try all exceptions in the exception cause chain.


findRootCause

protected java.lang.Throwable findRootCause(java.lang.Throwable t)
Find the root cause of given throwable.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2004-2007. All Rights Reserved.