Using stateless4j I am trying to perform an action in response to an event with parameters in one particular state. After handling the event I don't want to change state.
As stateless4j does not support actions on events (although I see there is a pending patch for this) I am instead misusing the permitDynamic() and using the selector to execute my action. I then return the same state in the selector. So, in the code below action_activated_serviceRegistered returns FsmState.ACTIVATED.
activationFsmConfig
.configure(FsmState.ACTIVATED)
.onEntry(fsmFunctions::action_activated_entry)
.onExit(fsmFunctions::action_activated_exit)
.permitDynamic(new TriggerWithParameters1<>(Trigger.SERVICE_REGISTERED, ServiceReference.class), fsmFunctions::action_activated_serviceRegistered);
The issue I am having is that the exit and entry actions to my state are firing even though I am not changing state.
Is there a better way of doing this?
Perhaps you can perform your action in guard condition of .ignoreIf(Trigger, guard).