Less expecting, more accepting.
State Machine Summary
Why State machine
State machines are powerful because behaviour is always guaranteed to be consistent, making it relatively easy to debug.
This is because operational
rules are written in stone when the machine is started.
Interaction with state machine
You can interact with the state machine by sending an event, listening for changes or simply request a current state.
One key point is you have to persist
StateMachineContext rather than
StateMachinePersister vs StateMachinePersist
StateMachinePersist, it handling serialization logic of a StateMachineContext. You need to implement at least two methods,
StateMachinePersister, persisting and restoring a StateMachine from a persistent storage.
One of it’s implementation,
DefaultStateMachinePersister which just a default wrapper of
AbstractStateMachinePersister,. It’s Constructor accept one instance of
StateMachinePersist, and for the method
restore, they are actually invoke
write from underlying StateMachinePersist.