|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.exec.ExecuteWatchdog
public class ExecuteWatchdog
Destroys a process running for too long. For example:
ExecuteWatchdog watchdog = new ExecuteWatchdog(30000);
Execute exec = new Execute(myloghandler, watchdog);
exec.setCommandLine(mycmdline);
int exitvalue = exec.execute();
if (Execute.isFailure(exitvalue) && watchdog.killedProcess()) {
// it was killed on purpose by the watchdog
}
Executor,
Watchdog| Constructor Summary | |
|---|---|
ExecuteWatchdog(long timeout)
Creates a new watchdog with a given timeout. |
|
| Method Summary | |
|---|---|
void |
checkException()
This method will rethrow the exception that was possibly caught during the run of the process. |
protected void |
cleanUp()
reset the monitor flag and the process. |
void |
destroyProcess()
Destroys the running process manually. |
boolean |
isWatching()
Indicates whether or not the watchdog is still monitoring the process. |
boolean |
killedProcess()
Indicates whether the last process run was killed. |
void |
start(Process process)
Watches the given process and terminates it, if it runs for too long. |
void |
stop()
Stops the watcher. |
void |
timeoutOccured(Watchdog w)
Called after watchdog has finished. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ExecuteWatchdog(long timeout)
timeout - the timeout for the process in milliseconds. It must be
greater than 0.| Method Detail |
|---|
public void start(Process process)
process - the process to monitor. It cannot be null
IllegalStateException - if a process is still being monitored.public void stop()
public void destroyProcess()
public void timeoutOccured(Watchdog w)
timeoutOccured in interface TimeoutObserverw - the watchdog that timed out.
public void checkException()
throws Exception
Exception - a wrapped exception over the one that was silently swallowed
and stored during the process run.public boolean isWatching()
public boolean killedProcess()
protected void cleanUp()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||