public class Transition extends AnnotatedObject implements 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.
TransitionableState,
TransitionCriteria,
TargetStateResolver| Modifier and Type | Field and Description |
|---|---|
protected org.apache.commons.logging.Log |
logger
Logger, for use in subclasses.
|
CAPTION_PROPERTY, DESCRIPTION_PROPERTY| Constructor and Description |
|---|
Transition()
Create 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.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
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.
|
TransitionCriteria |
getExecutionCriteria()
Returns the criteria that determine whether or not this transition, once matched, should complete execution or
should roll back.
|
java.lang.String |
getId()
The identifier of this transition.
|
TransitionCriteria |
getMatchingCriteria()
Returns the criteria that determine whether or not this transition matches as eligible for execution.
|
java.lang.String |
getTargetStateId()
Returns an identification of the target state of this transition.
|
TargetStateResolver |
getTargetStateResolver()
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.
|
java.lang.String |
toString() |
getAttributes, getCaption, getDescription, setCaption, setDescriptionclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetAttributes, getCaption, getDescriptionprotected final org.apache.commons.logging.Log logger
public Transition()
public Transition(TargetStateResolver targetStateResolver)
targetStateResolver - the resolver of the target state of this transitionsetMatchingCriteria(TransitionCriteria),
setExecutionCriteria(TransitionCriteria)public Transition(TransitionCriteria matchingCriteria, TargetStateResolver targetStateResolver)
matchingCriteria - the criteria for matching this transitiontargetStateResolver - the resolver of the target state of this transitionsetExecutionCriteria(TransitionCriteria)public java.lang.String getId()
TransitionDefinitiongetId in interface TransitionDefinitionpublic java.lang.String getTargetStateId()
TransitionDefinitiongetTargetStateId in interface TransitionDefinitionpublic TransitionCriteria getMatchingCriteria()
public void setMatchingCriteria(TransitionCriteria matchingCriteria)
matchingCriteria - the transition matching criteriapublic TransitionCriteria getExecutionCriteria()
public void setExecutionCriteria(TransitionCriteria executionCriteria)
executionCriteria - the transition execution criteriapublic TargetStateResolver getTargetStateResolver()
public void setTargetStateResolver(TargetStateResolver targetStateResolver)
targetStateResolver - the target state resolverpublic boolean matches(RequestContext context)
context - the flow execution request contextpublic boolean canExecute(RequestContext context)
context - the flow execution request contextpublic boolean execute(State sourceState, RequestControlContext context) throws FlowExecutionException
matches(RequestContext) method returns true
for the given context.sourceState - the source state to transition from, may be null if the current state is nullcontext - the flow execution control contextFlowExecutionException - when transition execution failspublic java.lang.String toString()
toString in class java.lang.Object