stella.rmi
Class ReceiverTorso.CommandHandler

java.lang.Object
  extended by java.lang.Thread
      extended by stella.rmi.ReceiverTorso.CommandHandler
All Implemented Interfaces:
Runnable
Enclosing class:
ReceiverTorso

protected class ReceiverTorso.CommandHandler
extends Thread

Handles the incomming command. To allow fast-return of the command-receiving end of the outer class, ReceiverTorso.rmiCommand(stella.CommandEvent), the actual command handling is done with a seperate class that is an extension to Thread. It is constructed with the incomming command so multiple calls to the outer classe's ReceiverTorso.rmiCommand(stella.CommandEvent) will not result in errors. The only use of the command-processing as an inner class is to allow multiple, thread-safe command calls.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  CommandEvent cmd
          The command to process.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected ReceiverTorso.CommandHandler(ThreadGroup group, CommandEvent com)
          Constructs a new command-handling thread.
 
Method Summary
 void run()
          The run method of the receiver.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cmd

private CommandEvent cmd
The command to process.

Constructor Detail

ReceiverTorso.CommandHandler

protected ReceiverTorso.CommandHandler(ThreadGroup group,
                                       CommandEvent com)
Constructs a new command-handling thread. The initial command is safely stored inside this helper class instance.

Parameters:
group - The thread group this command handler should run in.
cmd - The command to process.
Method Detail

run

public void run()
The run method of the receiver. It sends back acknowledge objects as appropriate counting down the acknowledge number from the initial number returned by ReceiverTorso.getAcknowledgeNumber(stella.CommandEvent). As long as calls to the ReceiverTorso.processCommand(stella.CommandEvent, int) returns true the acknowledge number is reduced until the AcknowledgeEvent.PRIMARY_ACK is reached and a final done event is sent. If a call to ReceiverTorso.processCommand(stella.CommandEvent, int) returns false this acknowledge chaining is broken: The error event is fetched with ReceiverTorso.getLastError(), sent back to the error listeners, and the command caster is notified with a final, successful, done event (Note that unsuccessful done events are spared for unexpected errors that have no individual error handling procedure).

Specified by:
run in interface Runnable
Overrides:
run in class Thread