public class DefaultCommandBuilder extends java.lang.Object implements CommandBuilder
CommandBuilder
Constructor and Description |
---|
DefaultCommandBuilder() |
Modifier and Type | Method and Description |
---|---|
void |
addArgument(CommandArgument arg) |
void |
addEnvironmentMetadataKey(java.lang.String key) |
org.apache.commons.exec.Executor |
configure(org.apache.commons.exec.Executor exe)
Configure the
Executor . |
org.apache.commons.exec.CommandLine |
createCommandLine(AdaptrisMessage msg)
Build a
ProcessBuilder object from the available data. |
java.util.Map<java.lang.String,java.lang.String> |
createEnvironment(AdaptrisMessage msg)
Create the environment when executing the process.
|
java.util.List<CommandArgument> |
getArguments() |
java.util.List<java.lang.String> |
getEnvironmentMetadataKeys() |
KeyValuePairSet |
getEnvironmentProperties() |
java.lang.String |
getExecutablePath() |
java.lang.Boolean |
getQuoteHandling() |
java.lang.Integer |
getSuccessExitCode() |
java.lang.String |
getWorkingDirectory() |
void |
setArguments(java.util.List<CommandArgument> l)
Specifies a list of command line arguments to be passed into the executable
|
void |
setEnvironmentMetadataKeys(java.util.List<java.lang.String> l)
Specifies any metadata keys that should be specified as Environment Variables.
|
void |
setEnvironmentProperties(KeyValuePairSet env)
Specifies any fixed value environment variables that are necessary.
|
void |
setExecutablePath(java.lang.String executable)
Specifies the executable to be invoke.
|
void |
setQuoteHandling(java.lang.Boolean b)
Specify whether to handle quotes or not.
|
void |
setSuccessExitCode(java.lang.Integer i)
Set the exit code value that is considered successful.
|
void |
setWorkingDirectory(java.lang.String wd)
Specify the working directory for the process.
|
public org.apache.commons.exec.CommandLine createCommandLine(AdaptrisMessage msg)
CommandBuilder
ProcessBuilder
object from the available data.createCommandLine
in interface CommandBuilder
msg
- the AdaptrisMessageProcessBuilder
public java.util.Map<java.lang.String,java.lang.String> createEnvironment(AdaptrisMessage msg)
CommandBuilder
createEnvironment
in interface CommandBuilder
msg
- the message.Executor.execute(CommandLine, Map)
. If null, then the default environment is used.public org.apache.commons.exec.Executor configure(org.apache.commons.exec.Executor exe)
CommandBuilder
Executor
.configure
in interface CommandBuilder
exe
- the Executor to configure.public java.util.List<java.lang.String> getEnvironmentMetadataKeys()
public void setEnvironmentMetadataKeys(java.util.List<java.lang.String> l)
Each key, if available as metadata, will become the environment variable with each corresponding value, the value.
l
- public void addEnvironmentMetadataKey(java.lang.String key)
public java.lang.String getWorkingDirectory()
public void setWorkingDirectory(java.lang.String wd)
wd
- the working directory; defaults to nullpublic KeyValuePairSet getEnvironmentProperties()
public void setEnvironmentProperties(KeyValuePairSet env)
env
- public java.lang.String getExecutablePath()
public void setExecutablePath(java.lang.String executable)
This can be an absolute path or else simply the name of an executable on the PATH. Examples might be "/bin/ls" or "echo" on Unix. Note that this defaults to null, which might create undefined behaviour.
executable
- public java.util.List<CommandArgument> getArguments()
public void setArguments(java.util.List<CommandArgument> l)
l
- the argumentspublic void addArgument(CommandArgument arg)
public java.lang.Integer getSuccessExitCode()
public void setSuccessExitCode(java.lang.Integer i)
i
- the exit code that is successful; defaults to 0 if not explicitly set.public java.lang.Boolean getQuoteHandling()
public void setQuoteHandling(java.lang.Boolean b)
If any argument doesn't include spaces or quotes, return it as is. If it contains double quotes, use single quotes - else surround the argument by double quotes.
b
- true or false, if not specified defaults to false.CommandLine.addArgument(String, boolean)