Documentation changes

- Document changes to JPA Entity model, persistence
  facilities and related new interfaces and services.
- Relates to #429
- Relates to #476
This commit is contained in:
Janne Valkealahti
2018-01-21 11:40:50 +00:00
parent 3481140126
commit 744d138944
14 changed files with 307 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,11 +35,11 @@ import org.springframework.statemachine.service.StateMachineService;
@Configuration
public class StateMachineConfig {
//tag::snippetA[]
@Configuration
@EnableStateMachineFactory
public static class MachineConfig extends StateMachineConfigurerAdapter<States, Events> {
//tag::snippetB[]
@Autowired
private JpaStateMachineRepository jpaStateMachineRepository;
@@ -50,6 +50,7 @@ public class StateMachineConfig {
.withPersistence()
.runtimePersister(stateMachineRuntimePersister());
}
//end::snippetB[]
@Override
public void configure(StateMachineStateConfigurer<States, Events> states)
@@ -89,24 +90,26 @@ public class StateMachineConfig {
.event(Events.E6);
}
//tag::snippetA[]
@Bean
public StateMachineRuntimePersister<States, Events, String> stateMachineRuntimePersister() {
return new JpaPersistingStateMachineInterceptor<>(jpaStateMachineRepository);
}
}
//end::snippetA[]
}
@Configuration
public static class ServiceConfig {
//tag::snippetC[]
@Bean
public StateMachineService<States, Events> stateMachineService(StateMachineFactory<States, Events> stateMachineFactory,
StateMachineRuntimePersister<States, Events, String> stateMachineRuntimePersister) {
return new DefaultStateMachineService<States, Events>(stateMachineFactory, stateMachineRuntimePersister);
}
//end::snippetC[]
}
//tag::snippetB[]
public enum States {
S1, S2, S3, S4, S5, S6;
}
@@ -114,5 +117,4 @@ public class StateMachineConfig {
public enum Events {
E1, E2, E3, E4, E5, E6;
}
//end::snippetB[]
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,6 +73,7 @@ public class StateMachineController {
return "states";
}
//tag::snippetA[]
private synchronized StateMachine<States, Events> getStateMachine(String machineId) throws Exception {
listener.resetMessages();
if (currentStateMachine == null) {
@@ -88,6 +89,7 @@ public class StateMachineController {
}
return currentStateMachine;
}
//end::snippetA[]
private Events[] getEvents() {
return EnumSet.allOf(Events.class).toArray(new Events[0]);