org.echarts
Class TransitionMachine

java.lang.Object
  extended by org.echarts.Machine
      extended by org.echarts.StateMachine
          extended by org.echarts.TransitionMachine
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
B2buaFSM, B2buaInviteFSM, B2buaSafeFSM, B2buaSafeFSM.ACTIVE, BusyRejectorFSM, ByeSwitchFSM, ByeSwitchFSM.CALLS, ByeSwitchNewFSM, ByeSwitchNewFSM.CALLS, ByeSwitchNewFSM.CALLS.PLACE_NEW_CALL, CallFSM, CancelSwitchNewFSM, CancelSwitchNewFSM.CALLS, CancelSwitchNewFSM.CALLS.PLACE_NEW_CALL, Click2DialFlow1Machine, Click2DialFlow4Machine, ConnectNewFSM, ConnectNewFSM.PLACE_NEW_CALL, EChartsSipServletMachine, FeatureBoxTerminationHandlerFSM, HoldFSM, HoldSwitchFSM, HoldSwitchFSM.CALLS, HoldSwitchNewFSM, HoldSwitchNewFSM.CALLS, HoldSwitchNewFSM.CALLS.PLACE_NEW_CALL, InviteDialogFSM, LineFSM, LineFSM.PROGRESS, LineFSM.WINNER_FOUND, MonitorControlMachine, MonitorControlMachine.NOTIFY, NoAnswerTimeoutFSM, NoAnswerTimeoutFSM.TIMED_CALL, NoAnswerTimeoutFSM.TIMED_CALL.TIMER, ParallelLocationFSM, ParallelLocationFSM.PLACE_CALLS, ParallelLocationFSM.PLACE_CALLS.RINGING, RerouteUponFailureFSM, SendReinviteFSM, SendRequestFSM, SipPortFSM, SipPortTeardownFSM, SubscriberB2buaFSM, SwitchFSM, SwitchFSM.PLACE_NEW_CALL, SwitchToConnectedFSM, SwitchToConnectedFSM.CALLS, SwitchToConnectedFSM.CALLS.CALL1, SwitchToConnectedFSM.CALLS.CALL2, SwitchToNewFSM, SwitchToNewFSM.CALLS, SwitchToNewFSM.CALLS.CONNECTED_CALL, SwitchToNewFSM.CALLS.NEW_CALL, TalkTimeMachine, ThirdPartyCCFlow1FSM, ThirdPartyCCFlow1FSM.CALL_SECOND_PARTY, ThirdPartyCCFlow1FSM.CALL_SECOND_PARTY.CALLEE, ThirdPartyCCFlow1FSM.CALL_SECOND_PARTY.CALLER, ThirdPartyCCFlow4FSM, ThirdPartyCCFlow4FSM.CALL_SECOND_PARTY, ThirdPartyCCFlow4FSM.CALL_SECOND_PARTY.CALLEE, ThirdPartyCCFlow4FSM.CALL_SECOND_PARTY.CALLER, TimeBombFSM, TransparentFSM, TransparentHandleRequestFSM, VxmlRedirectFSM

public abstract class TransitionMachine
extends StateMachine

Abstract class representing common elements of a StateMachine that define transitions (and-machines and or-machines).

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.echarts.Machine
ANY_CONFIG, BASIC_CONFIG, DEEP_HISTORY_CONFIG, DEFAULT_INITIAL_CONFIG, NEW_CONFIG, serialVersionUID, TERMINAL_CONFIG, VARIABLE_CONFIG
 
Constructor Summary
TransitionMachine(State[] states, MachineMessageTransitions[] messageTransitions, MachineMessagelessTransitions[] messagelessTransitions, java.lang.String machineName, Machine parentMachine, int machineIndex, MachineCode machineCode)
           
 
Method Summary
static void addMessagelessTransition(MachineMessagelessTransitions[] currentTransitions, MessagelessTransition transitionToAdd, int sourceStateIndex)
           
static void addMessageTransition(MachineMessageTransitions[] currentTransitions, MessageTransition transitionToAdd, int sourceStateIndex)
           
 java.lang.String globalStateString()
          Returns string representing global state of this machine.
 java.lang.String globalStateString(StateConfiguration config, TransitionMachine firedMachine)
          Returns string representing global state of this machine that was updated by the specified target configuration.
static MachineMessagelessTransitions[] initializeMessagelessTransitions(MachineMessagelessTransitions[] transitionsList)
           
static MachineMessageTransitions[] initializeMessageTransitions(MachineMessageTransitions[] transitionsList)
           
 boolean initializeRoot()
          Initializes root machine.
 java.lang.String localStateString()
          Returns formatted image of machine's local state.
 java.lang.String localStateString(StateConfiguration config, TransitionMachine firedMachine)
          Returns formated image of local machine state that has changed as a result of firing transition with specified relative target state configuration.
 void removePort(ExternalPort port)
          Removes machine's external port acceptor from port.
 void run()
          Run machine firing as many transitions as possible.
 boolean run(LocalPort port, java.lang.Object message)
          Use specified port and message as stimulus to fire as many transitions as possible without blocking.
 boolean runNoQueueing(LocalPort port, java.lang.Object message)
          Use specified port and message as stimulus to fire as many transitions as possible without blocking.
 
Methods inherited from class org.echarts.StateMachine
setMachineDebugging, setMachineMonitor, setMachineMonitoring
 
