Transition error action not used per defined action

- Revert some previous changes order to define transition
  error action logic in a different place. Now basically
  wrapping try/catch in a dedicated action order to have
  separate error action per action as is expected by a config
  SPI.
- Added some tests.
- Added docs for transition error actions.
- Relates to #238
- Fixes #259
This commit is contained in:
Janne Valkealahti
2016-09-27 09:21:30 +01:00
parent 8fc7592404
commit 0f3ffa1876
24 changed files with 452 additions and 211 deletions

View File

@@ -160,6 +160,7 @@ expression based guard is a _SpelExpressionGuard_. This was attached to
transition between states `S2` and `S3`. Both guard in above sample
always evaluate to true.
[[statemachine-config-actions]]
=== Configuring Actions
Actions can be defined to be executed with transitions and states
itself. Action is always executed as a result of a transition which
@@ -220,6 +221,27 @@ wrapped within a `Runnable` which may get cancelled via
action, you need to be able to catch `InterruptedException` which is
raised if task is cancelled.
[[statemachine-config-actions-errorhandling]]
==== Transition Action Error Handling
User can always catch exceptions manually but with actions defined for
transitions it is possible to define error action which is called if
exception is reased. Exception is then available from a `StateContext`
passed to that action.
[source,java,indent=0]
----
include::samples/DocsConfigurationSampleTests.java[tags=snippetEC]
----
Similar logic can be done manually for every action if needed.
[source,java,indent=0]
----
include::samples/DocsConfigurationSampleTests.java[tags=snippetED]
----
=== Configuring Pseudo States
_Pseudo state_ configuration is usually done by configuring states and
@@ -1583,6 +1605,12 @@ recognize only `StateMachineEvent` instances.
include::samples/DocsConfigurationSampleTests.java[tags=snippet4]
----
[TIP]
====
Actions defined for transitions also have their own error handling
logic <<statemachine-config-actions-errorhandling>>.
====
[[sm-persist]]
== Persisting State Machine
Traditionally an instance of a state machine is used as is within a

View File

@@ -30,5 +30,5 @@ _UML_ support and integrations with external config repositories.
* New _Repository_ abstraction keeping machine configuration in an
external repository <<sm-repository>>
* New support for state actions. <<state-actions>>
* New error action concepts.
* New transition error action concepts. <<statemachine-config-actions-errorhandling>>