Class ProcessUnit
java.lang.Object
de.iip_ecosphere.platform.configuration.maven.ProcessUnit
Represents a process.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classConsumes matching log regEx until all required are matched.private static classHandles an input stream.static classCreates process units.static interfaceIn-Process termination listener.static enumDenotes the reason for termination. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateProcessUnit(String description, Process process, long timeout, ProcessUnit.TerminationListener listener, List<Pattern> checkRegEx, de.iip_ecosphere.platform.tools.maven.python.Logger logger) Creates a process unit. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidattach(ProcessUnit.InputStreamHandler handler) Attaches a handler.private voidAttaches a closeable.Returns the check regEx of this unit.Returns the description of the unit.intReturns the exit status of the contained process.booleanReturns whether the regular expressions for process logging specified during creation matched so far.static StringReturns the maven bin folder viaPROP_MAVEN_BIN.private voidHandles a listener notification and decides about stopping the process, either as the reason requires immediate stop or as the listener decides.booleanReturns whether this unit has regEx to check.static booleanisFailed(int status) booleanReturns whether the contained process is (still) running.static booleanisSuccess(int status) private voidnotifyLogMatches(boolean terminateByLogMatch) Called when there is a log-regex matching result.private static voidSplits the OS path into path elements.intstop()Stops the process.intwaitFor()Waits for the process to end if it has been started.
-
Field Details
-
PROP_MAVEN_BIN
- See Also:
-
SCRIPT_NAMES
-
WIN_BAT_PREFIX
-
UNKOWN_EXIT_STATUS
public static final int UNKOWN_EXIT_STATUS- See Also:
-
timer
-
description
-
process
-
timeoutTask
-
closeables
-
logMatches
private boolean logMatches -
checkRegEx
-
logger
private de.iip_ecosphere.platform.tools.maven.python.Logger logger -
listener
-
-
Constructor Details
-
ProcessUnit
private ProcessUnit(String description, Process process, long timeout, ProcessUnit.TerminationListener listener, List<Pattern> checkRegEx, de.iip_ecosphere.platform.tools.maven.python.Logger logger) Creates a process unit.- Parameters:
description- the descriptionprocess- the process being executedtimeout- maximum lifetime ofprocessin milliseconds, ignored if not positivelistener- optional listener to be called when the execution/testing termination is reached, null for nonecheckRegEx- the regular expressions to be applied to the log outputlogger- the logging instance
-
-
Method Details
-
attach
Attaches a handler.- Parameters:
handler- the handler to be attached
-
attach
Attaches a closeable.- Parameters:
closeable- the closeable to attache
-
notifyLogMatches
private void notifyLogMatches(boolean terminateByLogMatch) Called when there is a log-regex matching result.- Parameters:
terminateByLogMatch- terminate the process by a log match or not
-
handleListenerNotification
Handles a listener notification and decides about stopping the process, either as the reason requires immediate stop or as the listener decides.- Parameters:
reason- the reason for the notification.
-
getLogMatches
public boolean getLogMatches()Returns whether the regular expressions for process logging specified during creation matched so far.- Returns:
truefor match,falseelse (default)
-
getExitValue
public int getExitValue()Returns the exit status of the contained process. Only returns a value if the process came to an end by itself, i.e., not terminated by a timeout or by a log match.- Returns:
- the process exit value,
UNKOWN_EXIT_STATUSfor unknown
-
isFailed
public static boolean isFailed(int status) - Parameters:
status- the status to check- Returns:
trueif failed,falsemay be running, not started or successful
-
isSuccess
public static boolean isSuccess(int status) - Parameters:
status- the status to check- Returns:
trueif successful,falseif running, not started or failed
-
getMavenBinPath
Returns the maven bin folder viaPROP_MAVEN_BIN.- Returns:
- the maven bin folder, may be null
-
getDescription
Returns the description of the unit.- Returns:
- the description
-
getCheckRegEx
Returns the check regEx of this unit.- Returns:
- the regEx, may be null
-
hasCheckRegEx
public boolean hasCheckRegEx()Returns whether this unit has regEx to check.- Returns:
trueif there are regEx,falseelse
-
isRunning
public boolean isRunning()Returns whether the contained process is (still) running.- Returns:
trueif the process is running,falseelse
-
waitFor
public int waitFor()Waits for the process to end if it has been started.- Returns:
- the process exit value
-
splitPath
Splits the OS path into path elements.- Parameters:
pathEltConsumer- the element consumer
-
stop
public int stop()Stops the process.- Returns:
- the
exit status
-