Package com.bc.ceres.core
Class ProcessObserver
java.lang.Object
com.bc.ceres.core.ProcessObserver
An observer that notifies its
handlers about lines of characters that have been written
by a process to both stdout and stderr output streams.
TODO Develop External Process Invocation API (EPIA) - idea: use velocity to generate input files + command-line from current context - address that executables might have different extensions (and paths) on different OS (.exe, .bat, .sh) Process Descriptor - name - description - n input descriptors (descriptor: name + type + description) - n output descriptors (descriptor: name + type + description) - n parameter descriptors (descriptor: name + type + description + attributes) - 1 command-line velocity template - 1 relative working directory template - n environment variables templates - n velocity file templates - n static files - n static archives to unpack Process Invocation - prepare context: set environment variables set inputs, outputs, parameters
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefault implementation ofProcessObserver.Handler, which simply prints observations to the console.static interfaceA handler that will be notified during the observation of the process.static enumThe observation mode.static interfaceThe observed process. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetMode()getName()intsetHandler(ProcessObserver.Handler handler) Default-handler prints to stdout / stderr.setMode(ProcessObserver.Mode mode) Default isProcessObserver.Mode.BLOCKING.Default is "process".setPollPeriod(int pollPeriod) Default is 500 milliseconds.setProgressMonitor(ProgressMonitor progressMonitor) Default does nothing.start()Starts observing the given process.
-
Constructor Details
-
ProcessObserver
Constructor.- Parameters:
process- The process to be observed
-
-
Method Details
-
getName
- Returns:
- A name that represents the process.
-
setName
Default is "process".- Parameters:
name- A name that represents the process.- Returns:
- this
-
getHandler
- Returns:
- A handler.
-
setHandler
Default-handler prints to stdout / stderr.- Parameters:
handler- A handler.- Returns:
- this
-
getProgressMonitor
- Returns:
- A progress monitor.
-
setProgressMonitor
Default does nothing.- Parameters:
progressMonitor- A progress monitor.- Returns:
- this
-
getMode
- Returns:
- The observation mode.
-
setMode
Default isProcessObserver.Mode.BLOCKING.- Parameters:
mode- The observation mode.- Returns:
- this
-
getPollPeriod
public int getPollPeriod()- Returns:
- Time in milliseconds between successive process status queries.
-
setPollPeriod
Default is 500 milliseconds.- Parameters:
pollPeriod- Time in milliseconds between successive process status queries.- Returns:
- this
-
start
Starts observing the given process.
-