Remote System Explorer DataStore
Release 3.3

org.eclipse.dstore.core.model
Class CommandHandler

java.lang.Object
  extended by java.lang.Thread
      extended by org.eclipse.dstore.core.server.SecuredThread
          extended by org.eclipse.dstore.core.model.Handler
              extended by org.eclipse.dstore.core.model.CommandHandler
All Implemented Interfaces:
Runnable

public abstract class CommandHandler
extends Handler

Abstract class for handling commands. A CommandHandler is a Handler that contains a queue of commands to be sent to miners. Each DataStore instance uses a single command handler that periodically sends it's queue either to a server or directly to miners.

The CommandHandler is the means by which the DataStore sends information or files from the client to the remote tools.


Field Summary
protected  ArrayList _classesToSend
           
protected  ArrayList _commands
           
 
Fields inherited from class org.eclipse.dstore.core.model.Handler
_keepRunning, _waitIncrement
 
Fields inherited from class org.eclipse.dstore.core.server.SecuredThread
_dataStore
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
CommandHandler()
          Constructor
 
Method Summary
 void addCommand(DataElement command, boolean immediate)
          Adds a command object to the queue
 void cancelAllCommands()
          Removes and affectively cancels all commands from the current queue of commands
 DataElement command(DataElement cmd)
          Add a command object to the command queue
 DataElement command(DataElement commandDescriptor, ArrayList arguments, DataElement object, boolean refArg, boolean immediate)
          Create and add a new command object to the command queue.
 DataElement command(DataElement cmd, boolean immediate)
          Add a command object to the command queue
 DataElement command(DataElement commandDescriptor, DataElement object, boolean refArg)
          Create and add a new command object to the command queue.
 DataElement command(DataElement commandDescriptor, DataElement arg, DataElement object, boolean refArg, boolean immediate)
          Create and add a new command object to the command queue.
 CommandGenerator getCommandGenerator()
           
 DataStore getDataStore()
          Returns the associated DataStore
 void handle()
          Periodically called to send commands from the queue.
abstract  void requestClass(String className)
          Implemented to provide the means by which classes are requested across the comm channel.
abstract  void sendAppendFile(String fileName, byte[] bytes, int size, boolean binary)
          Implemented to provide the means by which file bytes are sent and appended
abstract  void sendAppendFile(String fileName, byte[] bytes, int size, boolean binary, String byteStreamHandlerId)
          Implemented to provide the means by which file bytes are sent and appended
abstract  void sendClass(String className)
          Implemented to provide the means by which classes are sent across the comm channel.
abstract  void sendClass(String className, String classByteStreamHandlerId)
          Implemented to provide the means by which classes are sent across the comm channel.
abstract  void sendClassInstance(IRemoteClassInstance runnable, String classByteStreamHandlerId)
          Runs the specified class on the remote system
abstract  void sendCommands()
          Implemented to provide the means by which commands in the queue are sent
abstract  void sendFile(String fileName, byte[] bytes, int size, boolean binary)
          Implemented to provide the means by which file bytes are sent
abstract  void sendFile(String fileName, byte[] bytes, int size, boolean binary, String byteStreamHandlerId)
          Implemented to provide the means by which file bytes are sent
abstract  void sendKeepAliveConfirmation()
           
abstract  void sendKeepAliveRequest()
           
 void setDataStore(DataStore dataStore)
          Sets the associated DataStore
 void waitForInput()
          Causes the current thread to wait until this class request has been fulfilled.
 
Methods inherited from class org.eclipse.dstore.core.model.Handler
finish, getWaitTime, isFinished, notifyInput, run, setWaitTime
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, 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
 

Field Detail

_commands

protected ArrayList _commands

_classesToSend

protected ArrayList _classesToSend
Constructor Detail

CommandHandler

public CommandHandler()
Constructor

Method Detail

setDataStore

public void setDataStore(DataStore dataStore)
Sets the associated DataStore

Overrides:
setDataStore in class Handler

getDataStore

public DataStore getDataStore()
Returns the associated DataStore

Returns:
the associated DataStore

addCommand

public void addCommand(DataElement command,
                       boolean immediate)
Adds a command object to the queue

Parameters:
command - the command to add to the queue
immediate - indicates whether the command should be inserted first in the queue or whether it should be appended.

handle

public void handle()
Periodically called to send commands from the queue.

Specified by:
handle in class Handler

command

public DataElement command(DataElement commandDescriptor,
                           ArrayList arguments,
                           DataElement object,
                           boolean refArg,
                           boolean immediate)
Create and add a new command object to the command queue.

