| java.lang.Object org.mmbase.util.externalprocess.CommandLauncher
CommandLauncher | public class CommandLauncher (Code) | | The command launcher provides a way to comunicate with a external process
author: Nico Klasens (Finalist IT Group) version: $Id: since: MMBase-1.6 |
Constructor Summary | |
public | CommandLauncher(String name) Creates a new launcher
Fills in stderr and stdout output to the given streams. |
Method Summary | |
protected String[] | constructCommandArray(String command, String[] commandArgs) | public void | execute(String command) | public void | execute(String[] commandArgs) | public void | execute(String commandPath, String[] args) | public void | execute(String[] commandArgs, String[] env) | public void | execute(String commandPath, String[] args, String[] env) | public void | execute(String[] commandArgs, String[] env, String changeToDirectory) | public void | execute(String commandPath, String[] args, String[] env, String changeToDirectory) | public String[] | getCommandArgs() get CommandArgs. | public 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. | public void | waitAndRead(OutputStream out, OutputStream err) Reads output from the external process to the streams. | public void | waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) Reads output from the external process to the streams. | public void | waitAndWrite(InputStream in, OutputStream out, OutputStream err) Writes input to and reads output from the external process to the streams. | public void | waitAndWrite(InputStream in, OutputStream output, OutputStream err, IProgressMonitor monitor) Writes input to and reads output from the external process to the streams.
A progress monitor is polled to test for cancellation. |
DELAY | final protected static long DELAY(Code) | | The number of milliseconds to pause between polling.
|
commandArgs | protected String[] commandArgs(Code) | | Command and arguments
|
name | protected String name(Code) | | The internal name of the external process
|
process | protected Process process(Code) | | The process object representing the external process
|
CommandLauncher | public CommandLauncher(String name)(Code) | | Creates a new launcher
Fills in stderr and stdout output to the given streams.
Streams can be set to null , if output not required
Parameters: name - internal name of the external process |
constructCommandArray | protected String[] constructCommandArray(String command, String[] commandArgs)(Code) | | Constructs a command array that will be passed to the process
Parameters: command - path of comand Parameters: commandArgs - arguments after the command |
execute | public void execute(String commandPath, String[] args) throws ProcessException(Code) | | Execute a command
Parameters: commandPath - path of comand Parameters: args - arguments after the command throws: IOException - if an I/O error occurs |
execute | public void execute(String[] commandArgs, String[] env) throws ProcessException(Code) | | Execute a command
Parameters: commandArgs - command and arguments Parameters: env - environment name value pairs throws: IOException - if an I/O error occurs |
execute | public void execute(String commandPath, String[] args, String[] env) throws ProcessException(Code) | | Execute a command
Parameters: commandPath - path of comand Parameters: args - arguments after the comand Parameters: env - environment name value pairs throws: IOException - if an I/O error occurs |
execute | public void execute(String[] commandArgs, String[] env, String changeToDirectory) throws ProcessException(Code) | | Execute a command
Parameters: commandArgs - command and arguments Parameters: env - environment name value pairs Parameters: changeToDirectory - working directory throws: IOException - if an I/O error occurs |
execute | public void execute(String commandPath, String[] args, String[] env, String changeToDirectory) throws ProcessException(Code) | | Execute a command
Parameters: commandPath - path of comand Parameters: args - arguments after the comand Parameters: env - environment name value pairs Parameters: changeToDirectory - working directory throws: IOException - if an I/O error occurs |
getCommandArgs | public String[] getCommandArgs()(Code) | | get CommandArgs.
String[] |
printCommandLine | public void printCommandLine(String[] commandArgs)(Code) | | print Command Line.
Parameters: commandArgs - array of comand and args |
processStreams | protected void processStreams(ProcessClosure closure, OutputStream output, PipedInputStream inputPipe, OutputStream err, PipedInputStream errInPipe, IProgressMonitor monitor) throws ProcessException(Code) | | process the Streams.while the external process returns bytes. Cancellation
is possible by the ProgressMonitor
Parameters: closure - process closure object which handles the interaction withthe external process Parameters: output - process stdout is written to this stream Parameters: inputPipe - piped stream to other thread for the stdout Parameters: err - process stderr is written to this stream Parameters: errInPipe - piped stream to other thread for the stderr Parameters: monitor - monitor to receive progress info and to cancelthe external process throws: ProcessException - if process cancelled |
waitAndRead | public void waitAndRead(OutputStream out, OutputStream err) throws ProcessException(Code) | | Reads output from the external process to the streams.
Parameters: out - process stdout is written to this stream Parameters: err - process stderr is written to this stream throws: ProcessException - if process not yet executed |
waitAndRead | public void waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) throws ProcessException(Code) | | Reads output from the external process to the streams. A progress monitor
is polled to test for cancellation. Destroys the process if the monitor
becomes cancelled
Parameters: output - process stdout is written to this stream Parameters: err - process stderr is written to this stream Parameters: monitor - monitor monitor to receive progress info and to cancelthe external process throws: ProcessException - if process not yet executed or if processcancelled |
waitAndWrite | public void waitAndWrite(InputStream in, OutputStream out, OutputStream err) throws ProcessException(Code) | | Writes input to and reads output from the external process to the streams.
Parameters: in - process stdin is read from this stream Parameters: out - process stdout is written to this stream Parameters: err - process stderr is written to this stream throws: ProcessException - if process not yet executed |
waitAndWrite | public void waitAndWrite(InputStream in, OutputStream output, OutputStream err, IProgressMonitor monitor) throws ProcessException(Code) | | Writes input to and reads output from the external process to the streams.
A progress monitor is polled to test for cancellation. Destroys the
process if the monitor becomes cancelled
Parameters: in - process stdin is read from this stream Parameters: output - process stdout is written to this stream Parameters: err - process stderr is written to this stream Parameters: monitor - monitor monitor to receive progress info and to cancelthe external process throws: ProcessException - if process not yet executed or if processcancelled |
|
|