當前位置: 首頁>>代碼示例>>Java>>正文


Java NotificationListener.handleNotification方法代碼示例

本文整理匯總了Java中javax.management.NotificationListener.handleNotification方法的典型用法代碼示例。如果您正苦於以下問題:Java NotificationListener.handleNotification方法的具體用法?Java NotificationListener.handleNotification怎麽用?Java NotificationListener.handleNotification使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.management.NotificationListener的用法示例。


在下文中一共展示了NotificationListener.handleNotification方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: notify

import javax.management.NotificationListener; //導入方法依賴的package包/類
/**
 * Return true if the notification was sent successfully, false otherwise.
 * @param type
 * @param message
 * @return true if the notification succeeded
 */
public boolean notify(final String type, String message) {
    try {
        Notification n = new Notification(
                type,
                this,
                sequence.incrementAndGet(),
                System.currentTimeMillis(),
                "["+type+"] "+message);
        sendNotification(n);
        for (NotificationListener listener : listeners) {
            listener.handleNotification(n,this);
        }
        return true;
    }catch (Exception x) {
        if (log.isDebugEnabled()) {
            log.debug("Notify failed. Type="+type+"; Message="+message,x);
        }
        return false;
    }

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:28,代碼來源:ConnectionPool.java

示例2: sendNotification

import javax.management.NotificationListener; //導入方法依賴的package包/類
/**
 * Enable this <CODE>SnmpMibTable</CODE> to send a notification.
 *
 * <p>
 * @param notification The notification to send.
 */
private synchronized void sendNotification(Notification notification) {

    // loop on listener
    //
    for(java.util.Enumeration<NotificationListener> k = handbackTable.keys();
        k.hasMoreElements(); ) {

        NotificationListener listener = k.nextElement();

        // Get the associated handback list and the associated filter list
        //
        java.util.Vector<?> handbackList = handbackTable.get(listener) ;
        java.util.Vector<NotificationFilter> filterList =
            filterTable.get(listener) ;

        // loop on handback
        //
        java.util.Enumeration<NotificationFilter> f = filterList.elements();
        for(java.util.Enumeration<?> h = handbackList.elements();
            h.hasMoreElements(); ) {

            Object handback = h.nextElement();
            NotificationFilter filter = f.nextElement();

            if ((filter == null) ||
                 (filter.isNotificationEnabled(notification))) {

                listener.handleNotification(notification,handback) ;
            }
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:39,代碼來源:SnmpMibTable.java

示例3: dispatchNotification

import javax.management.NotificationListener; //導入方法依賴的package包/類
void dispatchNotification(TargetedNotification tn,
                          Integer myListenerID,
                          Map<Integer, ClientListenerInfo> listeners) {
    final Notification notif = tn.getNotification();
    final Integer listenerID = tn.getListenerID();

    if (listenerID.equals(myListenerID)) return;
    final ClientListenerInfo li = listeners.get(listenerID);

    if (li == null) {
        logger.trace("NotifFetcher.dispatch",
                     "Listener ID not in map");
        return;
    }

    NotificationListener l = li.getListener();
    Object h = li.getHandback();
    try {
        l.handleNotification(notif, h);
    } catch (RuntimeException e) {
        final String msg =
            "Failed to forward a notification " +
            "to a listener";
        logger.trace("NotifFetcher-run", msg, e);
    }

}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:28,代碼來源:ClientNotifForwarder.java


注:本文中的javax.management.NotificationListener.handleNotification方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。