Methods inherited from class org.echarts.Machine
clearSubmachineReference, getDefaultMachineDebugging, getDefaultMachineDebuggingGlobalStateOutput, getDefaultMachineMonitor, getDefaultMachineMonitorFilter, getDefaultMachineMonitoring, getMachineDebugging, getMachineDebuggingGlobalStateOutput, getMachineID, getMachineIndex, getMachineMonitor, getMachineMonitoring, getParentMachine, getRootMachine, getSystemDebugging, getSystemMonitoring, putEvent, setDebugging, setDefaultMachineDebugging, setDefaultMachineDebuggingGlobalStateOutput, setDefaultMachineMonitor, setDefaultMachineMonitorFilter, setDefaultMachineMonitoring, setMachineDebuggingGlobalStateOutput, setSystemDebugging, setSystemMonitoring, statePathString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransitionMachine

public TransitionMachine(State[] states,
                         MachineMessageTransitions[] messageTransitions,
                         MachineMessagelessTransitions[] messagelessTransitions,
                         java.lang.String machineName,
                         Machine parentMachine,
                         int machineIndex,
                         MachineCode machineCode)
                  throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

initializeMessageTransitions

public static final MachineMessageTransitions[] initializeMessageTransitions(MachineMessageTransitions[] transitionsList)

initializeMessagelessTransitions

public static final MachineMessagelessTransitions[] initializeMessagelessTransitions(MachineMessagelessTransitions[] transitionsList)

addMessagelessTransition

public static final void addMessagelessTransition(MachineMessagelessTransitions[] currentTransitions,
                                                  MessagelessTransition transitionToAdd,
                                                  int sourceStateIndex)

addMessageTransition

public static final void addMessageTransition(MachineMessageTransitions[] currentTransitions,
                                              MessageTransition transitionToAdd,
                                              int sourceStateIndex)

run

public final void run()
               throws java.lang.Exception
Run machine firing as many transitions as possible. If non-AnyPort message transitions are defined in current state then block until a message arrives on one of the currently active ports. When no more transitions can be fired and the only message transitions defined in the current state are AnyPort transitions then this method returns. If message transitions are defined for a port in the current state and a received message does not result in a message transition firing, then an exception is thrown.

Throws:
java.lang.Exception

run

public final boolean run(LocalPort port,
                         java.lang.Object message)
                  throws java.lang.Exception
Use specified port and message as stimulus to fire as many transitions as possible without blocking. If there does not exist an active message transition for the specified port in current state, then specified message will be enqueued in the port's queue. If active message transitions exist for the specified port in the current state and the specified message does not result in a message transition firing, then an exception is thrown. If message results in a transition firing, then the machine will attempt to fire transitions for any ports with enqueued messages. Method returns true if active message transitions exist for the updated machine state. Otherwise method returns returns false indicating that the method should not be called again. If the method is called and there are no active message transitions in the machine's current state then an exception is thrown.

Throws:
java.lang.Exception

runNoQueueing

public final boolean runNoQueueing(LocalPort port,
                                   java.lang.Object message)
                            throws java.lang.Exception
Use specified port and message as stimulus to fire as many transitions as possible without blocking. Unlike the run(port, message) method, this method does not enqueue/dequeue messages. For this reason, this method should only be used for machines that will run correctly without queue support i.e. machines without timed transitions and machines whose current state is always guaranteed to specify at least one message transition for the specified port argument. If active message transitions exist for the specified port in the current state and the specified message does not result in a message transition firing, then an exception is thrown. Method returns true if active message transitions exist for the updated machine state. Otherwise method returns returns false indicating that the method should not be called again. If the method is called and there are no active message transitions in the machine's current state then an exception is thrown.

Throws:
java.lang.Exception

initializeRoot

public final boolean initializeRoot()
                             throws java.lang.Exception
Initializes root machine. First, any submachines in initial state are created, any timed transitions satisfied by current state are activated. Then n messageless transition sequence is run until no more messageless transition are fireable. This method is automatically run the first time one of the machine run() methods is invoked for a machine. However, sometimes it is desireable to initialize a machine prior to its handling its first message transition. Method returns true if active message transitions exist for the updated machine state. Otherwise method returns returns false indicating that run() methods should not be called.

Throws:
java.lang.Exception

removePort

public final void removePort(ExternalPort port)
Removes machine's external port acceptor from port. CAUTION: This operation will render the machine inoperable, however, it does permit the port to be used with another machine. This method should only be used after machine has reached a terminal state or after an exception has occurred in the machine.


globalStateString

public final java.lang.String globalStateString(StateConfiguration config,
                                                TransitionMachine firedMachine)
                                         throws java.lang.Exception
Returns string representing global state of this machine that was updated by the specified target configuration.

Specified by:
globalStateString in class Machine
Throws:
java.lang.Exception

globalStateString

public final java.lang.String globalStateString()
Returns string representing global state of this machine.

Specified by:
globalStateString in class Machine

localStateString

public final java.lang.String localStateString(StateConfiguration config,
                                               TransitionMachine firedMachine)
                                        throws java.lang.Exception
Returns formated image of local machine state that has changed as a result of firing transition with specified relative target state configuration.

Specified by:
localStateString in class Machine
Throws:
java.lang.Exception

localStateString

public final java.lang.String localStateString()
Returns formatted image of machine's local state.

Specified by:
localStateString in class Machine