S
- the type of stateE
- the type of eventpublic abstract class AbstractState<S,E> extends LifecycleObjectSupport implements State<S,E>
State
.Constructor and Description |
---|
AbstractState(S id,
java.util.Collection<E> deferred)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<? extends Action<S,E>> entryActions,
java.util.Collection<? extends Action<S,E>> exitActions)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<? extends Action<S,E>> entryActions,
java.util.Collection<? extends Action<S,E>> exitActions,
java.util.Collection<? extends Action<S,E>> stateActions,
PseudoState<S,E> pseudoState,
java.util.Collection<Region<S,E>> regions,
StateMachine<S,E> submachine)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<? extends Action<S,E>> entryActions,
java.util.Collection<? extends Action<S,E>> exitActions,
PseudoState<S,E> pseudoState)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<? extends Action<S,E>> entryActions,
java.util.Collection<? extends Action<S,E>> exitActions,
PseudoState<S,E> pseudoState,
java.util.Collection<Region<S,E>> regions)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<? extends Action<S,E>> entryActions,
java.util.Collection<? extends Action<S,E>> exitActions,
PseudoState<S,E> pseudoState,
java.util.Collection<Region<S,E>> regions,
StateMachine<S,E> submachine)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<? extends Action<S,E>> entryActions,
java.util.Collection<? extends Action<S,E>> exitActions,
PseudoState<S,E> pseudoState,
StateMachine<S,E> submachine)
Instantiates a new abstract state.
|
AbstractState(S id,
PseudoState<S,E> pseudoState)
Instantiates a new abstract state.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener<S,E> listener)
Adds the action listener.
|
void |
addStateListener(StateListener<S,E> listener)
Adds the state listener.
|
protected void |
armTriggers()
Arm triggers.
|
protected void |
cancelStateActions()
Cancel existing state actions and clear list.
|
protected void |
disarmTriggers()
Disarm triggers.
|
protected void |
doStart()
Subclasses may implement this method with the start behavior.
|
protected void |
doStop()
Subclasses may implement this method with the stop behavior.
|
void |
entry(StateContext<S,E> context)
Initiate an entry sequence for the state.
|
protected void |
executeAction(Action<S,E> action,
StateContext<S,E> context)
Execute action and notify action listener if set.
|
void |
exit(StateContext<S,E> context)
Initiate an exit sequence for the state.
|
java.util.Collection<E> |
getDeferredEvents()
Gets the deferred events for this state.
|
java.util.Collection<? extends Action<S,E>> |
getEntryActions()
Gets
Action s executed entering in this state. |
java.util.Collection<? extends Action<S,E>> |
getExitActions()
Gets
Action s executed exiting from this state. |
S |
getId()
Gets the state identifier.
|
abstract java.util.Collection<S> |
getIds()
Gets the state identifiers.
|
PseudoState<S,E> |
getPseudoState()
Gets a
PseudoState attached to a State . |
java.util.Collection<Region<S,E>> |
getRegions()
Gets the regions.
|
java.util.Collection<? extends Action<S,E>> |
getStateActions()
Gets
Action s executed once in this state. |
abstract java.util.Collection<State<S,E>> |
getStates()
Gets all possible states this state knows about including itself
and substates.
|
StateMachine<S,E> |
getSubmachine()
Gets the submachine.
|
java.util.List<Trigger<S,E>> |
getTriggers()
Gets the triggers.
|
boolean |
isComposite()
Checks if state is a composite state.
|
boolean |
isOrthogonal()
Checks if state is an orthogonal state.
|
boolean |
isSimple()
Checks if state is a simple state.
|
boolean |
isSubmachineState()
Checks if state is a submachine state.
|
protected void |
notifyStateOnComplete(StateContext<S,E> context) |
void |
removeActionListener(ActionListener<S,E> listener)
Removes the action listener.
|
void |
removeStateListener(StateListener<S,E> listener)
Removes the state listener.
|
protected java.util.concurrent.ScheduledFuture<?> |
scheduleAction(Action<S,E> action,
StateContext<S,E> context,
java.util.concurrent.atomic.AtomicInteger completionCount)
Schedule action and return future which can be used to cancel it.
|
protected void |
scheduleStateActions(StateContext<S,E> context)
Schedule state actions and store futures into list to
be cancelled.
|
boolean |
sendEvent(org.springframework.messaging.Message<E> event)
Send an event
E wrapped with a Message to the state. |
void |
setStateDoActionPolicy(StateDoActionPolicy stateDoActionPolicy) |
void |
setStateDoActionPolicyTimeout(java.lang.Long stateDoActionPolicyTimeout) |
void |
setTriggers(java.util.List<Trigger<S,E>> triggers)
Sets the triggers.
|
boolean |
shouldDefer(org.springframework.messaging.Message<E> event)
Checks if state wants to defer an event.
|
java.lang.String |
toString() |
afterPropertiesSet, destroy, doDestroy, getBeanFactory, getPhase, getTaskExecutor, getTaskScheduler, isAutoStartup, isRunning, onInit, setAutoStartup, setBeanFactory, setPhase, setTaskExecutor, setTaskScheduler, start, stop, stop
public AbstractState(S id, PseudoState<S,E> pseudoState)
id
- the state identifierpseudoState
- the pseudo statepublic AbstractState(S id, java.util.Collection<E> deferred)
id
- the state identifierdeferred
- the deferredpublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<? extends Action<S,E>> entryActions, java.util.Collection<? extends Action<S,E>> exitActions)
id
- the state identifierdeferred
- the deferredentryActions
- the entry actionsexitActions
- the exit actionspublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<? extends Action<S,E>> entryActions, java.util.Collection<? extends Action<S,E>> exitActions, PseudoState<S,E> pseudoState)
id
- the state identifierdeferred
- the deferredentryActions
- the entry actionsexitActions
- the exit actionspseudoState
- the pseudo statepublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<? extends Action<S,E>> entryActions, java.util.Collection<? extends Action<S,E>> exitActions, PseudoState<S,E> pseudoState, StateMachine<S,E> submachine)
id
- the state identifierdeferred
- the deferredentryActions
- the entry actionsexitActions
- the exit actionspseudoState
- the pseudo statesubmachine
- the submachinepublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<? extends Action<S,E>> entryActions, java.util.Collection<? extends Action<S,E>> exitActions, PseudoState<S,E> pseudoState, java.util.Collection<Region<S,E>> regions)
id
- the state identifierdeferred
- the deferredentryActions
- the entry actionsexitActions
- the exit actionspseudoState
- the pseudo stateregions
- the regionspublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<? extends Action<S,E>> entryActions, java.util.Collection<? extends Action<S,E>> exitActions, PseudoState<S,E> pseudoState, java.util.Collection<Region<S,E>> regions, StateMachine<S,E> submachine)
id
- the state identifierdeferred
- the deferredentryActions
- the entry actionsexitActions
- the exit actionspseudoState
- the pseudo stateregions
- the regionssubmachine
- the submachinepublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<? extends Action<S,E>> entryActions, java.util.Collection<? extends Action<S,E>> exitActions, java.util.Collection<? extends Action<S,E>> stateActions, PseudoState<S,E> pseudoState, java.util.Collection<Region<S,E>> regions, StateMachine<S,E> submachine)
id
- the state identifierdeferred
- the deferredentryActions
- the entry actionsexitActions
- the exit actionsstateActions
- the state actionspseudoState
- the pseudo stateregions
- the regionssubmachine
- the submachinepublic boolean sendEvent(org.springframework.messaging.Message<E> event)
State
E
wrapped with a Message
to the state.public boolean shouldDefer(org.springframework.messaging.Message<E> event)
State
shouldDefer
in interface State<S,E>
event
- the wrapped eventpublic void exit(StateContext<S,E> context)
State
public void entry(StateContext<S,E> context)
State
public abstract java.util.Collection<S> getIds()
State
public abstract java.util.Collection<State<S,E>> getStates()
State
public PseudoState<S,E> getPseudoState()
State
PseudoState
attached to a State
.
PseudoState
is not required and thus this method return
NULL
if it's not set.getPseudoState
in interface State<S,E>
public java.util.Collection<E> getDeferredEvents()
State
getDeferredEvents
in interface State<S,E>
public java.util.Collection<? extends Action<S,E>> getEntryActions()
State
Action
s executed entering in this state.getEntryActions
in interface State<S,E>
public java.util.Collection<? extends Action<S,E>> getStateActions()
State
Action
s executed once in this state.getStateActions
in interface State<S,E>
public java.util.Collection<? extends Action<S,E>> getExitActions()
State
Action
s executed exiting from this state.getExitActions
in interface State<S,E>
public boolean isComposite()
State
isComposite
in interface State<S,E>
public boolean isOrthogonal()
State
TRUE
,
State.isComposite()
will also always return TRUE
.isOrthogonal
in interface State<S,E>
public boolean isSimple()
State
public boolean isSubmachineState()
State
isSubmachineState
in interface State<S,E>
public void addStateListener(StateListener<S,E> listener)
State
addStateListener
in interface State<S,E>
listener
- the listenerpublic void removeStateListener(StateListener<S,E> listener)
State
removeStateListener
in interface State<S,E>
listener
- the listenerpublic void addActionListener(ActionListener<S,E> listener)
State
addActionListener
in interface State<S,E>
listener
- the listenerpublic void removeActionListener(ActionListener<S,E> listener)
State
removeActionListener
in interface State<S,E>
listener
- the listenerprotected void doStart()
LifecycleObjectSupport
LifecycleObjectSupport.lifecycleLock
.doStart
in class LifecycleObjectSupport
protected void doStop()
LifecycleObjectSupport
LifecycleObjectSupport.lifecycleLock
.doStop
in class LifecycleObjectSupport
public StateMachine<S,E> getSubmachine()
public java.util.Collection<Region<S,E>> getRegions()
public void setTriggers(java.util.List<Trigger<S,E>> triggers)
triggers
- the triggerspublic java.util.List<Trigger<S,E>> getTriggers()
public void setStateDoActionPolicy(StateDoActionPolicy stateDoActionPolicy)
public void setStateDoActionPolicyTimeout(java.lang.Long stateDoActionPolicyTimeout)
protected void armTriggers()
protected void disarmTriggers()
protected void cancelStateActions()
protected void scheduleStateActions(StateContext<S,E> context)
context
- the contextprotected void executeAction(Action<S,E> action, StateContext<S,E> context)
action
- the actioncontext
- the contextprotected java.util.concurrent.ScheduledFuture<?> scheduleAction(Action<S,E> action, StateContext<S,E> context, java.util.concurrent.atomic.AtomicInteger completionCount)
action
- the actioncontext
- the contextcompletionCount
- the completion count trackerprotected void notifyStateOnComplete(StateContext<S,E> context)
public java.lang.String toString()
toString
in class java.lang.Object