1 23 24 37 package com.sun.enterprise.server; 38 39 import java.util.HashSet ; 40 import java.util.TimerTask ; 41 import java.util.Timer ; 42 43 50 abstract class AbstractMonitor extends TimerTask { 51 52 53 protected HashSet _monitoredEntries; 54 55 56 protected Timer _timer; 57 58 59 protected long _pollInterval; 60 61 66 AbstractMonitor(long pollInterval) { 67 this._pollInterval = pollInterval; 68 this._monitoredEntries = new HashSet (); 69 } 70 71 74 void start() { 75 this._timer = new Timer (true); 76 this._timer.schedule(this, 0, this._pollInterval); 77 } 78 79 82 void stop() { 83 if (this._timer != null) { 84 this._timer.cancel(); 85 } 86 } 87 88 93 void addMonitorableEntry(MonitorableEntry entry) { 94 95 synchronized (this._monitoredEntries) { 96 this._monitoredEntries.add(entry); 97 } 98 } 99 100 105 void removeMonitorableEntry(MonitorableEntry entry) { 106 107 synchronized (this._monitoredEntries) { 108 this._monitoredEntries.remove(entry); 109 } 110 } 111 } 112 | Popular Tags |