Class ProcessUnit.ProcessUnitBuilder
java.lang.Object
de.iip_ecosphere.platform.configuration.maven.ProcessUnit.ProcessUnitBuilder
- Enclosing class:
ProcessUnit
Creates process units.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionProcessUnitBuilder(String description, de.iip_ecosphere.platform.tools.maven.python.Logger logger) Creates a process builder instance. -
Method Summary
Modifier and TypeMethodDescriptionaddArgument(boolean enable, Object argument) Adds a conditional command line argument.addArgument(Object argument) Adds a command line argument.addArgumentOrScriptCommand(boolean cmdAsScript, String cmd) Addscmdas a script (also if inProcessUnit.SCRIPT_NAMES) or as argument.Addscmdas a script (also if inProcessUnit.SCRIPT_NAMES) or as argument.addArguments(String... arguments) Adds command line arguments.addArguments(List<String> arguments) Adds command line arguments.addCheckRegEx(Pattern regEx) Adds a checking regular expression on the logging.Adds the maven command (shall be used for arguments).addShellScriptCommand(String scriptName) Adds a shell command (shall be used for arguments).addShellScriptCommand(String scriptName, String extension) Adds a shell script command (shall be used for arguments).private booleanAppends an argument by aggregation if enabled throughenableArgumentAggregation().build()Builds the process.Builds the process.private voidEnables argument aggregation if needed, i.e., some command lines require complex arguments to be aggregated into a single argument.private StringReturns the maven path.private StringReturns the path for NodeJS.Sets the logging to a given file.private StringprependPath(String path, String cmd) Prependspathbeforecmdas file system path.Redirects the process error stream so that it appears as input stream.Sets the process home directory.setListener(ProcessUnit.TerminationListener listener) Sets a termination listener.setNodeJsHome(String home) Changes the nodejs home/bin directory, i.e., the directory where the bin files are located, which is usually in Windows the home directory, in linux the bin sub-directory.setNotifyListenerByLogMatch(boolean notifyByLogMatch) Sets whether the process listener shall be informed on a complete log regEx match, terminating the process if there is no listener.setRegExConjunction(boolean conjunct) Sets the log regEx aggregation mode, either conjunction or disjunction.setTimeout(long timeout) Sets the lifetime/timeout of the process.
-
Field Details
-
description
-
args
-
home
-
logger
private de.iip_ecosphere.platform.tools.maven.python.Logger logger -
timeout
private long timeout -
logFile
-
checkRegEx
-
listener
-
notifyByLogMatch
private boolean notifyByLogMatch -
conjunctLogMatches
private boolean conjunctLogMatches -
argAggregate
-
argAggregateStart
-
argAggregateEnd
-
err2In
private boolean err2In -
nodejsHome
-
-
Constructor Details
-
ProcessUnitBuilder
public ProcessUnitBuilder(String description, de.iip_ecosphere.platform.tools.maven.python.Logger logger) Creates a process builder instance.- Parameters:
description- the description of the unitlogger- the logger, may be null then aStandardLoggeris used
-
-
Method Details
-
logTo
Sets the logging to a given file.- Parameters:
logFile- the file to log to- Returns:
- this (builder style)
-
addCheckRegEx
Adds a checking regular expression on the logging.- Parameters:
regEx- the regular expression- Returns:
- this (builder style)
-
setRegExConjunction
Sets the log regEx aggregation mode, either conjunction or disjunction.- Parameters:
conjunct- iftruethe default, all regular expressions must match, iffalseonly one- Returns:
- this (builder style)
-
setHome
Sets the process home directory.- Parameters:
home- the home directory- Returns:
- this (builder style)
-
redirectErr2In
Redirects the process error stream so that it appears as input stream.- Returns:
- this (builder style)
-
addMavenCommand
Adds the maven command (shall be used for arguments).- Returns:
- this (builder style)
-
getMavenPath
Returns the maven path.- Returns:
- the maven path
-
prependPath
Prependspathbeforecmdas file system path.- Parameters:
path- the path, may be empty/null (ignored)cmd- the command- Returns:
- the composed path (if not ignored) and command separated by a file separator
-
setNodeJsHome
Changes the nodejs home/bin directory, i.e., the directory where the bin files are located, which is usually in Windows the home directory, in linux the bin sub-directory.- Parameters:
home- the home directory, ignored if null or empty- Returns:
- this for chaining
-
getNodeJsPath
Returns the path for NodeJS.- Returns:
- the path, may be empty for unknown
-
addShellScriptCommand
Adds a shell command (shall be used for arguments). Prefixes a command processor for windows and a "./" for the others.- Parameters:
scriptName- the script name without extension (adding "bat" for windows and "sh" else)- Returns:
- this (builder style)
- See Also:
-
addShellScriptCommand
Adds a shell script command (shall be used for arguments). Prefixes a command processor for windows and a "./" for the others.- Parameters:
scriptName- the script name without extensionextension- the extension (may be empty, start with "." or just be the extension)- Returns:
- this (builder style)
- See Also:
-
enableArgumentAggregation
private void enableArgumentAggregation()Enables argument aggregation if needed, i.e., some command lines require complex arguments to be aggregated into a single argument. If no aggregation is needed, arguments are added directly toargs. -
appendByAggregation
Appends an argument by aggregation if enabled throughenableArgumentAggregation().- Parameters:
arg- the argument(s)- Returns:
trueifargwas not processed,falseifargwas processed and does not need further aggregation
-
addArgumentOrScriptCommand
Addscmdas a script (also if inProcessUnit.SCRIPT_NAMES) or as argument.- Parameters:
cmd- the script name- Returns:
- this (builder style)
- See Also:
-
addArgumentOrScriptCommand
Addscmdas a script (also if inProcessUnit.SCRIPT_NAMES) or as argument.- Parameters:
cmdAsScript- iscmdis a script commandcmd- the script name- Returns:
- this (builder style)
-
addArgument
Adds a conditional command line argument.- Parameters:
enable- the condition resultargument- the argument- Returns:
- this (builder style)
-
addArgument
Adds a command line argument.- Parameters:
argument- the argument- Returns:
- this (builder style)
-
addArguments
Adds command line arguments.- Parameters:
arguments- the arguments (may be null, ignored)- Returns:
- this (builder style)
-
addArguments
Adds command line arguments.- Parameters:
arguments- the arguments- Returns:
- this (builder style)
-
setTimeout
Sets the lifetime/timeout of the process.- Parameters:
timeout- the timeout in milliseconds, default is 0, ignored if not positive- Returns:
- this (builder style)
-
setNotifyListenerByLogMatch
Sets whether the process listener shall be informed on a complete log regEx match, terminating the process if there is no listener.- Parameters:
notifyByLogMatch- notify the listener by a complete log match or not (default istrue)- Returns:
- this (builder style)
-
setListener
Sets a termination listener.- Parameters:
listener- the listener, may be null for none- Returns:
- this (builder style)
-
build4Mvn
Builds the process.- Returns:
- the process unit
- Throws:
org.apache.maven.plugin.MojoExecutionException- if creating the process fails
-
build
Builds the process.- Returns:
- the process unit
- Throws:
IOException- if creating the process fails
-