Class TransitionExecutingFlowExecutionExceptionHandler
java.lang.Object
org.springframework.webflow.engine.support.TransitionExecutingFlowExecutionExceptionHandler
- All Implemented Interfaces:
FlowExecutionExceptionHandler
public class TransitionExecutingFlowExecutionExceptionHandler
extends Object
implements FlowExecutionExceptionHandler
A flow execution exception handler that maps the occurrence of a specific type of exception to a transition to a new
State
.
The handled FlowExecutionException
will be exposed in flash scope as
FLOW_EXECUTION_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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds an exception-to-target state mapping to this handler.add
(Class<? extends Throwable> exceptionClass, TargetStateResolver targetStateResolver) Adds a exception-to-target state resolver mapping to this handler.boolean
Can this handler handle the given exception?protected void
exposeException
(RequestContext context, FlowExecutionException exception, Throwable rootCause) Exposes the given flow exception and root cause in flash scope to make them available for response rendering.Returns the list of actions to execute when this handler handles an exception.protected TargetStateResolver
Find the mapped target state resolver for given exception.void
handle
(FlowExecutionException exception, RequestControlContext context) Handle the exception in the context of the current request.toString()
-
Field Details
-
FLOW_EXECUTION_EXCEPTION_ATTRIBUTE
The name of the attribute to expose a handled exception under in flash scope ("flowExecutionException").- See Also:
-
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:
-
-
Constructor Details
-
TransitionExecutingFlowExecutionExceptionHandler
public TransitionExecutingFlowExecutionExceptionHandler()
-
-
Method Details
-
add
public TransitionExecutingFlowExecutionExceptionHandler add(Class<? extends Throwable> exceptionClass, String targetStateId) Adds an exception-to-target state mapping to this handler.- Parameters:
exceptionClass
- the type of exception to maptargetStateId
- 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 TransitionExecutingFlowExecutionExceptionHandler add(Class<? extends Throwable> exceptionClass, TargetStateResolver targetStateResolver) Adds a exception-to-target state resolver mapping to this handler.- Parameters:
exceptionClass
- the type of exception to maptargetStateResolver
- 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
Returns the list of actions to execute when this handler handles an exception. The returned list is mutable. -
canHandle
Description copied from interface:FlowExecutionExceptionHandler
Can this handler handle the given exception?- Specified by:
canHandle
in interfaceFlowExecutionExceptionHandler
- Parameters:
e
- the exception that occurred- Returns:
- true if yes, false if no
-
handle
Description copied from interface:FlowExecutionExceptionHandler
Handle the exception in the context of the current request. An implementation is expected to transition the flow to a state usingRequestControlContext.execute(Transition)
.- Specified by:
handle
in interfaceFlowExecutionExceptionHandler
- Parameters:
exception
- the exception that occurredcontext
- the execution control context for this request
-
exposeException
protected void exposeException(RequestContext context, FlowExecutionException exception, 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 contextexception
- the exception being handledrootCause
- root cause of the exception being handled (could be null)
-
getTargetStateResolver
Find the mapped target state resolver for given exception. Returnsnull
if no mapping can be found for given exception. Will try all exceptions in the exception cause chain. -
toString
-