Update docs

- Add section about error actions for states.
- Relates to #270
This commit is contained in:
Janne Valkealahti
2016-11-20 16:24:34 +00:00
parent f3016bd751
commit 6a5a704c75
2 changed files with 58 additions and 3 deletions

View File

@@ -353,6 +353,49 @@ public class DocsConfigurationSampleTests extends AbstractStateMachineTests {
}
}
// tag::snippetEE[]
@Configuration
@EnableStateMachine
public class Config55
extends EnumStateMachineConfigurerAdapter<States, Events> {
@Override
public void configure(StateMachineStateConfigurer<States, Events> states)
throws Exception {
states
.withStates()
.initial(States.S1)
.stateEntry(States.S2, action(), errorAction())
.stateDo(States.S2, action(), errorAction())
.stateExit(States.S2, action(), errorAction())
.state(States.S3);
}
@Bean
public Action<States, Events> action() {
return new Action<States, Events>() {
@Override
public void execute(StateContext<States, Events> context) {
throw new RuntimeException("MyError");
}
};
}
@Bean
public Action<States, Events> errorAction() {
return new Action<States, Events>() {
@Override
public void execute(StateContext<States, Events> context) {
// RuntimeException("MyError") added to context
Exception exception = context.getException();
exception.getMessage();
}
};
}
}
// end::snippetEE[]
// tag::snippetFA[]
@Configuration