|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
org.knime.base.node.util.exttool.CommandExecution
public class CommandExecution
Wraps a Java runtime process. Supports cancellations and progress messages
(through the ExecutionMonitor
). Picks up the output of the launched
process and forwards it into the log file. It keeps a buffer of 500 lines for
views to display and implements the Observable
interface. All
listeners will be provided with a ViewUpdateNotice
that contains a
new line picked up from the external process.
NOTE: Canceling the execution of the external process will only terminate the
command launched by this class. If the command created subprocesses (like a
shell script will do), these subprocesses will continue living. Even worse,
their output will not be picked up anymore, causing their output buffers to
fill up and potentially block the process. Thus, these processes will exist
in the system until they are killed manually.
Nested Class Summary | |
---|---|
(package private) class |
CommandExecution.CheckCanceledRunnable
|
(package private) class |
CommandExecution.StdErrCatchRunnable
|
(package private) class |
CommandExecution.StdOutCatchRunnable
|
Field Summary | |
---|---|
(package private) static int |
MAX_OUTLINES_STORED
the maximum number of lines stored for stdout and stderr output of the external tool. |
Constructor Summary | |
---|---|
CommandExecution(String... command)
Creates new instance with the given command to execute. |
|
CommandExecution(String cmdWithArgs)
Creates new instance with the given command to execute. |
Method Summary | |
---|---|
void |
clearBuffers()
Clears the std err and out buffers. |
int |
execute(ExecutionContext exec)
Executes the commands via the Runtime and streams the stdout as well as the stderr to the logger and notifies the registered observer if a msg occurs. |
int |
execute(ExecutionMonitor exec)
Executes the commands via the Runtime and streams the stdout as well as the stderr to the logger and notifies the registered observer if a msg occurs. |
String[] |
getEnvps()
|
File |
getExecutionDir()
|
LinkedList<String> |
getStdErr()
|
LinkedList<String> |
getStdOutput()
|
void |
setEnvps(String... envps)
|
void |
setExecutionDir(File dir)
|
Methods inherited from class java.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final int MAX_OUTLINES_STORED
Constructor Detail |
---|
public CommandExecution(String... command)
command
- The command to execute and its arguments, each specified
separately.public CommandExecution(String cmdWithArgs)
cmdWithArgs
- The command to execute and its arguments.Method Detail |
---|
public void setExecutionDir(File dir)
dir
- the working directory of the subprocess, or null if the
subprocess should inherit the working directory of the current
process.Runtime.exec(String, String[], File)
public File getExecutionDir()
Runtime.exec(String, String[], File)
public void setEnvps(String... envps)
envps
- array of strings, each element of which has environment
variable settings in the format name=value, or null if the
subprocess should inherit the environment of the current
process.Runtime.exec(String, String[], File)
public String[] getEnvps()
Runtime.exec(String, String[], File)
public int execute(ExecutionContext exec) throws Exception
Note: This method exists for historical reasons. It
casts the argument to an ExecutionMonitor
and calls the
corresponding execute
method.
exec
- The ExecutionContext
to monitor the status of
execution and to check for user cancellations.
Exception
- If the execution terminates abnormally.Runtime.exec(String[], String[], File)
public int execute(ExecutionMonitor exec) throws Exception
exec
- The ExecutionMonitor
to monitor the status of
execution and to check for user cancellations.
Exception
- If the execution terminates abnormally.Runtime.exec(String[], String[], File)
public void clearBuffers()
public LinkedList<String> getStdOutput()
public LinkedList<String> getStdErr()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |