org.springframework.statemachine.listener.StateMachineListener Java Examples

The following examples show how to use org.springframework.statemachine.listener.StateMachineListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractFlowConfiguration.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
protected MachineConfiguration<S, E> getStateMachineConfiguration() {
    StateMachineConfigurationBuilder<S, E> configurationBuilder =
            new StateMachineConfigurationBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    StateMachineStateBuilder<S, E> stateBuilder =
            new StateMachineStateBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    StateMachineTransitionBuilder<S, E> transitionBuilder =
            new StateMachineTransitionBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    StateMachineListener<S, E> listener =
            new StateMachineListenerAdapter<>() {
                @Override
                public void stateChanged(State<S, E> from, State<S, E> to) {
                    LOGGER.debug("state changed from {} to {}", from, to);
                }

                @Override
                public void eventNotAccepted(Message<E> event) {
                    LOGGER.error("{} not accepted event: {}", getClass().getSimpleName(), event);
                }
            };
    return new MachineConfiguration<>(configurationBuilder, stateBuilder, transitionBuilder, listener, new SyncTaskExecutor());
}
 
Example #2
Source File: AbstractFlowConfigurationTest.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@Override
protected MachineConfiguration<State, Event> getStateMachineConfiguration() {
    StateMachineConfigurationBuilder<State, Event> configurationBuilder =
            new StateMachineConfigurationBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    StateMachineStateBuilder<State, Event> stateBuilder =
            new StateMachineStateBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    StateMachineTransitionBuilder<State, Event> transitionBuilder =
            new StateMachineTransitionBuilder<>(ObjectPostProcessor.QUIESCENT_POSTPROCESSOR, true);
    StateMachineListener<State, Event> listener =
            new StateMachineListenerAdapter<State, Event>() {
                @Override
                public void eventNotAccepted(Message<Event> event) {
                    throw new NotAcceptedException();
                }
            };
    return new MachineConfiguration<>(configurationBuilder, stateBuilder, transitionBuilder, listener,
            new SyncTaskExecutor());
}
 
Example #3
Source File: StateMachineConfig.java    From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
@Bean
public StateMachineListener<States, Events> listener() {
    return new StateMachineListenerAdapter<States, Events>() {
        @Override
        public void stateChanged(State<States, Events> from, State<States, Events> to) {
            System.out.println("State change to " + to.getId());
        }
    };
}
 
Example #4
Source File: AbstractFlowConfiguration.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
MachineConfiguration(StateMachineConfigurationBuilder<S, E> configurationBuilder, StateMachineStateBuilder<S, E> stateBuilder,
        StateMachineTransitionBuilder<S, E> transitionBuilder, StateMachineListener<S, E> listener, TaskExecutor executor) {
    this.configurationBuilder = configurationBuilder;
    this.stateBuilder = stateBuilder;
    this.transitionBuilder = transitionBuilder;
    this.listener = listener;
    this.executor = executor;
}