|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ptc.windchill.upgrade.util.fsm.StateMachine
A StateMachine instance manages State information, events, and transitions according to a StateMachineDefinition.
StateMachines can run in synchronous or asynchronous mode:
start(...)
to transition it from the single start state
into another state.
StateMachineDefinition
,
StateDefinition
,
State
Nested Class Summary | |
private class |
StateMachine.CheckEventTypeEnabledStates
|
private class |
StateMachine.HandleEvent
|
private class |
StateMachine.Instruction
|
private class |
StateMachine.InstructionHandlingThread
|
Field Summary | |
private State |
currentState_
|
private StateMachineDefinition |
definition_
|
private HashMap |
eventEnabledStates_
|
private FixedLengthQueue |
instructionQueue_
|
private StateMachineListener |
listener_
|
private static int |
RUNNING
|
private int |
runningStatus_
|
private static int |
STOPPED
|
private boolean |
synchronous_
|
Constructor Summary | |
StateMachine(StateMachineDefinition definition,
boolean asynchronous)
Create an instance based on the the StateMachineDefinition. |
Method Summary | |
void |
addStateMachineListener(StateMachineListener new_listener)
Add a listener. |
void |
checkEventTypeEnabledStates()
Instruct the state machine to reevaluate the enabled states of all known event types in the state machine. |
void |
dispatchEvent(EventType event_type)
Create and dispatch an event of the specified type with no event object. |
void |
dispatchEvent(EventType event_type,
Object event_object)
Create and dispatch an event of the specified type and an acommpanying event object. |
private void |
doCheckEventTypeEnabledStates()
|
private void |
enqueue(StateMachine.Instruction instruction)
|
(package private) void |
fireEventEnabledStateEvaluationError(Throwable throwable)
|
(package private) void |
fireEventHandlingError(Event event,
Throwable throwable)
|
(package private) void |
fireEventTypeEnabledStateChanged(EventType event_type,
boolean is_enabled)
|
(package private) void |
firePostStateActivate(State state)
|
(package private) void |
firePostStateDeactivate(State state)
|
(package private) void |
firePreStateActivate(State state)
|
(package private) void |
firePreStateDeactivate(State state)
|
(package private) void |
fireStateMachineStopped()
|
boolean |
isEventTypeEnabled(EventType event_type)
Determine if events of the specified type will cause any action given the state machine's current state. |
(package private) boolean |
isRunning()
A package internal method: whether or not the state machine is running or has stopped |
void |
join()
If StateMachine is asynchronous, block until there are no pending events. |
private void |
logListenerError(String listener_method_name,
Throwable t)
|
private void |
onStop()
|
void |
removeStateMachineListener(StateMachineListener listener_to_remove)
Remove a listener. |
(package private) void |
setState(State state,
Event event)
|
void |
start()
Start the state machine with no event argument. |
void |
start(Object event_argument)
Start the state machine with an event argument. |
(package private) void |
transitionToState(StateDefinition state_definition,
Event event)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final int RUNNING
private static final int STOPPED
private StateMachineDefinition definition_
private boolean synchronous_
private State currentState_
private FixedLengthQueue instructionQueue_
private StateMachineListener listener_
private HashMap eventEnabledStates_
private int runningStatus_
Constructor Detail |
public StateMachine(StateMachineDefinition definition, boolean asynchronous)
While you do not need to subclass this type, you may want to do so in order to maintain application-specific data.
Method Detail |
public final void addStateMachineListener(StateMachineListener new_listener)
public final void removeStateMachineListener(StateMachineListener listener_to_remove)
public final void start()
dispatchEvent(EventType.START)
public final void start(Object event_argument)
Note: this is equivalent to dispatchEvent(EventType.START, event_argument)
public final void dispatchEvent(EventType event_type)
Returns immediately for asynchronous state machine instances
public final void dispatchEvent(EventType event_type, Object event_object)
event_object
- a value of any type, may be null
Returns immediately for asynchronous state machine instances
public final boolean isEventTypeEnabled(EventType event_type)
public final void checkEventTypeEnabledStates()
This is done automatically after handling each event. But client's may invoke this method whenever they do something that may change the result of Conditions that control the applicability of actions upon events.
This call will execute synchronously in the caller's thread. (THIS MAY CHANGE)
isEventTypeEnabled(EventType)
private void enqueue(StateMachine.Instruction instruction)
private void onStop()
final boolean isRunning()
public final void join()
final void transitionToState(StateDefinition state_definition, Event event)
final void setState(State state, Event event)
private void doCheckEventTypeEnabledStates()
final void firePreStateDeactivate(State state)
final void firePostStateDeactivate(State state)
final void firePreStateActivate(State state)
final void firePostStateActivate(State state)
final void fireEventHandlingError(Event event, Throwable throwable)
final void fireEventEnabledStateEvaluationError(Throwable throwable)
final void fireEventTypeEnabledStateChanged(EventType event_type, boolean is_enabled)
final void fireStateMachineStopped()
private void logListenerError(String listener_method_name, Throwable t)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |