Interface Spawnable
-
- All Known Implementing Classes:
AbstractSpawnable,ProcessSpawn,SshSpawn,SshSpawn2
public interface SpawnableSpawn 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 interfaceSpawnable.CloseListenerWill be notified when aSpawnablecloses.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetExitValue()If theSpawnhas exited, its exit code is returned.java.io.InputStreamgetStderr()Get a stream from which theSpawn's stderr can be read.java.io.OutputStreamgetStdin()Get a stream through which theSpawn's stdin can be written to.java.io.InputStreamgetStdout()Get a stream from which theSpawn's stdout can be read.booleanisClosed()Find out whether theSpawnhas finished.voidsetCloseListener(Spawnable.CloseListener closeListener)Register a listener that will be called when this spawnable closes.voidstart()This method launches theSpawn.voidstop()Stops a runningSpawn.
-
-
-
Method Detail
-
start
void start() throws java.io.IOExceptionThis method launches theSpawn. It starts theStreamPipers 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 theSpawnhas finished.- Returns:
- true if a spawned process has finished.
-
getExitValue
int getExitValue() throws ExpectJExceptionIf theSpawnhas 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.
-
-