Example usage for org.springframework.statemachine.config.builders StateMachineConfigurationConfigurer withConfiguration

List of usage examples for org.springframework.statemachine.config.builders StateMachineConfigurationConfigurer withConfiguration

Introduction

In this page you can find the example usage for org.springframework.statemachine.config.builders StateMachineConfigurationConfigurer withConfiguration.

Prototype

ConfigurationConfigurer<S, E> withConfiguration() throws Exception;

Source Link

Document

Gets a configurer for generic config.

Usage

From source file:ru.asmsoft.p2p.fsm.NodeStateMachine.java

@Override
public void configure(StateMachineConfigurationConfigurer<NodeStates, NodeEvents> config) throws Exception {
    config.withConfiguration().autoStartup(true).listener(stateListener);
}

From source file:com.example.StateMachineConfiguration.java

@Override
public void configure(final StateMachineConfigurationConfigurer<IssueStates, UserAction> config)
        throws Exception {
    config.withConfiguration().autoStartup(true)
            .listener(new StateMachineListenerAdapter<IssueStates, UserAction>() {
                @Override/*w w  w .j av a 2s  .  c  om*/
                public void stateChanged(final State<IssueStates, UserAction> from,
                        final State<IssueStates, UserAction> to) {
                    final Optional<IssueStates> beforeState = Optional.ofNullable(from).map(State::getId);
                    final Optional<IssueStates> afterState = Optional.ofNullable(to).map(State::getId);
                    log.info("state change from: {}, to: {}", beforeState, afterState);
                }
            });
}