本文整理汇总了Java中javax.management.NotificationFilter.isNotificationEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java NotificationFilter.isNotificationEnabled方法的具体用法?Java NotificationFilter.isNotificationEnabled怎么用?Java NotificationFilter.isNotificationEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.NotificationFilter
的用法示例。
在下文中一共展示了NotificationFilter.isNotificationEnabled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendNotification
import javax.management.NotificationFilter; //导入方法依赖的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) ;
}
}
}
}
示例2: apply
import javax.management.NotificationFilter; //导入方法依赖的package包/类
public void apply(List<TargetedNotification> targetedNotifs,
ObjectName source, Notification notif) {
// We proceed in two stages here, to avoid holding the listenerMap
// lock while invoking the filters (which are user code).
final IdAndFilter[] candidates;
synchronized (listenerMap) {
final Set<IdAndFilter> set = listenerMap.get(source);
if (set == null) {
logger.debug("bufferFilter", "no listeners for this name");
return;
}
candidates = new IdAndFilter[set.size()];
set.toArray(candidates);
}
// We don't synchronize on targetedNotifs, because it is a local
// variable of our caller and no other thread can see it.
for (IdAndFilter idaf : candidates) {
final NotificationFilter nf = idaf.getFilter();
if (nf == null || nf.isNotificationEnabled(notif)) {
logger.debug("bufferFilter", "filter matches");
final TargetedNotification tn =
new TargetedNotification(notif, idaf.getId());
if (allowNotificationEmission(source, tn))
targetedNotifs.add(tn);
}
}
}
示例3: makeFilter
import javax.management.NotificationFilter; //导入方法依赖的package包/类
private static NotificationBufferFilter makeFilter(final Integer id,
final ObjectName pattern,
final NotificationFilter filter) {
return new NotificationBufferFilter() {
public void apply(List<TargetedNotification> notifs,
ObjectName source, Notification notif) {
if (pattern.apply(source)) {
if (filter == null || filter.isNotificationEnabled(notif))
notifs.add(new TargetedNotification(notif, id));
}
}
};
}