|
Spring AMQP | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.util.exec.Execute
public class Execute
Runs an external program. Derived from ant exec task. All the 'backward compat with jdk1.1, 1.2' removed. Since jdk1.3 supports working dir, no need for scripts. All ant-specific code has been removed as well, this is a completely independent component.
Field Summary | |
---|---|
static int |
INVALID
Invalid exit code. |
Constructor Summary | |
---|---|
Execute()
Creates a new execute object using PumpStreamHandler for stream handling. |
|
Execute(ExecuteStreamHandler streamHandler)
Creates a new execute object. |
|
Execute(ExecuteStreamHandler streamHandler,
ExecuteWatchdog watchdog)
Creates a new execute object. |
Method Summary | |
---|---|
int |
execute()
Runs a process defined by the command line and returns its exit status. |
static int |
execute(Vector<String> envVars,
String cmd,
File baseDir)
|
static int |
execute(Vector<String> envVars,
Vector<String> cmd,
File baseDir)
|
static int |
execute(Vector<String> envVars,
Vector<String> cmd,
File baseDir,
int timeToWait)
Wrapper for common execution patterns |
String[] |
getCommandline()
Returns the commandline used to create a subprocess. |
String |
getCommandLineString()
|
String[] |
getEnvironment()
Returns the environment used to create a subprocess. |
int |
getExitValue()
query the exit value of the process. |
static Vector<String> |
getProcEnvironment()
Find the list of environment variables for this process. |
void |
kill()
|
void |
setCommandline(String[] commandline)
Sets the commandline of the subprocess to launch. |
void |
setEnvironment(String[] env)
Sets the environment variables for the subprocess to launch. |
protected void |
setExitValue(int value)
|
void |
setNewenvironment(boolean newenv)
Set whether to propagate the default environment or not. |
void |
setWorkingDirectory(File wd)
Sets the working directory of the process to execute. |
protected void |
waitFor(Process process)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int INVALID
Constructor Detail |
---|
public Execute()
PumpStreamHandler
for stream handling.
public Execute(ExecuteStreamHandler streamHandler)
streamHandler
- the stream handler used to handle the input and output streams of the subprocess.public Execute(ExecuteStreamHandler streamHandler, ExecuteWatchdog watchdog)
streamHandler
- the stream handler used to handle the input and output streams of the subprocess.watchdog
- a watchdog for the subprocess or null
to to disable a timeout for the subprocess.Method Detail |
---|
public static Vector<String> getProcEnvironment()
public String[] getCommandline()
public String getCommandLineString()
public void setCommandline(String[] commandline)
commandline
- the commandline of the subprocess to launchpublic void setNewenvironment(boolean newenv)
newenv
- whether to propagate the process environment.public String[] getEnvironment()
public void setEnvironment(String[] env)
env
- array of Strings, each element of which has an environment variable settings in format
key=valuepublic void setWorkingDirectory(File wd)
This is emulated using the antRun scripts unless the OS is Windows NT in which case a cmd.exe is spawned, or MRJ and setting user.dir works, or JDK 1.3 and there is official support in java.lang.Runtime.
wd
- the working directory of the process.public int execute() throws Exception
INVALID
Exception
- if launching of the subprocess failedpublic void kill()
protected void waitFor(Process process)
protected void setExitValue(int value)
public int getExitValue()
public static int execute(Vector<String> envVars, String cmd, File baseDir)
public static int execute(Vector<String> envVars, Vector<String> cmd, File baseDir)
public static int execute(Vector<String> envVars, Vector<String> cmd, File baseDir, int timeToWait)
envVars
- Environment variables to execute with (optional)cmd
- a vector of the commands to executebaseDir
- the base directory to run from (optional)timeToWait
- milliseconds to wait for completion
|
Spring AMQP | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |