Since I must support concurrent access to the state machine, I can't use the usual Autowired singleton approach. Instead, I am trying to build the state machine as described in the docs, here:
Here is my very modest code:
Builder<SessionState, SessionEvent> builder = StateMachineBuilder.builder();
builder.configureStates().withStates().initial(SessionState.INITIAL).states(EnumSet.allOf(SessionState.class));
StateMachine<SessionState, SessionEvent> stateMachine = builder.build();
stateMachine.start();
System.out.println(stateMachine.getState()); // null !!!
This fails immediately, as the state of the machine is surprisingly null, whereas I expect SessionState.INITIAL.
What am I doing wrong here??
I've also tried exactly the code shown in the docs, namely:
Builder<String, String> builder = StateMachineBuilder.builder();
builder.configureStates().withStates().initial("SI").end("SF").states(new HashSet<String>(Arrays.asList("S1", "S2", "S3", "S4")));
final StateMachine<String, String> stateMachine = builder.build();
stateMachine.start();
System.out.println(stateMachine.getState());
.... same result.