?? jmxnotificationspollmanager.java
字號(hào):
package org.sadun.util.polling;
import java.io.File;
import javax.management.ListenerNotFoundException;
import javax.management.NotificationBroadcasterSupport;
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import javax.management.ObjectName;
/**
* A PollManager which produces JMX notifications corresponding to base DirectoryPoller events.
*
* @author Cristiano Sadun
*/
class JMXNotificationsPollManager implements PollManager {
private NotificationBroadcasterSupport ns = new NotificationBroadcasterSupport();
private final static boolean debug = false;
private SequenceNumberGenerator sqg;
private ObjectName pollerName;
public JMXNotificationsPollManager(ObjectName pollerName, SequenceNumberGenerator sqg) {
this.pollerName=pollerName;
this.sqg=sqg;
}
public void cycleEnded(CycleEndEvent evt) {
if (debug) logEvent(evt);
ns.sendNotification(new CycleEndJMXNotification(pollerName, sqg, evt));
}
public void cycleStarted(CycleStartEvent evt) {
if (debug) logEvent(evt);
ns.sendNotification(new CycleStartJMXNotification(pollerName, sqg, evt));
}
public void directoryLookupEnded(DirectoryLookupEndEvent evt) {
if (debug) logEvent(evt);
ns.sendNotification(new DirectoryLookupEndJMXNotification(pollerName, sqg, evt));
}
public void directoryLookupStarted(DirectoryLookupStartEvent evt) {
if (debug) logEvent(evt);
ns.sendNotification(new DirectoryLookupStartJMXNotification(pollerName, sqg, evt));
}
public void exceptionDeletingTargetFile(File target) {
if (debug) logException(target, null);
ns.sendNotification(new ExceptionDeletingTargetFileJMXNotification(pollerName, sqg, target));
}
public void exceptionMovingFile(File file, File dest) {
if (debug) logException(file, dest);
ns.sendNotification(new ExceptionMovingFileJMXNotification(pollerName, sqg, file, dest));
}
public void fileFound(FileFoundEvent evt) {
if (debug) logEvent(evt);
ns.sendNotification(new FileFoundJMXNotification(pollerName, sqg, evt));
}
public void fileMoved(FileMovedEvent evt) {
if (debug) logEvent(evt);
ns.sendNotification(new FileMovedJMXNotification(pollerName, sqg, evt));
}
public void fileSetFound(FileSetFoundEvent evt) {
if (debug) logEvent(evt);
ns.sendNotification(new FileSetFoundJMXNotification(pollerName, sqg, evt));
}
public void addListener(NotificationListener listener, NotificationFilter filter, Object handback) {
ns.addNotificationListener(listener, filter,handback);
}
public void removeListener(NotificationListener listener) throws ListenerNotFoundException {
ns.removeNotificationListener(listener);
}
private static void logEvent(BasePollerEvent evt) {
System.out.println(evt);
}
private static void logException(File target, File dest) {
System.out.println("Exception "+(dest != null ? "moving" : "deleting")+" "+target);
}
public String toString() {
return "An internal pollmanager dispatching JMX notifications corresponding to basic events";
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -