use of javax.management.NotificationFilter in project jdk8u_jdk by JetBrains.
the class DirectoryScannerTest method doTestOperation.
private void doTestOperation(DirectoryScannerMXBean proxy, Call op, EnumSet<ScanState> after, String testName) throws Exception {
System.out.println("doTestOperation: " + testName);
final LinkedBlockingQueue<Notification> queue = new LinkedBlockingQueue<Notification>();
NotificationListener listener = new NotificationListener() {
public void handleNotification(Notification notification, Object handback) {
try {
queue.put(notification);
} catch (Exception x) {
System.err.println("Failed to queue notif: " + x);
}
}
};
NotificationFilter filter = null;
Object handback = null;
final ScanState before;
final NotificationEmitter emitter = (NotificationEmitter) makeNotificationEmitter(proxy, DirectoryScannerMXBean.class);
emitter.addNotificationListener(listener, filter, handback);
before = proxy.getState();
op.call();
try {
final Notification notification = queue.poll(3000, TimeUnit.MILLISECONDS);
assertEquals(AttributeChangeNotification.ATTRIBUTE_CHANGE, notification.getType());
assertEquals(AttributeChangeNotification.class, notification.getClass());
assertEquals(getObjectName(proxy), notification.getSource());
AttributeChangeNotification acn = (AttributeChangeNotification) notification;
assertEquals("State", acn.getAttributeName());
assertEquals(ScanState.class.getName(), acn.getAttributeType());
assertEquals(before, ScanState.valueOf((String) acn.getOldValue()));
assertContained(after, ScanState.valueOf((String) acn.getNewValue()));
emitter.removeNotificationListener(listener, filter, handback);
} finally {
try {
op.cancel();
} catch (Exception x) {
System.err.println("Failed to cleanup: " + x);
}
}
}
use of javax.management.NotificationFilter in project felix by apache.
the class RMIConnectionInvoker method addNotificationListener.
public void addNotificationListener(ObjectName name, ObjectName listener, MarshalledObject filter, MarshalledObject handback, Subject delegate) throws InstanceNotFoundException, IOException {
NotificationFilter f = (NotificationFilter) RMIMarshaller.unmarshal(filter, server.getClassLoaderFor(name), defaultLoader);
Object h = RMIMarshaller.unmarshal(handback, server.getClassLoaderFor(name), defaultLoader);
server.addNotificationListener(name, listener, f, h);
}
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();
}
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();
}
Aggregations