public class ProcessToStart extends Object
| Constructor and Description |
|---|
ProcessToStart() |
| Modifier and Type | Method and Description |
|---|---|
String[] |
getArguments()
Returns an array of strings that are the argument values passed on the command line to the program executable.
|
String[] |
getEnvironment()
Returns environment variable name/value pairs that define the environment to be passed to the started process.
|
String[] |
getEnvironment(Properties properties)
Convenience method that not only returns the environment variables as a String array, but the environment
variables are also populated in the given
Properties map so the caller can more easily look up
environment variables by name. |
String |
getInputDirectory()
Returns the directory where the
input file is located. |
String |
getInputFile()
Returns the name of the file that contains data to be input to the program.
|
String |
getOutputDirectory()
Returns the directory where the program's output log file will be written.
|
String |
getOutputFile()
The file (to be placed in the
output directory) where the program's output will be
written. |
OutputStream |
getOutputStream()
The output stream where the program's output will be written.
|
String |
getProgramDirectory()
Returns the full path to the
program executable. |
String |
getProgramExecutable()
Returns the name of the program to execute.
|
String |
getProgramTitle()
Returns the title for this program.
|
Long |
getWaitForExit()
If 0 or less, the process executor will not wait for the process to exit before returning control.
|
String |
getWorkingDirectory()
Returns the working directory of the new process (known also as the current directory or the startup directory).
|
Boolean |
isBackupOutputFile()
If
true, any previously existing output file will be backed up by renaming it with a date/timestamp. |
Boolean |
isCaptureOutput()
|
Boolean |
isCheckExecutableExists()
If
true, then the executable will first be checked for its existance. |
Boolean |
isKillOnTimeout()
If
true, then the process will be forcibly killed if it doesn't exit within the
wait time. |
void |
setArguments(String[] value)
Sets the argument values that are to be passed on the command line to the program executable.
|
void |
setBackupOutputFile(Boolean value)
Sets the flag to indicate if any previously existing output file should be backed up.
|
void |
setCaptureOutput(Boolean value)
Sets the flag to indicate if the process' output should be captured in the output file.
|
void |
setCheckExecutableExists(Boolean value)
Sets the flag to indicate if the executable should be checked for existence first.
|
void |
setEnvironment(Properties value)
Convienence method that takes a
Properties object containing the environment variables, as opposed
to an array of strings (see setEnvironment(String[]). |
void |
setEnvironment(String[] value)
Sets the environment variable name/value pairs that define the environment to be passed to the started process.
|
void |
setInputDirectory(String value)
Sets the directory where the
input file is located. |
void |
setInputFile(String value)
Sets the name of the file that contains data to be input to the program.
|
void |
setKillOnTimeout(Boolean value)
Sets the flag to indicate if the process should be killed after the wait timeout expires.
|
void |
setOutputDirectory(String value)
Sets the directory where the program's output log file will be written.
|
void |
setOutputFile(String value)
Sets the file (to be placed in the
output directory) where the program's output
will be written. |
void |
setOutputStream(OutputStream value)
The output stream where the program's output will be written.
|
void |
setProgramDirectory(String value)
Sets the full path to the program executable.
|
void |
setProgramExecutable(String value)
Sets the name of the program to execute.
|
void |
setProgramTitle(String value)
Sets the title for this program.
|
void |
setWaitForExit(Long value)
If
null or is 0 or less, the process executor will not wait for the process to exit before returning
control. |
void |
setWorkingDirectory(String value)
Sets the working directory of the new process
|
public String getProgramTitle()
This is useful when, for example, a Java JVM needs to be started and you want to set the title to describe the main class being launched (since all Java executables that are launched typically have the same executable name, that of "java.exe").
If the title was never set, this will return getProgramExecutable()
.
public void setProgramTitle(String value)
value - the title of the program (may be null)getProgramTitle()public String getProgramExecutable()
getProgramDirectory(). If, however,
getProgramDirectory() returns null, the full path to the executable may be returned by this
method.public void setProgramExecutable(String value)
value - program executable namegetProgramExecutable()public String getProgramDirectory()
program executable. This is just the directory where
the executable file is located without the name of the executable itself - for that information, see
getProgramExecutable(). If this returns null, then the full path may be included in the
executable name itself.public void setProgramDirectory(String value)
value - program executable directory locationgetProgramExecutable()public String[] getArguments()
null or empty, no arguments will be passed to the program.public void setArguments(String[] value)
null or empty, no arguments will be passed to the program.value - array of program arguments (may be null or empty)public String[] getEnvironment()
null will allow the subprocess to inherit the parent process environment. Each string must be in the
format: name=value.null or empty)public String[] getEnvironment(Properties properties) throws IllegalArgumentException
Properties map so the caller can more easily look up
environment variables by name. Note that any properties in the properties object will be cleared out
- only the environment variables in this object will populate the properties object once this method
returns.
Note that the returned array should still be examined - at the least to see if it is null - even
if the caller only wants to use the Properties object for retrieval of the environment variables.
This is because a null return value has special semantics, as opposed to a non- null
but empty array. See getEnvironment() for more.
properties - a Properties object where the environment variables can be stored (must not be
null)null or empty)IllegalArgumentException - if an environment variable string doesn't conform to the format:
name=value or properties is nullpublic void setEnvironment(String[] value)
null will allow the subprocess to inherit the parent process environment. Each string must be in the
format: name=value.value - environment variables (may be null or empty)public void setEnvironment(Properties value)
Properties object containing the environment variables, as opposed
to an array of strings (see setEnvironment(String[]). Sets the environment variable name/value pairs
that define the environment to be passed to the started process. A null will allow the subprocess to
inherit the parent process environment.value - property name/values stored in a Properties objectsetEnvironment(String[])public String getWorkingDirectory()
null allows the subprocess to inherit the current working directory of the parent process.null)public void setWorkingDirectory(String value)
value - the working directory path (may be null)getWorkingDirectory()public String getOutputDirectory()
null, a directory will
be assigned (typically the java.io.tmpdir directory).
If getOutputStream() is not null, it overrides this (that is, the stream will get the
output, not the output file).
Regardless of this return value, output will not be captured unless
explicitly told to do so.
null)public void setOutputDirectory(String value)
value - the directory where the output log will be written to (may be null)getOutputDirectory()public String getOutputFile()
output directory) where the program's output will be
written. This should just be the filename; its full path will be specified by the
output directory.
It is in this file where you can view the program's stdout/stderr output stream data.
If null, an auto-generated filename will be used.
If getOutputStream() is not null, it overrides this (that is, the stream will get the
output, not the output file).
Regardless of this return value, output will not be captured unless
explicitly told to do so.
null)public void setOutputFile(String value)
output directory) where the program's output
will be written.value - the program's output log file (may be null)getOutputFile()public OutputStream getOutputStream()
null, then
getOutputDirectory()/getOutputFile() will be examined if the output should be written to a
file.
Regardless of this return value, output will not be captured unless
explicitly told to do so.
null)public void setOutputStream(OutputStream value)
value - the program's output stream (may be null)getOutputStream()public String getInputDirectory()
input file is located.
If this is specified, the input file must also be specified.
null)public void setInputDirectory(String value)
input file is located.value - directory where the input file is located (may be null)getInputDirectory()public String getInputFile()
If this is specified, the input directory must also be specified.
null)public void setInputFile(String value)
value - name of the input file (may be null)getInputFile()public Long getWaitForExit()
null)public void setWaitForExit(Long value)
null or is 0 or less, the process executor will not wait for the process to exit before returning
control. Otherwise, this is the number of milliseconds the process executor will wait for the process to exit. If
the time expires, control will return but the process will continue to run (an attempt to kill the process will
not be made).value - timepublic Boolean isCaptureOutput()
true, the started process' output will be captured and written to the output
file or stream. If false, no output file is
created and the process' output is simply consumed and ignored even if a non-null output file or
stream has been set.false, this will never be null)public void setCaptureOutput(Boolean value)
value - capture output flagisCaptureOutput()public Boolean isBackupOutputFile()
true, any previously existing output file will be backed up by renaming it with a date/timestamp.
If false, any previously existing output file will be overwritten.public void setBackupOutputFile(Boolean value)
value - the backup flagisBackupOutputFile()public Boolean isKillOnTimeout()
true, then the process will be forcibly killed if it doesn't exit within the
wait time. If false, the process will be allowed to continue to run for as
long as it needs - getWaitForExit() will only force the caller to "wake up" and not block waiting for
the process to finish.false, will never be null)public void setKillOnTimeout(Boolean value)
value - the kill flagisKillOnTimeout()public Boolean isCheckExecutableExists()
true, then the executable will first be checked for its existance.
If the executable does not exist, the execution should fail-fast. If false,
the process will attempt to be executed no matter what. This will allow the operating
system to check its executable PATH to find the executable if required.true, will never be null)public void setCheckExecutableExists(Boolean value)
value - the check flagisCheckExecutableExists()Copyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.