Methods Summary |
---|
public synchronized void | checkException()This method will rethrow the exception that was possibly caught during
the run of the process. It will only remains valid once the process has
been terminated either by 'error', timeout or manual intervention.
Information will be discarded once a new process is ran.
if (caught != null) {
throw new BuildException("Exception in ExecuteWatchdog.run: "
+ caught.getMessage(), caught);
}
|
protected synchronized void | cleanUp()reset the monitor flag and the process.
watch = false;
process = null;
|
public boolean | isWatching()Indicates whether or not the watchdog is still monitoring the process.
return watch;
|
public boolean | killedProcess()Indicates whether the last process run was killed on timeout or not.
return killedProcess;
|
public synchronized void | start(java.lang.Process process)Watches the given process and terminates it, if it runs for too long.
All information from the previous run are reset.
if (process == null) {
throw new NullPointerException("process is null.");
}
if (this.process != null) {
throw new IllegalStateException("Already running.");
}
this.caught = null;
this.killedProcess = false;
this.watch = true;
this.process = process;
watchdog.start();
|
public synchronized void | stop()Stops the watcher. It will notify all threads possibly waiting
on this object.
watchdog.stop();
cleanUp();
|
public synchronized void | timeoutOccured(org.apache.tools.ant.util.Watchdog w)Called after watchdog has finished.
This can be called in the watchdog thread
try {
try {
// We must check if the process was not stopped
// before being here
process.exitValue();
} catch (IllegalThreadStateException itse) {
// the process is not terminated, if this is really
// a timeout and not a manual stop then kill it.
if (watch) {
killedProcess = true;
process.destroy();
}
}
} catch (Exception e) {
caught = e;
} finally {
cleanUp();
}
|