com.sun.faban.common
Interface CommandHandle

All Superinterfaces:
Remote
All Known Implementing Classes:
CommandHandleImpl

public interface CommandHandle
extends Remote

A handle interface for a command executed on a local or remote system.

Author:
Akara Sucharitakul

Method Summary
 void destroy()
          Forfully terminates the command.
 int exitValue()
          Obtains the exit value of the command.
 byte[] fetchOutput(int streamId)
          Obtains the stdout or stderr of the command.
 FileTransfer fetchOutput(int streamId, String destFile)
          Obtains the stdout or stderr of the command and put it into file.
 String getCommandString()
          Obtains the command string this command handle represents.
 void waitFor()
          Waits for the command to terminate.
 void waitFor(int timeout)
          Waits for the command to terminate, with a given timeout.
 

Method Detail

getCommandString

String getCommandString()
                        throws RemoteException
Obtains the command string this command handle represents.

Returns:
The command string executed.
Throws:
RemoteException - A network error occurred

destroy

void destroy()
             throws RemoteException
Forfully terminates the command.

Throws:
RemoteException - A network error occurred

waitFor

void waitFor()
             throws InterruptedException,
                    RemoteException
Waits for the command to terminate.

Throws:
InterruptedException - The waiting thread got interrupted
RemoteException - A network error occurred

waitFor

void waitFor(int timeout)
             throws InterruptedException,
                    RemoteException
Waits for the command to terminate, with a given timeout.

Parameters:
timeout - The time out
Throws:
InterruptedException - The waiting thread got interrupted.
RemoteException

exitValue

int exitValue()
              throws IllegalStateException,
                     RemoteException
Obtains the exit value of the command.

Returns:
The exit value of the command
Throws:
IllegalStateException - If the command has not yet terminated
RemoteException - A network error occurred

fetchOutput

byte[] fetchOutput(int streamId)
                   throws IOException,
                          IllegalStateException,
                          RemoteException
Obtains the stdout or stderr of the command.

Parameters:
streamId - Command.STDOUT or Command.STDERR
Returns:
The output of the command, as a byte array
Throws:
IOException - There is an error getting the output
IllegalStateException - The command is not yet terminated or does not record output
RemoteException - A network error occurred

fetchOutput

FileTransfer fetchOutput(int streamId,
                         String destFile)
                         throws IOException,
                                IllegalStateException,
                                RemoteException
Obtains the stdout or stderr of the command and put it into file.

Parameters:
streamId - Command.STDOUT or Command.STDERR
destFile - The destination file on the calling system
Returns:
The FileTransfer, if called from remote system, the file is saved
Throws:
IOException - There is an error getting the output
IllegalStateException - The command is not yet terminated or does not record output
RemoteException - A network error occurred