Remote System Explorer DataStore
Release 1.0

org.eclipse.dstore.core.server
Class ServerCommandHandler

java.lang.Object
  extended byjava.lang.Thread
      extended byorg.eclipse.dstore.core.model.Handler
          extended byorg.eclipse.dstore.core.model.CommandHandler
              extended byorg.eclipse.dstore.core.server.ServerCommandHandler
All Implemented Interfaces:
Runnable

public class ServerCommandHandler
extends CommandHandler

The ServerCommandHandler is reponsible for maintaining a queue of commands and periodically routing commands from the queue to the appropriate miners.


Field Summary
 
Fields inherited from class org.eclipse.dstore.core.model.CommandHandler
_classesToSend, _commands
 
Fields inherited from class org.eclipse.dstore.core.model.Handler
_dataStore, _keepRunning, _waitIncrement
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ServerCommandHandler(ArrayList loaders)
          Constructor
 
Method Summary
 void finish()
          Called when the DataStore session is finished or when there is an unexpected error.
 void finishMiner(String name)
          Terminates a specified miner
 Miner getMiner(String name)
          Returns the specified miner
 ArrayList getMiners()
          Returns the list of loaded miners
 Miner loadMiner(String minerId)
           
 void loadMiners()
          Loads the miners
 void requestClass(String className)
          Does not apply to server.
 void sendAppendFile(String fileName, byte[] bytes, int size, boolean binary)
          Appends bytes sent from the client to a file
 void sendAppendFile(String fileName, byte[] bytes, int size, boolean binary, String byteStreamHandlerId)
          Appends bytes sent from the client to a file
 void sendClass(String className)
          Implemented to provide the means by which classes are requested and sent across the comm channel.
 void sendClass(String className, String classByteStreamHandlerId)
          Implemented to provide the means by which classes are requested and sent across the comm channel.
 void sendClassInstance(IRemoteClassInstance runnable, String classByteStreamHandlerId)
          Runs the specified class on the remote system
 void sendCommands()
          Called periodically to route the current queue of commands to the appropriate miners
 void sendFile(String fileName, byte[] bytes, int size, boolean binary)
          Sets the contents of a file with bytes sent from the client
 void sendFile(String fileName, byte[] bytes, int size, boolean binary, String byteStreamHandlerId)
          Sets the contents of a file with bytes sent from the client
 void sendFile(String fileName, File file)
          Set the contents of a file with the specified file
 void sendKeepAliveConfirmation()
          Does not apply to server.
 void sendKeepAliveRequest()
          Does not apply to server.
 void setDataStore(DataStore dataStore)
          Sets the associated DataStore
 
Methods inherited from class org.eclipse.dstore.core.model.CommandHandler
addCommand, cancelAllCommands, command, command, command, command, command, getCommandGenerator, getDataStore, handle, waitForInput
 
Methods inherited from class org.eclipse.dstore.core.model.Handler
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
 

Constructor Detail

ServerCommandHandler

public ServerCommandHandler(ArrayList loaders)
Constructor

Parameters:
loaders - a list of ExternalLoaders used for loading miners
Method Detail

setDataStore

public void setDataStore(DataStore dataStore)
Sets the associated DataStore

Overrides:
setDataStore in class CommandHandler
Parameters:
dataStore - the associated DataStore

loadMiners

public void loadMiners()
Loads the miners


loadMiner

public Miner loadMiner(String minerId)

getMiners

public ArrayList getMiners()
Returns the list of loaded miners

Returns:
the list of miners

getMiner

public Miner getMiner(String name)
Returns the specified miner

Parameters:
name - the qualified classname of the miner to return
Returns:
the miner

finishMiner

public void finishMiner(String name)
Terminates a specified miner

Parameters:
name - the qualified classname of the miner to terminate

finish

public void finish()
Called when the DataStore session is finished or when there is an unexpected error.

Overrides:
finish in class Handler

sendCommands

public void sendCommands()
Called periodically to route the current queue of commands to the appropriate miners

Specified by:
sendCommands in class CommandHandler

sendFile

public void sendFile(String fileName,
                     File file)
Set the contents of a file with the specified file

Parameters:
fileName - the name of the target file
file - the source file

sendFile

public void sendFile(String fileName,
                     byte[] bytes,
                     int size,
                     boolean binary)
Sets the contents of a file with bytes sent from the client

Specified by:
sendFile in class CommandHandler
Parameters:
fileName - the name of the file to append to
bytes - the bytes of a file to insert
size - the number of bytes to insert
binary - indicates whether to insert the bytes as binary or unicode

sendFile

public void sendFile(String fileName,
                     byte[] bytes,
                     int size,
                     boolean binary,
                     String byteStreamHandlerId)
Sets the contents of a file with bytes sent from the client

Specified by:
sendFile in class CommandHandler
Parameters:
fileName - the name of the file to append to
bytes - the bytes of a file to insert
size - the number of bytes to insert
binary - indicates whether to insert the bytes as binary or unicode
byteStreamHandlerId - indicates which byte stream handler should receive the bytes

sendAppendFile

public void sendAppendFile(String fileName,
                           byte[] bytes,
                           int size,
                           boolean binary)
Appends bytes sent from the client to a file

Specified by:
sendAppendFile in class CommandHandler
Parameters:
fileName - the name of the file to append to
bytes - the bytes of a file to append
size - the number of bytes to append
binary - indicates whether to append the bytes as binary or unicode

sendAppendFile

public void sendAppendFile(String fileName,
                           byte[] bytes,
                           int size,
                           boolean binary,
                           String byteStreamHandlerId)
Appends bytes sent from the client to a file

Specified by:
sendAppendFile in class CommandHandler
Parameters:
fileName - the name of the file to append to
bytes - the bytes of a file to append
size - the number of bytes to append
binary - indicates whether to append the bytes as binary or unicode
byteStreamHandlerId - indicates which byte stream handler should receive the bytes

sendClass

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

Specified by:
sendClass in class CommandHandler
Parameters:
className - the name of the class to request

sendClass

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

Specified by:
sendClass in class CommandHandler
Parameters:
className - the name of the class to request
classByteStreamHandlerId - indicates which class byte stream handler to receive the class with

sendClassInstance

public void sendClassInstance(IRemoteClassInstance runnable,
                              String classByteStreamHandlerId)
Description copied from class: CommandHandler
Runs the specified class on the remote system

Specified by:
sendClassInstance in class CommandHandler

requestClass

public void requestClass(String className)
Does not apply to server. Use ServerUpdateHandler.requestClass().

Specified by:
requestClass in class CommandHandler
Parameters:
className - the name of the class to request

sendKeepAliveConfirmation

public void sendKeepAliveConfirmation()
Does not apply to server. Use ServerUpdateHandler.sendKeepAliveConfirmation().

Specified by:
sendKeepAliveConfirmation in class CommandHandler

sendKeepAliveRequest

public void sendKeepAliveRequest()
Does not apply to server. Use ServerUpdateHandler.sendKeepAliveRequest().

Specified by:
sendKeepAliveRequest in class CommandHandler

Remote System Explorer DataStore
Release 1.0

Guidelines for using DataStore APIs.