|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jppf.server.protocol.JPPFTask
org.jppf.server.protocol.CommandLineTask
public abstract class CommandLineTask
Instances of this class encapsulate the execution of an external process, program or shell script.
This task starts and external process using command line arguments, environment variables, and a list
of input and/or output files to use or generated by the external process.
This task also captures the standard and error output (i.e. equivalent to System.out and System.err) of the
external process.
| Field Summary |
|---|
| Fields inherited from class org.jppf.server.protocol.JPPFTask |
|---|
listeners |
| Constructor Summary | |
|---|---|
CommandLineTask()
Default condtructor. |
|
CommandLineTask(Map<String,String> env,
String startDir,
String... commands)
Create an instance of this class and set the parameters of the external process or script to launch. |
|
CommandLineTask(String... commands)
Create an instance of this class and set the parameters of the external process or script to launch. |
|
| Method Summary | |
|---|---|
void |
errorStreamAltered(ProcessWrapperEvent event)
Notification that the process has written to its error stream. |
List<String> |
getCommandList()
Get the list of command-line arguments. |
Map<String,String> |
getEnv()
Get the environment variables to set. |
String |
getErrorOutput()
Get the content of the error output for the process. |
String |
getStandardOutput()
Get the content of the standard output for the process. |
String |
getStartDir()
Get the directory to start the command in. |
boolean |
isCaptureOutput()
Determines whether the process output is captured. |
void |
launchProcess()
Run the external process or script. |
void |
outputStreamAltered(ProcessWrapperEvent event)
Notification that the process has written to its output stream. |
void |
setCaptureOutput(boolean captureOutput)
Specifies whether the process output is captured. |
void |
setCommandList(List<String> commandList)
Set the list of command-line arguments. |
void |
setCommandList(String... commands)
Set the list of command-line arguments. |
void |
setEnv(Map<String,String> env)
Get the environment variables to set. |
void |
setStartDir(String startDir)
Set the directory to start the command in. |
| Methods inherited from class org.jppf.server.protocol.JPPFTask |
|---|
addJPPFTaskListener, fireNotification, getDataProvider, getException, getId, getListeners, getPosition, getResult, getTaskObject, getTimeout, getTimeoutDate, getTimeoutDateFormat, getTimeoutFormat, getTimeoutSchedule, onCancel, onRestart, onTimeout, removeJPPFTaskListener, setDataProvider, setException, setId, setPosition, setResult, setTimeout, setTimeoutDate, setTimeoutDate, setTimeoutSchedule |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.lang.Runnable |
|---|
run |
| Constructor Detail |
|---|
public CommandLineTask()
public CommandLineTask(String... commands)
commands - the list of command-line arguments.
public CommandLineTask(Map<String,String> env,
String startDir,
String... commands)
env - the environment variables to set.startDir - the directory to start the command in.commands - the list of command-line arguments.| Method Detail |
|---|
public void launchProcess()
throws Exception
Exception - if an error occurs.public boolean isCaptureOutput()
public void setCaptureOutput(boolean captureOutput)
captureOutput - true if the output is cpatured, false otherwise.public String getStandardOutput()
public String getErrorOutput()
public List<String> getCommandList()
public void setCommandList(List<String> commandList)
commandList - a list of arguments as strings.public void setCommandList(String... commands)
commands - a list of arguments as strings.public Map<String,String> getEnv()
public void setEnv(Map<String,String> env)
env - a map of variable names to their corresponding values.public String getStartDir()
public void setStartDir(String startDir)
startDir - the start directory as a string.public void outputStreamAltered(ProcessWrapperEvent event)
outputStreamAltered in interface ProcessWrapperEventListenerevent - encapsulates the output stream's content.ProcessWrapperEventListener.outputStreamAltered(org.jppf.process.event.ProcessWrapperEvent)public void errorStreamAltered(ProcessWrapperEvent event)
errorStreamAltered in interface ProcessWrapperEventListenerevent - encapsulate the error stream's content.ProcessWrapperEventListener.errorStreamAltered(org.jppf.process.event.ProcessWrapperEvent)
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||