Compose your own business state machine using a combination of the following building blocks.
The reference is not
an interface, but instead tells the state machine where to find operations
that it can invoke. More to the point, it specifies the interface that is
used in the invocation of another component.
Variables store the data that are used by a state
machine, and can be either a business object or a simple type.
A correlation set defines properties that are used to distinguish one instance of a state machine from another within a runtime environment.
There are five different kinds of states:
The first state and starting point of any state machine or composite state, the initial state is where things begin.
When used in a primary state machine, an initial state has one outbound transition that defines the operation that starts the state machine.
When used in a composite state, the outbound transition must be automatic.
In both cases, there can be only one outbound transition, and it cannot be guarded.
Use a state to represent an individual discrete stage in your state machine diagram.
A simple state may define both an entry and an exit action, and when it is entered, it enables all of its outbound transitions.
A composite state is an aggregate of two or more states. Use them to decompose a complex state machine diagram into an easy to comprehend hierarchy of state machines. It can also be done to facilitate exception and error handling by making it possible to define a single exception transition that is valid for all states nested within the composite state.
Composite states may define one or more outbound exception transitions, or a single default transition (see definitions below).
When used in a state machine, the final state is where the state machine comes to a normal end.
When it is contained in a composite state, the movement to final state will fire the composite state's default transition.
A final state may define an entry action, but it may not have an exit action.
Use this state to bring a halt to all activity within the state machine. It is an abnormal end to a state machine.
In the main state machine, a terminate state ends the execution. When used within a composite state, a terminate state is used to indicate and abnormal end, and it will cause the whole state machine to stop. A terminate state may define an entry action, but it may not have an exit action.
A transition channels execution from one state to the
next by recognizing the triggering event, evaluating the conditions necessary
for execution to flow through it, and determining what actions can occur should
execution be allowed. An event can trigger more than one transition at a time,
but only one of those transitions will fire.
If an event triggers more than one outbound transition from a given state, the order that the transitions are checked is undefined. In the case of nested composite states, if an event triggers transitions in more than one composite state, the transitions are checked from the innermost composite state to the outermost composite state.
A default transition is an unguarded, automatic transition whose source state is a composite state, and whose trigger is a completion event. A default transition fires whenever a final state within the composite state is entered. If a composite state defines a default transition, it must define a final state and vise versa.
Exception transitions are transitions whose triggering event is either a timer event or a call event, and whose source state is a composite state. Exception transitions are enabled when the composite state is entered and triggered when their triggering event occurs, regardless of which substate the composite state is in. If a substate defines a transition with the same triggering event, the guard, if any, of that transition will be checked before the exception transition. That is, transitions fire from the inside out.
Simple transitions have source and target states that are different, and where exit and entry actions are executed.
In a self-transition, the source state and the target state are the same.
There are two kinds of self transitions. An external transition is one that executes both the exit and entry actions and registers a change of state. Conversely, an internal transition is a self transition that does not allow the exit and entry actions to be executed. Internal transition cannot be defined on a composite state, an it's triggering event must be either a call event or a timer event.
These objects appear within the action-bar, and are modifiers that are used on states and transitions.
There are six kinds of objects:
Entry is the action that is executed when coming into the state.
Exit is the action that is executed when leaving the state.
An operation is an external prompt, represented by an interface, that attempts to trigger a movement from one state to another.
A timeout imposes a time limit on how long the state machine should remain in the state. It can be an expiration (the date and time when the state expires), or a duration (the length of time to remain in the state).
Use a timeout to ensure that the state will not be maintained indefinitely while waiting for an operation that may never occur.
Use a condition to guard the transition, and allow the transition to the next state if the condition evaluates to 'True'.
An action is an activity that is executed when transitioning from one state to another.