public class CommandLauncher extends Object
| Modifier and Type | Field and Description |
|---|---|
protected String[] |
commandArgs
Command and arguments
|
protected static long |
DELAY
The number of milliseconds to pause between polling.
|
protected String |
name
The internal name of the external process
|
protected Process |
process
The process object representing the external process
|
| Constructor and Description |
|---|
CommandLauncher(String name)
Creates a new launcher
Fills in stderr and stdout output to the given streams.
|
| Modifier and Type | Method and Description |
|---|---|
protected String[] |
constructCommandArray(String command,
String[] commandArgs)
Constructs a command array that will be passed to the process
|
void |
execute(String command)
Execute a command
|
void |
execute(String[] commandArgs)
Execute a command
|
void |
execute(String[] commandArgs,
String[] env)
Execute a command
|
void |
execute(String[] commandArgs,
String[] env,
String changeToDirectory)
Execute a command
|
void |
execute(String commandPath,
String[] args)
Execute a command
|
void |
execute(String commandPath,
String[] args,
String[] env)
Execute a command
|
void |
execute(String commandPath,
String[] args,
String[] env,
String changeToDirectory)
Execute a command
|
String[] |
getCommandArgs()
get CommandArgs.
|
Process |
getProcess() |
void |
printCommandLine(String[] commandArgs)
print Command Line.
|
protected void |
processStreams(ProcessClosure closure,
OutputStream output,
PipedInputStream inputPipe,
OutputStream err,
PipedInputStream errInPipe,
IProgressMonitor monitor)
process the Streams.while the external process returns bytes.
|
void |
waitAndRead(OutputStream out,
OutputStream err)
Reads output from the external process to the streams.
|
void |
waitAndRead(OutputStream output,
OutputStream err,
IProgressMonitor monitor)
Reads output from the external process to the streams.
|
ProcessClosure |
waitAndWrite(InputStream in,
OutputStream out,
OutputStream err)
Writes input to and reads output from the external process to the streams.
|
void |
waitAndWrite(InputStream in,
OutputStream output,
OutputStream err,
IProgressMonitor monitor)
Writes input to and reads output from the external process to the streams.
|
protected static final long DELAY
protected Process process
protected String[] commandArgs
protected String name
public CommandLauncher(String name)
null, if output not requiredname - internal name of the external processpublic String[] getCommandArgs()
protected String[] constructCommandArray(String command, String[] commandArgs)
command - path of comandcommandArgs - arguments after the commandpublic void execute(String command) throws ProcessException
command - commandIOException - if an I/O error occursProcessExceptionpublic void execute(String[] commandArgs) throws ProcessException
commandArgs - command and argumentsIOException - if an I/O error occursProcessExceptionpublic void execute(String commandPath, String[] args) throws ProcessException
commandPath - path of comandargs - arguments after the commandIOException - if an I/O error occursProcessExceptionpublic void execute(String[] commandArgs, String[] env) throws ProcessException
commandArgs - command and argumentsenv - environment name value pairsIOException - if an I/O error occursProcessExceptionpublic void execute(String commandPath, String[] args, String[] env) throws ProcessException
commandPath - path of comandargs - arguments after the comandenv - environment name value pairsIOException - if an I/O error occursProcessExceptionpublic void execute(String[] commandArgs, String[] env, String changeToDirectory) throws ProcessException
commandArgs - command and argumentsenv - environment name value pairschangeToDirectory - working directoryIOException - if an I/O error occursProcessExceptionpublic void execute(String commandPath, String[] args, String[] env, String changeToDirectory) throws ProcessException
commandPath - path of comandargs - arguments after the comandenv - environment name value pairschangeToDirectory - working directoryIOException - if an I/O error occursProcessExceptionpublic void waitAndRead(OutputStream out, OutputStream err) throws ProcessException
out - process stdout is written to this streamerr - process stderr is written to this streamProcessException - if process not yet executedpublic void waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) throws ProcessException
output - process stdout is written to this streamerr - process stderr is written to this streammonitor - monitor monitor to receive progress info and to cancel
the external processProcessException - if process not yet executed or if process
cancelledpublic ProcessClosure waitAndWrite(InputStream in, OutputStream out, OutputStream err) throws ProcessException
in - process stdin is read from this streamout - process stdout is written to this streamerr - process stderr is written to this streamProcessException - if process not yet executedpublic void waitAndWrite(InputStream in, OutputStream output, OutputStream err, IProgressMonitor monitor) throws ProcessException
in - process stdin is read from this streamoutput - process stdout is written to this streamerr - process stderr is written to this streammonitor - monitor monitor to receive progress info and to cancel
the external processProcessException - if process not yet executed or if process
cancelledprotected void processStreams(ProcessClosure closure, OutputStream output, PipedInputStream inputPipe, OutputStream err, PipedInputStream errInPipe, IProgressMonitor monitor) throws ProcessException
closure - process closure object which handles the interaction with
the external processoutput - process stdout is written to this streaminputPipe - piped stream to other thread for the stdouterr - process stderr is written to this streamerrInPipe - piped stream to other thread for the stderrmonitor - monitor to receive progress info and to cancel
the external processProcessException - if process cancelledpublic void printCommandLine(String[] commandArgs)
commandArgs - array of comand and argspublic Process getProcess()
MMBase 1.9-SNAPSHOT - ${javadoctimestamp}