Example usage for org.springframework.statemachine.support StateMachineInterceptorAdapter StateMachineInterceptorAdapter

List of usage examples for org.springframework.statemachine.support StateMachineInterceptorAdapter StateMachineInterceptorAdapter

Introduction

In this page you can find the example usage for org.springframework.statemachine.support StateMachineInterceptorAdapter StateMachineInterceptorAdapter.

Prototype

StateMachineInterceptorAdapter

Source Link

Usage

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

private void cancelJobBeforeEnteringState(final States targetState) {
    this.sm.getStateMachineAccessor().doWithAllRegions(function -> function
            .addStateMachineInterceptor(new StateMachineInterceptorAdapter<States, Events>() {
                @Override/*  w  ww.  j av a 2  s  .  c  o m*/
                public void preStateChange(final State<States, Events> state, final Message<Events> message,
                        final Transition<States, Events> transition,
                        final StateMachine<States, Events> stateMachine) {
                    log.info("Sending event {} before transitioning to state: {}", Events.CANCEL_JOB_LAUNCH,
                            targetState);
                    if (state.getId() == targetState) {
                        stateMachine.sendEvent(Events.CANCEL_JOB_LAUNCH);
                    }
                }
            }));
}

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

private void cancelJobAfterEnteringState(final States targetState) {
    this.sm.getStateMachineAccessor().doWithAllRegions(function -> function
            .addStateMachineInterceptor(new StateMachineInterceptorAdapter<States, Events>() {
                @Override/*from  w ww.ja va  2  s.  c  o  m*/
                public void postStateChange(final State<States, Events> state, final Message<Events> message,
                        final Transition<States, Events> transition,
                        final StateMachine<States, Events> stateMachine) {
                    log.info("Sending event {} after transitioning to state: {}", Events.CANCEL_JOB_LAUNCH,
                            targetState);
                    if (state.getId() == targetState) {
                        stateMachine.sendEvent(Events.CANCEL_JOB_LAUNCH);
                    }
                }
            }));
}