use of javax.management.NotificationFilter in project jdk8u_jdk by JetBrains.
the class SnmpMibTable method sendNotification.
// ----------------------------------------------------------------------
// PRIVATE METHODS
// ----------------------------------------------------------------------
/**
* Enable this <CODE>SnmpMibTable</CODE> to send a notification.
*
* <p>
* @param notification The notification to send.
*/
private synchronized void sendNotification(Notification notification) {
//
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);
}
}
}
}
use of javax.management.NotificationFilter in project camel by apache.
the class JMXMonitorConsumer method addNotificationListener.
@Override
protected void addNotificationListener() throws Exception {
JMXEndpoint ep = (JMXEndpoint) getEndpoint();
// create the monitor bean
Monitor bean = null;
if (ep.getMonitorType().equals("counter")) {
CounterMonitor counter = new CounterMonitor();
Number initThreshold = convertNumberToAttributeType(ep.getInitThreshold(), ep.getJMXObjectName(), ep.getObservedAttribute());
Number offset = convertNumberToAttributeType(ep.getOffset(), ep.getJMXObjectName(), ep.getObservedAttribute());
Number modulus = convertNumberToAttributeType(ep.getModulus(), ep.getJMXObjectName(), ep.getObservedAttribute());
counter.setInitThreshold(initThreshold);
counter.setOffset(offset);
counter.setModulus(modulus);
counter.setDifferenceMode(ep.isDifferenceMode());
counter.setNotify(true);
bean = counter;
} else if (ep.getMonitorType().equals("gauge")) {
GaugeMonitor gm = new GaugeMonitor();
gm.setNotifyHigh(ep.isNotifyHigh());
gm.setNotifyLow(ep.isNotifyLow());
gm.setDifferenceMode(ep.isDifferenceMode());
Number highValue = convertNumberToAttributeType(ep.getThresholdHigh(), ep.getJMXObjectName(), ep.getObservedAttribute());
Number lowValue = convertNumberToAttributeType(ep.getThresholdLow(), ep.getJMXObjectName(), ep.getObservedAttribute());
gm.setThresholds(highValue, lowValue);
bean = gm;
} else if (ep.getMonitorType().equals("string")) {
StringMonitor sm = new StringMonitor();
sm.setNotifyDiffer(ep.isNotifyDiffer());
sm.setNotifyMatch(ep.isNotifyMatch());
sm.setStringToCompare(ep.getStringToCompare());
bean = sm;
}
bean.addObservedObject(ep.getJMXObjectName());
bean.setObservedAttribute(ep.getObservedAttribute());
bean.setGranularityPeriod(ep.getGranularityPeriod());
// register the bean
mMonitorObjectName = new ObjectName(ep.getObjectDomain(), "name", "camel-jmx-monitor-" + UUID.randomUUID());
ManagementFactory.getPlatformMBeanServer().registerMBean(bean, mMonitorObjectName);
// add ourselves as a listener to it
NotificationFilter nf = ep.getNotificationFilter();
getServerConnection().addNotificationListener(mMonitorObjectName, this, nf, bean);
bean.start();
}
use of javax.management.NotificationFilter in project camel by apache.
the class JMXConsumer method addNotificationListener.
/**
* Adds a notification listener to the target bean.
* @throws Exception
*/
protected void addNotificationListener() throws Exception {
JMXEndpoint ep = (JMXEndpoint) getEndpoint();
NotificationFilter nf = ep.getNotificationFilter();
ObjectName objectName = ep.getJMXObjectName();
getServerConnection().addNotificationListener(objectName, this, nf, ep.getHandback());
}
use of javax.management.NotificationFilter in project quasar by puniverse.
the class MonitoringServices method addPerfNotificationListener.
public synchronized void addPerfNotificationListener(NotificationListener listener, Object handback) {
timer.addNotificationListener(listener, new NotificationFilter() {
@Override
public boolean isNotificationEnabled(Notification notification) {
return "perfTimer".equals(notification.getType());
}
}, handback);
perfTimerListeners++;
manageTimer();
}
use of javax.management.NotificationFilter in project quasar by puniverse.
the class MonitoringServices method addStructuralNotificationListener.
public synchronized void addStructuralNotificationListener(NotificationListener listener, Object handback) {
timer.addNotificationListener(listener, new NotificationFilter() {
@Override
public boolean isNotificationEnabled(Notification notification) {
return "structTimer".equals(notification.getType());
}
}, handback);
structuralTimerListeners++;
manageTimer();
}
Aggregations