Update ref docs
- First set of changes for doc updates for M3 - Relates #88
This commit is contained in:
@@ -67,6 +67,7 @@ public class Application {
|
||||
}
|
||||
//end::snippetA[]
|
||||
|
||||
//tag::snippetB[]
|
||||
@Configuration
|
||||
static class PersistHandlerConfig {
|
||||
|
||||
@@ -84,7 +85,9 @@ public class Application {
|
||||
}
|
||||
|
||||
}
|
||||
//end::snippetB[]
|
||||
|
||||
//tag::snippetC[]
|
||||
public static class Order {
|
||||
int id;
|
||||
String state;
|
||||
@@ -100,6 +103,7 @@ public class Application {
|
||||
}
|
||||
|
||||
}
|
||||
//end::snippetC[]
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Bootstrap.main(args);
|
||||
|
||||
@@ -36,8 +36,10 @@ public class Persist {
|
||||
|
||||
private final PersistStateMachineHandler handler;
|
||||
|
||||
//tag::snippetA[]
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
//end::snippetA[]
|
||||
|
||||
private final PersistStateChangeListener listener = new LocalPersistStateChangeListener();
|
||||
|
||||
@@ -62,6 +64,7 @@ public class Persist {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
//tag::snippetB[]
|
||||
public void change(int order, String event) {
|
||||
Order o = jdbcTemplate.queryForObject("select id, state from orders where id = ?", new Object[]{order}, new RowMapper<Order>() {
|
||||
public Order mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
@@ -70,7 +73,9 @@ public class Persist {
|
||||
});
|
||||
handler.handleEventWithState(MessageBuilder.withPayload(event).setHeader("order", order).build(), o.state);
|
||||
}
|
||||
//end::snippetB[]
|
||||
|
||||
//tag::snippetC[]
|
||||
private class LocalPersistStateChangeListener implements PersistStateChangeListener {
|
||||
|
||||
@Override
|
||||
@@ -82,5 +87,6 @@ public class Persist {
|
||||
}
|
||||
}
|
||||
}
|
||||
//end::snippetC[]
|
||||
|
||||
}
|
||||
|
||||
@@ -32,18 +32,19 @@ import org.springframework.statemachine.zookeeper.ZookeeperStateMachineEnsemble;
|
||||
@Configuration
|
||||
public class Application {
|
||||
|
||||
//tag::snippetA[]
|
||||
@Configuration
|
||||
@EnableStateMachine
|
||||
static class StateMachineConfig
|
||||
extends StateMachineConfigurerAdapter<String, String> {
|
||||
|
||||
//tag::snippetA[]
|
||||
@Override
|
||||
public void configure(StateMachineConfigurationConfigurer<String, String> config) throws Exception {
|
||||
config
|
||||
.withDistributed()
|
||||
.ensemble(stateMachineEnsemble());
|
||||
}
|
||||
//end::snippetA[]
|
||||
|
||||
@Override
|
||||
public void configure(StateMachineStateConfigurer<String, String> states)
|
||||
@@ -69,6 +70,7 @@ public class Application {
|
||||
.event("PUSH");
|
||||
}
|
||||
|
||||
//tag::snippetB[]
|
||||
@Bean
|
||||
public StateMachineEnsemble<String, String> stateMachineEnsemble() throws Exception {
|
||||
return new ZookeeperStateMachineEnsemble<String, String>(curatorClient(), "/foo");
|
||||
@@ -79,27 +81,20 @@ public class Application {
|
||||
CuratorFramework client = CuratorFrameworkFactory.builder().defaultData(new byte[0])
|
||||
.retryPolicy(new ExponentialBackoffRetry(1000, 3))
|
||||
.connectString("localhost:2181").build();
|
||||
// for testing we start it here, thought initiator
|
||||
// is trying to start it if not already done
|
||||
client.start();
|
||||
return client;
|
||||
}
|
||||
|
||||
//end::snippetB[]
|
||||
|
||||
}
|
||||
//end::snippetA[]
|
||||
|
||||
//tag::snippetB[]
|
||||
public static enum States {
|
||||
LOCKED, UNLOCKED
|
||||
}
|
||||
//end::snippetB[]
|
||||
|
||||
//tag::snippetC[]
|
||||
public static enum Events {
|
||||
COIN, PUSH
|
||||
}
|
||||
//end::snippetC[]
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Bootstrap.main(args);
|
||||
|
||||
Reference in New Issue
Block a user