From 3d41bef524534b51925abd3b5abdb2f0337e9211 Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Fri, 22 Apr 2016 13:35:38 +0100 Subject: [PATCH] Update docs - Relates to #194 --- docs/src/reference/asciidoc/appendix.adoc | 30 +++++++++++++++++++ docs/src/reference/asciidoc/sm.adoc | 8 +++++ .../docs/DocsConfigurationSampleTests.java | 27 +++++++++++------ 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/docs/src/reference/asciidoc/appendix.adoc b/docs/src/reference/asciidoc/appendix.adoc index ea0bcc3a..83a3241f 100644 --- a/docs/src/reference/asciidoc/appendix.adoc +++ b/docs/src/reference/asciidoc/appendix.adoc @@ -110,12 +110,23 @@ sub-machines. A pseudo state which allows to make a transition choice based of i.e. event headers or extended state variables. +*Junction State*:: +A pseudo state which is relatively similar to choice state but allows +multiple incoming transitions while choice only allows one incoming +transition. + *Fork State*:: A pseudo state which gives a controlled entry into a regions. *Join State*:: A pseudo state which gives a controlled exit from a regions. +*Entry Point*:: +A pseudo state which allows a controlled entry into a submachine. + +*Exit Point*:: +A pseudo state which allows a controlled exit from a submachine. + *Region*:: A region is an orthogonal part of either a composite state or a state machine. It contains states and transitions. @@ -183,6 +194,14 @@ simple if/elseif/else structure is used to make sure that at least one branch is selected. Otherwise state machine might end up in a deadlock and configuration would be ill-formed. +===== Junction +*Junction pseudostate* is functionally similar than choice as both are +implemented with if/elseif/else structure. Only real difference is +that junction allows multiple incoming transitions while choice only +allows one. Thus difference is purely academic but have some +differences i.e. when state machine is designed using real UI modeling +framework. + ===== History *History pseudostate* can be used to remember a last active state configuration. After state machine has been exited, history state can @@ -198,6 +217,17 @@ makes things much simpler. What is left for user to do is simply do a transition into a history state and state machine will hand the needed logic to go back to its last known recorded state. +In cases where a Transition terminates on a history state when the state +has not been entered before (i.e., no prior history) or it had reached its +End State, there is an option to force a transition to a specific substate, +using the default history mechanism. This is a Transition that originates +in the history state and terminates on a specific Vertex (the default history +state) of the Region containing the history state. This Transition is only +taken if execution leads to the history tate and the state had never been +active before. Otherwise, the normal history entry into the Region is executed. +If no default history transition is defined, then standard default entry of +the region is performed. + ===== Fork *Fork pseudostate* can be used to do an explicit entry into one or more regions. diff --git a/docs/src/reference/asciidoc/sm.adoc b/docs/src/reference/asciidoc/sm.adoc index 9b3adceb..04d72c69 100644 --- a/docs/src/reference/asciidoc/sm.adoc +++ b/docs/src/reference/asciidoc/sm.adoc @@ -238,6 +238,14 @@ You need to choose its state identifier and `History.SHALLOW` or include::samples/DocsConfigurationSampleTests.java[tags=snippetR] ---- +Also as shown above, optionally it is possible to define a default +transition from a history state into a state vertex in a same machine. +This transition takes place as a default if for example machine has +never been entered, thus no history would be available. If default +state transition is not defined, then normal entry into a region is +done. This default transition is also used if machine's history is +a final state. + ==== Choice State Choice needs to be defined in both states and transitions to work properly. Mark particular state as choice state by using `choice()` diff --git a/spring-statemachine-core/src/test/java/org/springframework/statemachine/docs/DocsConfigurationSampleTests.java b/spring-statemachine-core/src/test/java/org/springframework/statemachine/docs/DocsConfigurationSampleTests.java index ba77261a..6f77fb52 100644 --- a/spring-statemachine-core/src/test/java/org/springframework/statemachine/docs/DocsConfigurationSampleTests.java +++ b/spring-statemachine-core/src/test/java/org/springframework/statemachine/docs/DocsConfigurationSampleTests.java @@ -537,16 +537,25 @@ public class DocsConfigurationSampleTests extends AbstractStateMachineTests { public void configure(StateMachineStateConfigurer states) throws Exception { states - .withStates() - .initial(States3.S1) - .state(States3.S2) - .and() .withStates() - .parent(States3.S2) - .initial(States3.S2I) - .state(States3.S21) - .state(States3.S22) - .history(States3.SH, History.SHALLOW); + .initial(States3.S1) + .state(States3.S2) + .and() + .withStates() + .parent(States3.S2) + .initial(States3.S2I) + .state(States3.S21) + .state(States3.S22) + .history(States3.SH, History.SHALLOW); + } + + @Override + public void configure(StateMachineTransitionConfigurer transitions) + throws Exception { + transitions + .withHistory() + .source(States3.SH) + .target(States3.S22); } }