Parameters:
commandDescriptor - the descriptor for the new command
arguments - the arguments for the command
object - the subject of the command
refArg - indicates whether the subject should be represented in the command as a reference to the subject or the actual subject, itself
immediate - indicates whether the command should be first in the queue or appended to it
Returns:
the status object of the command

command

public DataElement command(DataElement commandDescriptor,
                           DataElement arg,
                           DataElement object,
                           boolean refArg,
                           boolean immediate)
Create and add a new command object to the command queue.

Parameters:
commandDescriptor - the descriptor for the new command
arg - the arg for the command
object - the subject of the command
refArg - indicates whether the subject should be represented in the command as a reference to the subject or the actual subject, itself
immediate - indicates whether the command should be first in the queue or appended to it
Returns:
the status object of the command

command

public DataElement command(DataElement commandDescriptor,
                           DataElement object,
                           boolean refArg)
Create and add a new command object to the command queue.

Parameters:
commandDescriptor - the descriptor for the new command
object - the subject of the command
refArg - indicates whether the subject should be represented in the command as a reference to the subject or the actual subject, itself
Returns:
the status object of the command

command

public DataElement command(DataElement cmd)
Add a command object to the command queue

Parameters:
cmd - the command object to add to the queue
Returns:
the status object of the command

command

public DataElement command(DataElement cmd,
                           boolean immediate)
Add a command object to the command queue

Parameters:
cmd - the command object to add to the queue
immediate - indicates whether the command is to be inserted first in the queue or appended
Returns:
the status object of the command

cancelAllCommands

public void cancelAllCommands()
Removes and affectively cancels all commands from the current queue of commands


getCommandGenerator

public CommandGenerator getCommandGenerator()
Since:
3.0 CommandGenerator moved from "internal" to API

sendCommands

public abstract void sendCommands()
Implemented to provide the means by which commands in the queue are sent


sendFile

public abstract void sendFile(String fileName,
                              byte[] bytes,
                              int size,
                              boolean binary)
Implemented to provide the means by which file bytes are sent

Parameters:
fileName - the name of the file to send
bytes - to bytes of the file to send
size - the number of bytes to send
binary - indicates whether to send the bytes as binary or text

sendFile

public abstract void sendFile(String fileName,
                              byte[] bytes,
                              int size,
                              boolean binary,
                              String byteStreamHandlerId)
Implemented to provide the means by which file bytes are sent

Parameters:
fileName - the name of the file to send
bytes - to bytes of the file to send
size - the number of bytes to send
binary - indicates whether to send the bytes as binary or text
byteStreamHandlerId - indicates which byte stream handler to receive the bytes with

sendAppendFile

public abstract void sendAppendFile(String fileName,
                                    byte[] bytes,
                                    int size,
                                    boolean binary)
Implemented to provide the means by which file bytes are sent and appended

Parameters:
fileName - the name of the file to send
bytes - to bytes of the file to send
size - the number of bytes to send
binary - indicates whether to send the bytes as binary or text

sendAppendFile

public abstract void sendAppendFile(String fileName,
                                    byte[] bytes,
                                    int size,
                                    boolean binary,
                                    String byteStreamHandlerId)
Implemented to provide the means by which file bytes are sent and appended

Parameters:
fileName - the name of the file to send
bytes - to bytes of the file to send
size - the number of bytes to send
binary - indicates whether to send the bytes as binary or text
byteStreamHandlerId - indicates which byte stream handler to receive the bytes with

sendClass

public abstract void sendClass(String className)
Implemented to provide the means by which classes are sent across the comm channel.

Parameters:
className - the name of the class to send

sendClass

public abstract void sendClass(String className,
                               String classByteStreamHandlerId)
Implemented to provide the means by which classes are sent across the comm channel.

Parameters:
className - the name of the class to send
classByteStreamHandlerId - indicates which class byte stream handler to receive the class with

sendClassInstance

public abstract void sendClassInstance(IRemoteClassInstance runnable,
                                       String classByteStreamHandlerId)
Runs the specified class on the remote system


waitForInput

public void waitForInput()
Causes the current thread to wait until this class request has been fulfilled.

Overrides:
waitForInput in class Handler

requestClass

public abstract void requestClass(String className)
Implemented to provide the means by which classes are requested across the comm channel.

Parameters:
className - the name of the class to request

sendKeepAliveConfirmation

public abstract void sendKeepAliveConfirmation()

sendKeepAliveRequest

public abstract void sendKeepAliveRequest()

Remote System Explorer DataStore
Release 3.3

Copyright (c) IBM Corporation and others 2000, 2011. All Rights Reserved.