// Check that notification filtering works
NotificationFilter senderFilter = new NotificationFilter() {
public boolean isNotificationEnabled(Notification n) {
if (!(n instanceof MBeanServerNotification))
return false;
MBeanServerNotification mbsn = (MBeanServerNotification) n;
return (mbsn.getMBeanName().equals(senderName));
}
};
Integer senderListenerId = new Integer(88);
NotificationBufferFilter senderListenerFilter =
makeFilter(senderListenerId, wildcardName, senderFilter);
nr = nb.fetchNotifications(senderListenerFilter, 0, 1000L,
Integer.MAX_VALUE);
tns = nr.getTargetedNotifications();
if (tns.length != 1) {
System.out.println("Expected 1 notif, got: " + Arrays.asList(tns));
return false;
}
MBeanServerNotification mbsn =
(MBeanServerNotification) tns[0].getNotification();
if (!mbsn.getMBeanName().equals(senderName)) {
System.out.println("Expected notif with senderName, got: " +
mbsn + " (" + mbsn.getMBeanName() + ")");
return false;
}
System.out.println("Successfully applied NotificationFilter, OK");
// Now send 8 notifs to fill up our 10-element buffer