Amir
Amir

Reputation: 652

Spring State Machine Access to StateContext in eventNotAccepted Listener

I'm new to Spring State Machine. I have used a StateMachineListener for my state machine. How can i access to StateContext in eventNotAccepted method.

@Override
        public void eventNotAccepted(Message<String> event) {

        }

Upvotes: 3

Views: 2146

Answers (1)

Janne Valkealahti
Janne Valkealahti

Reputation: 2646

You need to use StateMachineListener.stateContext(StateContext<S, E>) and listen all StateContext changes. From there check StateContext.getStage() when it matches Stage.EVENT_NOT_ACCEPTED.

Originally when that listener interface were added we didn't have context and later when people wanted access to it we didn't want to break backward compatibility, thus that new method were added.

Upvotes: 10

Related Questions