jde.debugger.command
Class CommandHandler

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--jde.debugger.command.CommandHandler
All Implemented Interfaces:
Protocol, java.lang.Runnable
Direct Known Subclasses:
ProcessCommandHandler, SessionCommandHandler

public abstract class CommandHandler
extends java.lang.Thread
implements Protocol

Abstract class that provides most of the implementation of the command handlers. A command handler is run by a thread, which picks commands from a queue and executes them. Commands are placed on the queue by another thread that calls the handle(jde.debugger.command.DebugCommand) method, which must be defined in a subclass to this. To stop the command handler, one should call the requestStop() method.

Created: Tue Jan 08 10:48:01 2002

Version:
1.0
Author:
Petter Måhlén

Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface jde.debugger.Protocol
APP_IO, ATTACH_SHMEM, ATTACH_SOCKET, BR, BREAK, CANCEL_TRACE_CLASSES, CANCEL_TRACE_METHODS, CANCEL_TRACE_THREADS, CLEAR, CMD_NOK, CMD_OK, COMMAND_ERROR, COMMAND_RESULT, COMMANDS, CONNECTED_TO_VM, DEBUG, ERROR, EVALUATE, EVENT_BREAKPOINT_HIT, EVENT_CLASS_PREPARE, EVENT_CLASS_UNLOAD, EVENT_EXCEPTION, EVENT_METHOD_ENTRY, EVENT_METHOD_EXIT, EVENT_OTHER, EVENT_STEP_COMPLETED, EVENT_THREAD_DEATH, EVENT_THREAD_START, EVENT_VM_DEATH, EVENT_VM_DISCONNECT, EVENT_VM_START, EVENT_WATCHPOINT_HIT, EVENTS, EVENTSET, EXCEPTION, EXIT, FINISH, FRAMEWORK, GET_ARRAY, GET_LOADED_CLASSES, GET_LOCALS, GET_OBJECT, GET_OBJECT_MONITORS, GET_PATH_INFORMATION, GET_STRING, GET_THREAD, GET_THREADS, GUI, INTERRUPT, INVALID, JDE_BUG, JDE_INIT_DEBUG_SESSION, JDE_PIPE, KILL_THREAD, LAUNCH, LISTEN_SHMEM, LISTEN_SOCKET, MESSAGE, NONE, NOQUOTE, QUIT, QUOTE, REPORT_IDS_IN_USE, RESUME, RUN, SPEC_RESOLVED, STEP, SUSPEND, TRACE_CLASSES, TRACE_EXCEPTIONS, TRACE_METHODS, TRACE_THREADS, WARNING, WATCH
 
Constructor Summary
CommandHandler()
           
 
Method Summary
 void addCommandListener(CommandListener listener)
          Add an CommandListener.
 void fireCommandEvent(java.lang.Integer procID, java.lang.Integer cmdID, java.lang.String cmdName, java.util.List arguments)
          Fire an event indicating that a command has been received.
abstract  java.lang.Integer getProcID()
           
abstract  void handle(DebugCommand cmd)
          Handle a debug command: normally means performing some kind of consistency check and then adding it to the internal queue, using the queue(DebugCommand) method.
protected  void queue(DebugCommand cmd)
          Place the command on the internal command queue.
 void removeCommandListener(CommandListener listener)
          Remove an CommandListener.
 void requestStop()
          Used by other threads to request the CommandHandler to stop executing.
 void run()
          The main loop of the thread simply calls the #remove method, and then the DebugCommand.doCommand() method of the received command.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CommandHandler

public CommandHandler()
Method Detail

fireCommandEvent

public void fireCommandEvent(java.lang.Integer procID,
                             java.lang.Integer cmdID,
                             java.lang.String cmdName,
                             java.util.List arguments)
                      throws JDEException
Fire an event indicating that a command has been received.

addCommandListener

public void addCommandListener(CommandListener listener)
Add an CommandListener. If the listener is already in the list, nothing is done
Parameters:
listener - The listener to add

removeCommandListener

public void removeCommandListener(CommandListener listener)
Remove an CommandListener. If the listener is already in the list, nothing is done
Parameters:
listener - The listener to remove

queue

protected final void queue(DebugCommand cmd)
                    throws JDEException
Place the command on the internal command queue. This method should be called by the handle() method of the sub-class, after it has performed whatever consistency checks are necessary. The method is synchronized on the private m_commandQueue member. It will normally be executed by another thread than the one that runs the actual command handler.

The above comments refer to an old scheme for processing commands. The current implementation does nothing and should be removed.

Parameters:
cmd - a DebugCommand value
Throws:
JDEException - if an error occurs

handle

public abstract void handle(DebugCommand cmd)
                     throws JDEException
Handle a debug command: normally means performing some kind of consistency check and then adding it to the internal queue, using the queue(DebugCommand) method.
Parameters:
cmd - a DebugCommand value
Throws:
JDEException - if an error occurs

requestStop

public void requestStop()
Used by other threads to request the CommandHandler to stop executing.

getProcID

public abstract java.lang.Integer getProcID()

run

public void run()
The main loop of the thread simply calls the #remove method, and then the DebugCommand.doCommand() method of the received command.
Overrides:
run in class java.lang.Thread