Example usage for org.springframework.statemachine.config.configurers StateConfigurer state

List of usage examples for org.springframework.statemachine.config.configurers StateConfigurer state

Introduction

In this page you can find the example usage for org.springframework.statemachine.config.configurers StateConfigurer state.

Prototype

StateConfigurer<S, E> state(S state, Action<S, E> entryAction, Action<S, E> exitAction);

Source Link

Document

Specify a state S with entry and exit Action .

Usage

From source file:com.netflix.genie.agent.execution.statemachine.StateMachineAutoConfiguration.java

private void configureStates(final StateMachineBuilder.Builder<States, Events> builder,
        final Collection<Pair<States, StateAction>> statesWithActions) throws Exception {
    // Set up initial and terminal states (action-free)
    final StateConfigurer<States, Events> stateConfigurer = builder.configureStates().withStates()
            .initial(States.READY).end(States.END);

    // Set up the rest of the states with their corresponding action
    for (Pair<States, StateAction> stateWithAction : statesWithActions) {
        final States state = stateWithAction.getLeft();
        final StateAction action = stateWithAction.getRight();
        stateConfigurer
                // Use entryAction because it is not interruptible.
                // StateAction is susceptible to cancellation in case of event-triggered transition out of the state.
                .state(state, action, null);
        log.info("Configured state {} with action {}", state, action.getClass().getSimpleName());
    }//from ww w  . j a  v  a 2 s. c  o  m
}