33
44Turnstile is a simple device that gives you access if payment is
55made. It is a concept that is simple to model using a state machine. In its
6- simplest, form there are only two states: `LOCKED` and `UNLOCKED`. Two
6+ simplest form, there are only two states: `LOCKED` and `UNLOCKED`. Two
77events, `COIN` and `PUSH` can happen, depending on whether someone
88makes a payment or tries to go through the turnstile.
99The following image shows the state machine:
@@ -16,7 +16,7 @@ The following listing shows the enumeration that defines the possible states:
1616.States
1717[source,java,indent=0]
1818----
19- include::samples/demo/turnstile/Application .java[tags=snippetB]
19+ include::samples/demo/turnstile/States .java[tags=snippetB]
2020----
2121====
2222
@@ -26,7 +26,7 @@ The following listing shows the enumeration that defines the events:
2626.Events
2727[source,java,indent=0]
2828----
29- include::samples/demo/turnstile/Application .java[tags=snippetC]
29+ include::samples/demo/turnstile/Events .java[tags=snippetC]
3030----
3131====
3232
@@ -36,7 +36,7 @@ The following listing shows the code that configures the state machine:
3636.Configuration
3737[source,java,indent=0]
3838----
39- include::samples/demo/turnstile/Application .java[tags=snippetA]
39+ include::samples/demo/turnstile/StateMachineConfiguration .java[tags=snippetA]
4040----
4141====
4242
@@ -49,7 +49,7 @@ and shows the command's output:
4949----
5050$ java -jar spring-statemachine-samples-turnstile-{revnumber}.jar
5151
52- sm>sm print
52+ sm>print
5353+----------------------------------------------------------------+
5454| SM |
5555+----------------------------------------------------------------+
@@ -70,15 +70,15 @@ sm>sm print
7070| |
7171+----------------------------------------------------------------+
7272
73- sm>sm start
73+ sm>start
7474State changed to LOCKED
7575State machine started
7676
77- sm>sm event COIN
77+ sm>event COIN
7878State changed to UNLOCKED
7979Event COIN send
8080
81- sm>sm event PUSH
81+ sm>event PUSH
8282State changed to LOCKED
8383Event PUSH send
8484----
0 commit comments