public class StartCommand extends AbstractCommand
Warning: This command has security implications - it defines any process to start. A remote service that executes this command should have some type of security restrictions in place, to avoid running rogue or unauthorized commands.
| Modifier and Type | Field and Description |
|---|---|
static CommandType |
COMMAND_TYPE
command type constant identifying this command
|
static ParameterDefinition |
PARAM_ARGS
identifies the parameter whose value is an array of arguments to pass to the executable
|
static ParameterDefinition |
PARAM_BACKUP_OUTPUT_FILE
identifies the parameter whose value is the flag to determine whether to backup any previously existing output
file; if false, it will be overwritten
|
static ParameterDefinition |
PARAM_CAPTURE_OUTPUT
identifies the parameter whose value is the flag to determine if the started process's output should be dumped to
the output file
|
static ParameterDefinition |
PARAM_ENV
identifies the parameter whose value is an Properties object containing environment variable name/value pairs to
give to the process
|
static ParameterDefinition |
PARAM_INPUT_DIR
identifies the parameter whose value is the directory location of the file that contains data to be fed into the
programs' stdin input stream
|
static ParameterDefinition |
PARAM_INPUT_FILE
identifies the parameter whose value is the file name that contains data to be fed into the programs' stdin input
stream
|
static ParameterDefinition |
PARAM_OUTPUT_DIR
identifies the parameter whose value is the directory where the process's output log will be written
|
static ParameterDefinition |
PARAM_OUTPUT_FILE
identifies the parameter whose value is the filename (in the output directory) where the process's stdout/stderr
output log will be written
|
static ParameterDefinition |
PARAM_PROGRAM_DIR
identifies the parameter whose value is the full path to the program's executable
|
static ParameterDefinition |
PARAM_PROGRAM_EXE
identifies the parameter whose value is the name of the program to execute
|
static ParameterDefinition |
PARAM_PROGRAM_TITLE
identifies the parameter whose value is a simple title for this start command configuration (may be used for
output filename)
|
static ParameterDefinition |
PARAM_WAIT_FOR_EXIT
identifies the parameter whose value is the time to wait until the process has exited
|
static ParameterDefinition |
PARAM_WORKING_DIR
identifies the parameter whose value is directory location to start the process in (the working directory).
|
| Constructor and Description |
|---|
StartCommand()
Constructor for
StartCommand. |
StartCommand(Command commandToTransform)
Constructor for
StartCommand. |
StartCommand(Map<String,Object> commandParameters)
Constructor for
StartCommand. |
| Modifier and Type | Method and Description |
|---|---|
protected CommandType |
buildCommandType()
Builds the command type of this command.
|
protected ParameterDefinition[] |
buildParameterDefinitions()
Builds the set of parameter definitions that this command will use.
|
void |
checkParameterValidity(boolean convertIfNecessary)
Ensures that if either
PARAM_INPUT_DIR or PARAM_INPUT_FILE are specified, that both are
specified. |
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)
Convienence 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. |
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
null or is 0 or less, the process executor will not wait for the process to exit before returning
the response. |
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()
If
true, the started process' output will be captured and written to the output file. |
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 |
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 |
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 |
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)
Sets the time to wait for the process to exit.
|
void |
setWorkingDirectory(String value)
Sets the working directory of the new process (known also as the current directory or the startup directory).
|
allowAnyParameter, convertParameters, getCommandType, getConfiguration, getParameterDefinition, getParameterDefinitions, getParameterValue, getParameterValues, getParameterValuesInternalMap, hasParameterValue, initializeMetadata, isCommandInResponse, removeParameterValue, removeParameterValues, setCommandInResponse, setParameterValue, setParameterValuesInternalMap, toString, toStringpublic static final CommandType COMMAND_TYPE
public static final ParameterDefinition PARAM_PROGRAM_TITLE
public static final ParameterDefinition PARAM_PROGRAM_EXE
public static final ParameterDefinition PARAM_PROGRAM_DIR
public static final ParameterDefinition PARAM_ARGS
public static final ParameterDefinition PARAM_ENV
public static final ParameterDefinition PARAM_WORKING_DIR
public static final ParameterDefinition PARAM_OUTPUT_DIR
public static final ParameterDefinition PARAM_OUTPUT_FILE
public static final ParameterDefinition PARAM_INPUT_DIR
public static final ParameterDefinition PARAM_INPUT_FILE
public static final ParameterDefinition PARAM_WAIT_FOR_EXIT
public static final ParameterDefinition PARAM_CAPTURE_OUTPUT
public static final ParameterDefinition PARAM_BACKUP_OUTPUT_FILE
public StartCommand()
throws IllegalArgumentException,
InvalidParameterDefinitionException
StartCommand.public StartCommand(Map<String,Object> commandParameters) throws IllegalArgumentException, InvalidParameterDefinitionException
StartCommand.public StartCommand(Command commandToTransform)
StartCommand.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").
public void setProgramTitle(String value)
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").
value - the title of the program (may be null)public String getProgramExecutable()
getProgramDirectory()).public void setProgramExecutable(String value)
setProgramDirectory(String)).value - program executable namepublic String getProgramDirectory()
getProgramExecutable()).public void setProgramDirectory(String value)
getProgramExecutable()).value - program executable directory locationpublic 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 InvalidParameterValueException, 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)InvalidParameterValueException - if an environment variable string doesn't conform to the format:
name=valueIllegalArgumentException - if 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)
null allows the subprocess to inherit the current working directory of the parent process.value - the working directory path (may be null)public String getOutputDirectory()
null, a directory will
be assigned (typically the java.io.tmpdir directory).null)public void setOutputDirectory(String value)
null, a directory will be
assigned (typically the java.io.tmpdir directory).value - the directory where the output log will be written to (may be null)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.
null)public void setOutputFile(String value)
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.
value - the program's output log file (may be null)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.
If this is specified, the input file must also be specified.
value - directory where the input file is located (may be null)public String getInputFile()
If this is specified, the input directory must also be specified.
null)public void setInputFile(String value)
If this is specified, the input directory must also be specified.
value - name of the input file (may be null)public Long getWaitForExit()
null or is 0 or less, the process executor will not wait for the process to exit before returning
the response. Otherwise, this is the number of milliseconds the process executor will wait for the process to
exit. If the time expires, the response will return but the process will continue to run (an attempt to kill the
process will not be made).public void setWaitForExit(Long value)
value - wait time in millisecondsgetWaitForExit()public Boolean isCaptureOutput()
true, the started process' output will be captured and written to the output file. If
false, no output file is created and the process' output is simply consumed and ignored.public void setCaptureOutput(Boolean value)
true, the
started process' output will be captured and written to the output file. If false, no output file is
created and the process' output is simply consumed and ignored.value - capture output flagpublic 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)
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.value - the backup flagpublic void checkParameterValidity(boolean convertIfNecessary)
throws InvalidParameterValueException
PARAM_INPUT_DIR or PARAM_INPUT_FILE are specified, that both are
specified. In other words, you can't specify one without specifying the other.checkParameterValidity in interface CommandcheckParameterValidity in class AbstractCommandconvertIfNecessary - if true, then attempt to convert any invalid parameter valuesInvalidParameterValueException - if one or more parameters are invalidCommand.checkParameterValidity(boolean)protected CommandType buildCommandType()
AbstractCommandnull.
This method is called by the command's constructors.
buildCommandType in class AbstractCommandnullAbstractCommand.buildCommandType()protected ParameterDefinition[] buildParameterDefinitions()
AbstractCommandnull if the command accepts any and all parameters, regardless of name or typeThis method is called by the command's constructors.
buildParameterDefinitions in class AbstractCommandnullAbstractCommand.buildParameterDefinitions()Copyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.