Class Transition
- All Implemented Interfaces:
Annotated
,TransitionDefinition
state
to another state
.
When executed a transition takes a flow execution from its current state, called the source state, to another
state, called the target state. A transition may become eligible for execution on the occurrence of an
Event
from within a transitionable source state.
When an event occurs within this transition's source TransitionableState
the determination of the
eligibility of this transition is made by a TransitionCriteria
object called the matching
criteria. If the matching criteria returns true
this transition is marked eligible for execution for
that event.
Determination as to whether an eligible transition should be allowed to execute is made by a
TransitionCriteria
object called the execution criteria. If the execution criteria test fails
this transition will roll back and reenter its source state. If the execution criteria test succeeds this
transition will execute and take the flow to the transition's target state.
The target state of this transition is typically specified at configuration time in a static manner. If the target
state of this transition needs to be calculated in a dynamic fashion at runtime configure a
TargetStateResolver
that supports such calculations.
- Author:
- Keith Donald, Erwin Vervaet
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final org.apache.commons.logging.Log
Logger, for use in subclasses.Fields inherited from class org.springframework.webflow.core.AnnotatedObject
CAPTION_PROPERTY, DESCRIPTION_PROPERTY
-
Constructor Summary
ConstructorDescriptionCreate a new transition that always matches and always executes, but its execution does nothing by default.Transition
(TargetStateResolver targetStateResolver) Create a new transition that always matches and always executes, transitioning to the target state calculated by the provided targetStateResolver.Transition
(TransitionCriteria matchingCriteria, TargetStateResolver targetStateResolver) Create a new transition that matches on the specified criteria, transitioning to the target state calculated by the provided targetStateResolver. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canExecute
(RequestContext context) Checks if this transition can complete its execution or should be rolled back, given the state of the flow execution request context.boolean
execute
(State sourceState, RequestControlContext context) Execute this state transition.Returns the criteria that determine whether or not this transition, once matched, should complete execution or should roll back.getId()
The identifier of this transition.Returns the criteria that determine whether or not this transition matches as eligible for execution.Returns an identification of the target state of this transition.Returns this transition's target state resolver.boolean
matches
(RequestContext context) Checks if this transition is eligible for execution given the state of the provided flow execution request context.void
setExecutionCriteria
(TransitionCriteria executionCriteria) Set the criteria that determine whether or not this transition, once matched, should complete execution or should roll back.void
setMatchingCriteria
(TransitionCriteria matchingCriteria) Set the criteria that determine whether or not this transition matches as eligible for execution.void
setTargetStateResolver
(TargetStateResolver targetStateResolver) Set this transition's target state resolver, to calculate what state to transition to when this transition is executed.toString()
Methods inherited from class org.springframework.webflow.core.AnnotatedObject
getAttributes, getCaption, getDescription, setCaption, setDescription
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.webflow.core.Annotated
getAttributes, getCaption, getDescription
-
Field Details
-
logger
protected final org.apache.commons.logging.Log loggerLogger, for use in subclasses.
-
-
Constructor Details
-
Transition
public Transition()Create a new transition that always matches and always executes, but its execution does nothing by default. -
Transition
Create a new transition that always matches and always executes, transitioning to the target state calculated by the provided targetStateResolver.- Parameters:
targetStateResolver
- the resolver of the target state of this transition- See Also:
-
Transition
Create a new transition that matches on the specified criteria, transitioning to the target state calculated by the provided targetStateResolver.- Parameters:
matchingCriteria
- the criteria for matching this transitiontargetStateResolver
- the resolver of the target state of this transition- See Also:
-
-
Method Details
-
getId
Description copied from interface:TransitionDefinition
The identifier of this transition. This id value should be unique among all other transitions in a set.- Specified by:
getId
in interfaceTransitionDefinition
- Returns:
- the transition identifier
-
getTargetStateId
Description copied from interface:TransitionDefinition
Returns an identification of the target state of this transition. This could be an actual static state id or something more dynamic, like a string representation of an expression evaluating the target state id at flow execution time.- Specified by:
getTargetStateId
in interfaceTransitionDefinition
- Returns:
- the target state identifier
-
getMatchingCriteria
Returns the criteria that determine whether or not this transition matches as eligible for execution.- Returns:
- the transition matching criteria
-
setMatchingCriteria
Set the criteria that determine whether or not this transition matches as eligible for execution.- Parameters:
matchingCriteria
- the transition matching criteria
-
getExecutionCriteria
Returns the criteria that determine whether or not this transition, once matched, should complete execution or should roll back.- Returns:
- the transition execution criteria
-
setExecutionCriteria
Set the criteria that determine whether or not this transition, once matched, should complete execution or should roll back.- Parameters:
executionCriteria
- the transition execution criteria
-
getTargetStateResolver
Returns this transition's target state resolver. -
setTargetStateResolver
Set this transition's target state resolver, to calculate what state to transition to when this transition is executed.- Parameters:
targetStateResolver
- the target state resolver
-
matches
Checks if this transition is eligible for execution given the state of the provided flow execution request context.- Parameters:
context
- the flow execution request context- Returns:
- true if this transition should execute, false otherwise
-
canExecute
Checks if this transition can complete its execution or should be rolled back, given the state of the flow execution request context.- Parameters:
context
- the flow execution request context- Returns:
- true if this transition can complete execution, false if it should roll back
-
execute
public boolean execute(State sourceState, RequestControlContext context) throws FlowExecutionException Execute this state transition. Should only be called if thematches(RequestContext)
method returns true for the given context.- Parameters:
sourceState
- the source state to transition from, may be null if the current state is nullcontext
- the flow execution control context- Returns:
- a boolean indicating if executing this transition caused the current state to exit and a new state to enter
- Throws:
FlowExecutionException
- when transition execution fails
-
toString
-