Package com.bc.ceres.core
Class ProcessObserver
- java.lang.Object
-
- com.bc.ceres.core.ProcessObserver
-
public class ProcessObserver extends Object
An observer that notifies itshandlers
about lines of characters that have been written by a process to bothstdout
andstderr
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 Classes Modifier and Type Class Description static class
ProcessObserver.DefaultHandler
Default implementation ofProcessObserver.Handler
, which simply prints observations to the console.static interface
ProcessObserver.Handler
A handler that will be notified during the observation of the process.static class
ProcessObserver.Mode
The observation mode.static interface
ProcessObserver.ObservedProcess
The observed process.
-
Constructor Summary
Constructors Constructor Description ProcessObserver(Process process)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProcessObserver.Handler
getHandler()
ProcessObserver.Mode
getMode()
String
getName()
int
getPollPeriod()
ProgressMonitor
getProgressMonitor()
ProcessObserver
setHandler(ProcessObserver.Handler handler)
Default-handler prints to stdout / stderr.ProcessObserver
setMode(ProcessObserver.Mode mode)
Default isProcessObserver.Mode.BLOCKING
.ProcessObserver
setName(String name)
Default is "process".ProcessObserver
setPollPeriod(int pollPeriod)
Default is 500 milliseconds.ProcessObserver
setProgressMonitor(ProgressMonitor progressMonitor)
Default does nothing.ProcessObserver.ObservedProcess
start()
Starts observing the given process.
-
-
-
Constructor Detail
-
ProcessObserver
public ProcessObserver(Process process)
Constructor.- Parameters:
process
- The process to be observed
-
-
Method Detail
-
getName
public String getName()
- Returns:
- A name that represents the process.
-
setName
public ProcessObserver setName(String name)
Default is "process".- Parameters:
name
- A name that represents the process.- Returns:
- this
-
getHandler
public ProcessObserver.Handler getHandler()
- Returns:
- A handler.
-
setHandler
public ProcessObserver setHandler(ProcessObserver.Handler handler)
Default-handler prints to stdout / stderr.- Parameters:
handler
- A handler.- Returns:
- this
-
getProgressMonitor
public ProgressMonitor getProgressMonitor()
- Returns:
- A progress monitor.
-
setProgressMonitor
public ProcessObserver setProgressMonitor(ProgressMonitor progressMonitor)
Default does nothing.- Parameters:
progressMonitor
- A progress monitor.- Returns:
- this
-
getMode
public ProcessObserver.Mode getMode()
- Returns:
- The observation mode.
-
setMode
public ProcessObserver setMode(ProcessObserver.Mode mode)
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
public ProcessObserver setPollPeriod(int pollPeriod)
Default is 500 milliseconds.- Parameters:
pollPeriod
- Time in milliseconds between successive process status queries.- Returns:
- this
-
start
public ProcessObserver.ObservedProcess start()
Starts observing the given process.
-
-