本文整理匯總了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;
}
}
示例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) ;
}
}
}
}
示例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);
}
}