Deploy is an example how state machine concepts can be used with an uml modeling to provide a generic error handling state. This state machine is a relatively complex example of how various features can be used to provide a centralized error handling concept.
Note | |
---|---|
Above statechart is designed using Eclipse Papyrus Plugin Chapter 32, Eclipse Modeling Support and imported into Spring StateMachine via its uml model file. Actions and Guards defined in a model are resolved from a Spring Application Context. |
In this state machine scenario we have two different behaviors,
DEPLOY
and UNDEPLOY
what user tries to execute.
What is happening a above statechart:
DEPLOY
state INSTALL
and START
states are entered
conditionally. We enter START
directly if product is already
installed and no need to try to START
if install fails.
UNDEPLOY
state we enter STOP
conditionally if application is
already running.
DEPLOY
and UNDEPLOY
are done via
Choice pseudostate within those states and choices are selected
by Guards.
DEPLOY
and UNDEPLOY
states.
DEPLOY
and UNDEPLOY
we go through a Junction
pseudostate to make a choice if we want to go through ERROR
state
in case error was added into an Extended State.
READY
state to process new requests.
Let’s get into actual demo. Run the boot based sample application:
# java -jar spring-statemachine-samples-deploy-1.2.9.RELEASE.jar
In a browser you see something like:
Important | |
---|---|
As we don’t have a real install, start or stop functionality we simulate failures by checking existence of particular message headers. |
Now you can start to send event to a machine and choose various message headers which will drive a different functionality.