Interface Spawnable
-
- All Known Implementing Classes:
AbstractSpawnable
,ProcessSpawn
,SshSpawn
,SshSpawn2
public interface Spawnable
Spawn interface, can use this interface manage Spawan object, obtain functions such as: start / stop, get stdout /stdin / stderr stream, and set close listener
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Spawnable.CloseListener
Will be notified when aSpawnable
closes.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
getExitValue()
If theSpawn
has exited, its exit code is returned.java.io.InputStream
getStderr()
Get a stream from which theSpawn
's stderr can be read.java.io.OutputStream
getStdin()
Get a stream through which theSpawn
's stdin can be written to.java.io.InputStream
getStdout()
Get a stream from which theSpawn
's stdout can be read.boolean
isClosed()
Find out whether theSpawn
has finished.void
setCloseListener(Spawnable.CloseListener closeListener)
Register a listener that will be called when this spawnable closes.void
start()
This method launches theSpawn
.void
stop()
Stops a runningSpawn
.
-
-
-
Method Detail
-
start
void start() throws java.io.IOException
This method launches theSpawn
. It starts theStreamPiper
s that enable copying of process stream contents to standard streams.- Throws:
java.io.IOException
- on trouble.
-
getStdout
java.io.InputStream getStdout()
Get a stream from which theSpawn
's stdout can be read.- Returns:
- A stream that represents stdout of a spawned process.
- See Also:
Process.getInputStream()
-
getStdin
java.io.OutputStream getStdin()
Get a stream through which theSpawn
's stdin can be written to.- Returns:
- A stream that represents stdin of a spawned process.
- See Also:
Process.getOutputStream()
-
getStderr
java.io.InputStream getStderr()
Get a stream from which theSpawn
'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 theSpawn
has finished.- Returns:
- true if a spawned process has finished.
-
getExitValue
int getExitValue() throws ExpectJException
If theSpawn
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 runningSpawn
. 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.
-
-