public abstract class CommandLineTask extends JPPFTask implements ProcessWrapperEventListener
| Constructor and Description |
|---|
CommandLineTask()
Default constructor.
|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
int |
getExitCode()
Get the exit code returned by the sub-process.
|
Process |
getProcess()
Get the process that is launched by this task.
|
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.
|
int |
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.
|
compute, getDataProvider, getException, getId, getPosition, getResult, getTaskObject, getTimeoutSchedule, isInNode, onCancel, onTimeout, setDataProvider, setException, setId, setPosition, setResult, setTimeoutSchedulepublic 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.public int launchProcess()
throws Exception
Exception - if an error occurs.public boolean isCaptureOutput()
public void setCaptureOutput(boolean captureOutput)
captureOutput - true if the output is captured, 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)public int getExitCode()
Process.waitFor()Copyright © 2005-2012 JPPF Team.