⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jmxnotificationspollmanager.java

📁 一个简易的轮训小程序 哈哈哈哈哈哈后 嘿嘿嘿嘿黑诶
💻 JAVA
字号:
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";
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -