|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.cafesoft.core.util.MonitoredProcess
MonitoredProcess encapsulates a native java.lang.Process created using one of the java.lang.Runtime.exec() methods. The Process is monitored in a new Thread, with additional Threads reading the System.out and System.err streams. MonitoredProcess enables listeners to asynchronously receive notification of the Process exit status and other runtime exceptions. In addition, the MonitoredProcess can be destroyed at any time. This is useful if the Process does not start within a given period or does not shutdown gracefully.
| Constructor Summary | |
MonitoredProcess(String processName,
Process process,
Logger logger)
Create a new MonitoredProcess. |
|
| Method Summary | |
void |
addMonitoredProcessEventListener(MonitoredProcessEventListener listener)
Add a MonitoredProcessEvent listener to this component. |
void |
destroy()
Destroy the MonitoredProcess. |
int |
getExitValue()
Get the process exit value (valid only if process is not running). |
boolean |
isRunning()
Get the process status. |
static void |
main(String[] arg)
Test a MonitoredProcess. |
void |
removeMonitoredProcessEventListener(MonitoredProcessEventListener listener)
Remove a MonitoredProcessEvent listener from this component. |
boolean |
setDebug(boolean enable)
Enable or disable DEBUG-level messages. |
void |
start()
Start monitoring the Process. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public MonitoredProcess(String processName,
Process process,
Logger logger)
processName - a textual name assigned to the process for
identification within MonitoredProcess events and logged output.process - the java.lang.Process to be monitored.logger - a Logger to which the Process's System.out and
System.err are logged.| Method Detail |
public boolean setDebug(boolean enable)
enable - enable or disable DEBUG-level messages.
public void start()
throws MonitoredProcessException
MonitoredProcessException - if the MonitoredProcess has already
been started.public boolean isRunning()
public int getExitValue()
public void destroy()
public void addMonitoredProcessEventListener(MonitoredProcessEventListener listener)
listener - The listener to addpublic void removeMonitoredProcessEventListener(MonitoredProcessEventListener listener)
listener - The listener to removepublic static void main(String[] arg)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||