expectj
Interface Spawnable

All Known Implementing Classes:
AbstractSpawnable, ProcessSpawn, SshSpawn

public interface Spawnable

Implementors of this interface can be spawned by ExpectJ.

Author:
Johan Walles

Nested Class Summary
static interface Spawnable.CloseListener
          Will be notified when a Spawnable closes.
 
Method Summary
 int getExitValue()
          If the Spawn has exited, its exit code is returned.
 InputStream getStderr()
          Get a stream from which the Spawn's stderr can be read.
 OutputStream getStdin()
          Get a stream through which the Spawn's stdin can be written to.
 InputStream getStdout()
          Get a stream from which the Spawn's stdout can be read.
 boolean isClosed()
          Find out whether the Spawn has finished.
 void setCloseListener(Spawnable.CloseListener closeListener)
          Register a listener that will be called when this spawnable closes.
 void start()
          This method launches the Spawn.
 void stop()
          Stops a running Spawn.
 

Method Detail

start

void start()
           throws IOException
This method launches the Spawn. It starts the StreamPipers that enable copying of process stream contents to standard streams.

Throws:
IOException - on trouble.

getStdout

InputStream getStdout()
Get a stream from which the Spawn's stdout can be read.

Returns:
A stream that represents stdout of a spawned process.
See Also:
Process.getInputStream()

getStdin

OutputStream getStdin()
Get a stream through which the Spawn's stdin can be written to.

Returns:
A stream that represents stdin of a spawned process.
See Also:
Process.getOutputStream()

getStderr

InputStream getStderr()
Get a stream from which the Spawn's stderr can be read.

Returns:
A stream that represents stderr of a spawned process, or null if there is no stderr.
See Also:
Process.getErrorStream()

isClosed

boolean isClosed()
Find out whether the Spawn has finished.

Returns:
true if a spawned process has finished.

getExitValue

int getExitValue()
                 throws ExpectJException
If the Spawn has exited, its exit code is returned.

Returns:
The exit code of the finished spawn.
Throws:
ExpectJException - if the spawn is still running.
See Also:
isClosed(), System.exit(int)

stop

void stop()
Stops a running Spawn. After this method returns, isClosed() must return true.


setCloseListener

void setCloseListener(Spawnable.CloseListener closeListener)
Register a listener that will be called when this spawnable closes.

Parameters:
closeListener - The listener that will be notified when this spawnable closes.


Copyright © 2010. All Rights Reserved.