com.atlassian.fisheye.plugins.scm.utils.process
Interface ProcessHandler

All Known Implementing Classes:
BaseProcessHandler, PluggableProcessHandler, StringProcessHandler

public interface ProcessHandler

Interface used to manage the IO and termination needs of an external processes managed by ExternalProcess. The methods of this interface will be called by different threads, so implementors should take care to ensure thread safety

See Also:
ExternalProcess

Method Summary
 void complete(int exitCode, ProcessException exception)
          Called when the external process has completed
 ProcessException getException()
          Get any processing exception associated with this handler
 int getExitCode()
          Get the process exit code
 boolean hasInput()
          Indicate if this handler has input to provide to the process
 boolean isComplete()
          Indicate if the process has completed
 void processError(java.io.InputStream error)
          Process the process stderr stream
 void processOutput(java.io.InputStream output)
          Process the process stdout stream
 void provideInput(java.io.OutputStream input)
          Provide input to the external process.
 void reset()
          Called if the process is to be re-executed.
 void setWatchdog(Watchdog watchdog)
          Set the watchdog associated with this handler.
 boolean succeeded()
          Indicate if the process execution has been considered successful.
 

Method Detail

processOutput

void processOutput(java.io.InputStream output)
                   throws ProcessException
Process the process stdout stream

Parameters:
output - the external process' output stream (available as an input to this class)
Throws:
ProcessException - if there is a problem processing the output

processError

void processError(java.io.InputStream error)
                  throws ProcessException
Process the process stderr stream

Parameters:
error - the external process' standard error stream (available as an input to this class)
Throws:
ProcessException - if there is a problem processing the output

hasInput

boolean hasInput()
Indicate if this handler has input to provide to the process

Returns:
true if input is available

provideInput

void provideInput(java.io.OutputStream input)
Provide input to the external process. Input is provided by writing the content to the given output stream. This method will only be called if hasInput() returns true

Parameters:
input - the output stream representing standard input to the external process
Throws:
java.lang.IllegalStateException - if no input has been configured.

complete

void complete(int exitCode,
              ProcessException exception)
Called when the external process has completed

Parameters:
exitCode - the exit code of the external process
exception - any process exceptions that were thrown within the VM when handling the external process

isComplete

boolean isComplete()
Indicate if the process has completed

Returns:
true if complete has been called.

setWatchdog

void setWatchdog(Watchdog watchdog)
Set the watchdog associated with this handler. The watchdog should be called at regular intervals to prevent the external process being terminated. Typically this is done in the IO handling methods


succeeded

boolean succeeded()
Indicate if the process execution has been considered successful.

Returns:
true if the process execution completed without error

reset

void reset()
Called if the process is to be re-executed.


getException

ProcessException getException()
Get any processing exception associated with this handler

Returns:
a processing exception instance or null if no exception occurred.

getExitCode

int getExitCode()
Get the process exit code

Returns:
process exit code