|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecteu.planets_project.services.utils.ProcessRunner
public class ProcessRunner
Native command executor. Based on ProcessBuilder.
This code is not yet entirely thread safe. Be sure to only call a given processRunner from one thread, and do not reuse it.
Constructor Summary | |
---|---|
ProcessRunner()
Create a new ProcessRunner. |
|
ProcessRunner(List<String> commands)
Create a new ProcessRunner with the given command. |
|
ProcessRunner(String command)
Create a new ProcessRunner with just this command, with no arguments. |
Method Summary | |
---|---|
InputStream |
getProcessError()
The OutputStream will either be the error-OutputStream directly from the execution of the native commands or a cache with the error-output of the execution of the native commands. |
String |
getProcessErrorAsString()
Return what was printed on the error channel of a _finished_ process, as a string, including newlines. |
InputStream |
getProcessOutput()
The OutputStream will either be the OutputStream directly from the execution of the native commands or a cache with the output of the execution of the native commands. |
String |
getProcessOutputAsString()
Return what was printed on the output channel of a _finished_ process, as a string, including newlines. |
int |
getReturnCode()
Get the return code of the process. |
boolean |
isTimedOut()
Tells whether the process has timedout. |
void |
run()
Run the method, feeding it input, and killing it if the timeout is exceeded. |
void |
setCollection(boolean collect)
Decide if the outputstreams should be collected. |
void |
setCommand(List<String> commands)
Set the command for this ProcessRunner. |
void |
setEnviroment(Map<String,String> enviroment)
Sets the enviroment that the process should run in. |
void |
setErrorCollectionByteSize(int maxError)
How many bytes should we collect from the ErrorStream. |
void |
setInputStream(InputStream processInput)
Set the inputstream, from which the process should read. |
void |
setOutputCollectionByteSize(int maxOutput)
How many bytes should we collect from the OutputStream. |
void |
setStartingDir(File startingDir)
The directory to be used as starting dir. |
void |
setTimeout(long timeout)
Set the timeout. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ProcessRunner()
public ProcessRunner(String command)
command
- the command to runpublic ProcessRunner(List<String> commands)
commands
- the command to runMethod Detail |
---|
public void setEnviroment(Map<String,String> enviroment)
export FLIM=flam echo $FLIMput "FLIM","flam" in the enviroment.
enviroment
- The Map containing the mapping in the enviroment.public void setInputStream(InputStream processInput)
processInput
- to read from.public void setStartingDir(File startingDir)
startingDir
- the starting dir.public void setCommand(List<String> commands)
commands
- the new command.public void setTimeout(long timeout)
timeout
- the new timeout in millisecspublic void setCollection(boolean collect)
collect
- should we collect the outputpublic void setErrorCollectionByteSize(int maxError)
maxError
- number of bytes to max collect.public void setOutputCollectionByteSize(int maxOutput)
maxOutput
- number of bytes to max collect.public InputStream getProcessOutput()
public InputStream getProcessError()
public int getReturnCode()
public boolean isTimedOut()
public String getProcessOutputAsString()
public String getProcessErrorAsString()
public void run()
run
in interface Runnable
Runnable.run()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |