Methods Summary |
---|
public com.sun.corba.se.spi.orbutil.fsm.StateEngine | add(com.sun.corba.se.spi.orbutil.fsm.State oldState, com.sun.corba.se.spi.orbutil.fsm.Input input, com.sun.corba.se.spi.orbutil.fsm.Guard guard, com.sun.corba.se.spi.orbutil.fsm.Action action, com.sun.corba.se.spi.orbutil.fsm.State newState)
mustBeInitializing() ;
StateImpl oldStateImpl = (StateImpl)oldState ;
GuardedAction ga = new GuardedAction( guard, action, newState ) ;
oldStateImpl.addGuardedAction( input, ga ) ;
return this ;
|
public com.sun.corba.se.spi.orbutil.fsm.StateEngine | add(com.sun.corba.se.spi.orbutil.fsm.State oldState, com.sun.corba.se.spi.orbutil.fsm.Input input, com.sun.corba.se.spi.orbutil.fsm.Action action, com.sun.corba.se.spi.orbutil.fsm.State newState)
mustBeInitializing() ;
StateImpl oldStateImpl = (StateImpl)oldState ;
GuardedAction ta = new GuardedAction( action, newState ) ;
oldStateImpl.addGuardedAction( input, ta ) ;
return this ;
|
public void | doIt(com.sun.corba.se.spi.orbutil.fsm.FSM fsm, com.sun.corba.se.spi.orbutil.fsm.Input in, boolean debug)
// This method is present only for debugging.
// innerDoIt does the actual transition.
if (debug)
ORBUtility.dprint( this, "doIt enter: currentState = " +
fsm.getState() + " in = " + in ) ;
try {
innerDoIt( fsm, in, debug ) ;
} finally {
if (debug)
ORBUtility.dprint( this, "doIt exit" ) ;
}
|
public void | done()
mustBeInitializing() ;
// optimize FSM here if desired. For example,
// we could choose different strategies for implementing
// the state transition function based on the distribution
// of values for states and input labels.
initializing = false ;
|
private com.sun.corba.se.spi.orbutil.fsm.Action | getDefaultAction(com.sun.corba.se.spi.orbutil.fsm.StateImpl currentState)
Action action = currentState.getDefaultAction() ;
if (action == null)
action = defaultAction ;
return action ;
|
private com.sun.corba.se.spi.orbutil.fsm.StateImpl | getDefaultNextState(com.sun.corba.se.spi.orbutil.fsm.StateImpl currentState)
// Use the currentState defaults if
// set, otherwise use the state engine default.
StateImpl nextState = (StateImpl)currentState.getDefaultNextState() ;
if (nextState == null)
// The state engine default never changes the state
nextState = currentState ;
return nextState ;
|
private void | innerDoIt(com.sun.corba.se.spi.orbutil.fsm.FSM fsm, com.sun.corba.se.spi.orbutil.fsm.Input in, boolean debug)
if (debug) {
ORBUtility.dprint( this, "Calling innerDoIt with input " + in ) ;
}
// Locals needed for performing the state transition, once we determine
// the required transition.
StateImpl currentState = null ;
StateImpl nextState = null ;
Action action = null ;
// Do until no guard has deferred.
boolean deferral = false ;
do {
deferral = false ; // clear this after each deferral!
currentState = (StateImpl)fsm.getState() ;
nextState = getDefaultNextState( currentState ) ;
action = getDefaultAction( currentState ) ;
if (debug) {
ORBUtility.dprint( this, "currentState = " + currentState ) ;
ORBUtility.dprint( this, "in = " + in ) ;
ORBUtility.dprint( this, "default nextState = " + nextState ) ;
ORBUtility.dprint( this, "default action = " + action ) ;
}
Set gas = currentState.getGuardedActions(in) ;
if (gas != null) {
Iterator iter = gas.iterator() ;
// Search for a guard that is not DISABLED.
// All DISABLED means use defaults.
while (iter.hasNext()) {
GuardedAction ga = (GuardedAction)iter.next() ;
Guard.Result gr = ga.getGuard().evaluate( fsm, in ) ;
if (debug)
ORBUtility.dprint( this,
"doIt: evaluated " + ga + " with result " + gr ) ;
if (gr == Guard.Result.ENABLED) {
// ga has the next state and action.
nextState = (StateImpl)ga.getNextState() ;
action = ga.getAction() ;
if (debug) {
ORBUtility.dprint( this, "nextState = " + nextState ) ;
ORBUtility.dprint( this, "action = " + action ) ;
}
break ;
} else if (gr == Guard.Result.DEFERED) {
deferral = true ;
break ;
}
}
}
} while (deferral) ;
performStateTransition( fsm, in, nextState, action, debug ) ;
|
public com.sun.corba.se.spi.orbutil.fsm.FSM | makeFSM(com.sun.corba.se.spi.orbutil.fsm.State startState)
mustNotBeInitializing() ;
return new FSMImpl( this, startState ) ;
|
private void | mustBeInitializing()
if (!initializing)
throw new IllegalStateException(
"Invalid method call after initialization completed" ) ;
|
private void | mustNotBeInitializing()
if (initializing)
throw new IllegalStateException(
"Invalid method call before initialization completed" ) ;
|
private void | performStateTransition(com.sun.corba.se.spi.orbutil.fsm.FSM fsm, com.sun.corba.se.spi.orbutil.fsm.Input in, com.sun.corba.se.spi.orbutil.fsm.StateImpl nextState, com.sun.corba.se.spi.orbutil.fsm.Action action, boolean debug)
StateImpl currentState = (StateImpl)fsm.getState() ;
// Perform the state transition. Pre and post actions are only
// performed if the state changes (see UML hidden transitions).
boolean different = !currentState.equals( nextState ) ;
if (different) {
if (debug)
ORBUtility.dprint( this,
"doIt: executing postAction for state " + currentState ) ;
try {
currentState.postAction( fsm ) ;
} catch (Throwable thr) {
if (debug)
ORBUtility.dprint( this,
"doIt: postAction threw " + thr ) ;
if (thr instanceof ThreadDeath)
throw (ThreadDeath)thr ;
}
}
try {
// Note that action may be null in a transition, which simply
// means that no action is needed. Note that action.doIt may
// throw an exception, in which case the exception is
// propagated after making sure that the transition is properly
// completed.
if (action != null)
action.doIt( fsm, in ) ;
} finally {
if (different) {
if (debug)
ORBUtility.dprint( this,
"doIt: executing preAction for state " + nextState ) ;
try {
nextState.preAction( fsm ) ;
} catch (Throwable thr) {
if (debug)
ORBUtility.dprint( this,
"doIt: preAction threw " + thr ) ;
if (thr instanceof ThreadDeath)
throw (ThreadDeath)thr ;
}
((FSMImpl)fsm).internalSetState( nextState ) ;
}
if (debug)
ORBUtility.dprint( this, "doIt: state is now " + nextState ) ;
}
|
public com.sun.corba.se.spi.orbutil.fsm.StateEngine | setDefault(com.sun.corba.se.spi.orbutil.fsm.State oldState, com.sun.corba.se.spi.orbutil.fsm.Action action, com.sun.corba.se.spi.orbutil.fsm.State newState)
mustBeInitializing() ;
StateImpl oldStateImpl = (StateImpl)oldState ;
oldStateImpl.setDefaultAction( action ) ;
oldStateImpl.setDefaultNextState( newState ) ;
return this ;
|
public com.sun.corba.se.spi.orbutil.fsm.StateEngine | setDefault(com.sun.corba.se.spi.orbutil.fsm.State oldState, com.sun.corba.se.spi.orbutil.fsm.State newState)
return setDefault( oldState, emptyAction, newState ) ;
|
public com.sun.corba.se.spi.orbutil.fsm.StateEngine | setDefault(com.sun.corba.se.spi.orbutil.fsm.State oldState)
return setDefault( oldState, oldState ) ;
|
public void | setDefaultAction(com.sun.corba.se.spi.orbutil.fsm.Action act)
mustBeInitializing() ;
defaultAction = act ;
|