|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.util.ProcessLauncher
Performs the process using another thread to start sending output, before processing has completed.
Supported API: true
Extendable: false
Process
Nested Class Summary | |
private class |
ProcessLauncher.PrintStreamSpewer
Thread to read from an input stream (line-by-line) and print it to a print stream until the input stream closes. |
class |
ProcessLauncher.TimeoutException
|
private class |
ProcessLauncher.TimeoutMonitor
|
Field Summary | |
private String[] |
arguments_
|
private String |
command_
|
private Properties |
environment_
|
private ProcessLauncher.PrintStreamSpewer |
errSpewer_
|
private PrintStream |
errStream_
|
private PrintWriter |
errWriter_
|
private String |
executable_
|
private ProcessLauncher.PrintStreamSpewer |
outSpewer_
|
private PrintStream |
outStream_
|
private PrintWriter |
outWriter_
|
private Process |
process_
|
private ProcessLauncher.TimeoutMonitor |
timeoutMonitor_
|
private boolean |
verbose
|
Constructor Summary | |
ProcessLauncher(String command)
Create an instance to run the command; Supported API: true |
|
ProcessLauncher(String executable,
String[] args)
|
|
ProcessLauncher(String executable,
String[] args,
Properties environment_variables)
|
Method Summary | |
private static String |
buildCommand(String executable,
String[] arguments)
|
private void |
cleanUpProcess()
|
private void |
cleanUpTimeoutMonitor()
|
private String[] |
formatEnvironment()
|
String |
getCommand()
Tell the client what the command was when constructor was called. |
static void |
main(String[] args)
Use java to launch a process to execute a command. |
int |
runProcess()
Launch the subprocess and wait for it to complete. |
int |
runProcess(long inactivity_timeout,
long overall_timeout)
Launch the sub-process but do not wait beyond overall_timeout for it to complete. |
void |
setErrorStream(PrintStream error_stream)
The errors from the process and local class methods will be written to this PrintStream, for reading to begin before processing completes. |
void |
setErrorWriter(PrintWriter error_writer)
The errors from the process and local class methods will be written to this PrintWriter, for reading to begin after the process completes. |
void |
setOutStream(PrintStream out_stream)
The output from the process's output stream will be written to this PrintStream, for reading to begin before processing completes. |
void |
setOutWriter(PrintWriter out_writer)
The output from the process's output stream will be written to this PrintWriter, for reading to begin after the process completes. |
void |
setVerbosity(boolean verbosity)
|
private void |
startSpewersForProcess()
Start moving single-line Strings from the process_'s InputStream and ErrorStream into the caller's output. |
private int |
waitForProcessToExitOrTimeOut()
|
private void |
waitForSpewersToStop()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private String executable_
private String[] arguments_
private Properties environment_
private String command_
private Process process_
private ProcessLauncher.TimeoutMonitor timeoutMonitor_
private ProcessLauncher.PrintStreamSpewer outSpewer_
private ProcessLauncher.PrintStreamSpewer errSpewer_
private PrintStream outStream_
private PrintStream errStream_
private PrintWriter outWriter_
private PrintWriter errWriter_
private boolean verbose
Constructor Detail |
public ProcessLauncher(String command)
command
- Process this command.public ProcessLauncher(String executable, String[] args)
public ProcessLauncher(String executable, String[] args, Properties environment_variables)
Method Detail |
private static String buildCommand(String executable, String[] arguments)
public final String getCommand()
public void setErrorWriter(PrintWriter error_writer)
error_writer
- After processing completes, review errors from here.public void setOutWriter(PrintWriter out_writer)
out_writer
- After processing completes, review the process' progression from here.public void setErrorStream(PrintStream error_stream)
error_stream
- While still processing, look at errors from here.public void setOutStream(PrintStream out_stream)
out_stream
- While still processing, look at the process' progression from here.public final int runProcess() throws IOException, ProcessLauncher.TimeoutException
IOException
- Forwarded from runProcess(long,long).
ProcessLauncher.TimeoutException
public final int runProcess(long inactivity_timeout, long overall_timeout) throws IOException, ProcessLauncher.TimeoutException
inactivity_timeout
- Max milliseconds between process additions to the output (= 0 means no max).overall_timeout
- Max milliseconds for all process output (= 0 means no max).
IOException
- If unable to process the command.
ProcessLauncher.TimeoutException
private String[] formatEnvironment()
private void startSpewersForProcess()
private void waitForSpewersToStop()
private int waitForProcessToExitOrTimeOut() throws IOException, ProcessLauncher.TimeoutException
IOException
ProcessLauncher.TimeoutException
private void cleanUpTimeoutMonitor()
private void cleanUpProcess()
public static void main(String[] args)
args
- The command.public void setVerbosity(boolean verbosity)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |