protected Object createObject() throws SAXException { return new TargetedNotification(notification, listenerID); } }
public void serialize(QName name, Attributes attributes, Object value, SerializationContext context) throws IOException { TargetedNotification targetedNotification = (TargetedNotification)value; context.startElement(name, attributes); context.serialize(NOTIFICATION_QNAME, null, targetedNotification.getNotification()); context.serialize(LISTENER_ID_QNAME, null, targetedNotification.getListenerID()); context.endElement(); }
logger.warning("purgeUnserializable", "cannot serialize notif: " + tn); logger.fine("purgeUnserializable", e); final Integer listenerID = tn.getListenerID(); final Notification badNotif = tn.getNotification(); final String notifType = JMXConnectionNotification.NOTIFS_LOST; final String notifMessage = "Not serializable: " + badNotif; final Notification goodNotif = new JMXConnectionNotification(notifType, badNotif.getSource(), clientId, badNotif.getSequenceNumber(), notifMessage, ONE_LONG); tn = new TargetedNotification(goodNotif, listenerID); trialnr = new NotificationResult(0, 0, new TargetedNotification[] { tn }); try {
final Set<Notification> notifs = new HashSet<>(nr.getTargetedNotifications().length); for (final TargetedNotification targetdNotif: nr.getTargetedNotifications()) { final Notification notif = targetdNotif.getNotification(); if (!notifs.contains(notif)) notifs.add(notif);
/** * @param tn . * @param myListenerID . * @param listeners . */ void dispatchNotification(final TargetedNotification tn, final Integer myListenerID, final Map<Integer, ListenerInfo> listeners) { final Notification notif = tn.getNotification(); final Integer listenerID = tn.getListenerID(); if (listenerID.equals(myListenerID)) return; final ListenerInfo li = listeners.get(listenerID); if (li == null) { logger.trace("NotifFetcher.dispatch", "Listener ID not in map"); return; } final NotificationListener l = li.getListener(); final Object h = li.getHandback(); try { l.handleNotification(notif, h); } catch (final RuntimeException e) { final String msg = "Failed to forward a notification " + "to a listener"; logger.trace("NotifFetcher-run", msg, e); } }
private void addClientNotification(Integer id, Notification notification) { synchronized(clientListenerNotifications) { if(clientListenerNotifications.size() == maxNumberOfNotifications) { clientListenerNotifications.remove(0); startSequence++; } TargetedNotification targetedNotification = new TargetedNotification(notification, id); clientListenerNotifications.add(targetedNotification); currentSequence++; } }
Integer id = targetedNotification.getListenerID(); ClientListenerHolder holder = (ClientListenerHolder)clientListeners.get(id); if(holder != null) final Notification notification = targetedNotification.getNotification(); boolean deliverNotification = true; if(holder.getFilterOnClient())
private void addNotification(Integer id, Notification notification) { buffer.add(new TargetedNotification(notification, id)); }
for (int i = 0; i < len; i++) { final TargetedNotification tn = notifs[i]; final Integer listenerID = tn.getListenerID(); if (!listenerID.equals(forwarder.mbeanRemovedNotifID)) { // check if an mbean unregistration notif final ListenerInfo li = forwarder.infoList.get(listenerID); continue; final Notification notif = tn.getNotification(); final String unreg = MBeanServerNotification.UNREGISTRATION_NOTIFICATION; if (notif instanceof MBeanServerNotification && notif.getType().equals(unreg)) {
/** * We have a candidate notification. See if it matches our filters. We do this outside the synchronized block so we don't hold up everyone accessing the buffer * (including notification senders) while we evaluate potentially slow filters. * @param candidate . * @param listeners . * @return . */ private List<TargetedNotification> matchNotifs(final ArrayNotificationBufferAux.NamedNotification candidate, final Set<ListenerInfo> listeners) { final Notification notif = candidate.getNotification(); final List<TargetedNotification> matchedNotifs = new ArrayList<>(); log.debug("fetchNotifications", "applying filters to candidate"); synchronized (listeners) { for (final ListenerInfo li: listeners) { final NotificationFilter filter = li.getNotificationFilter(); if (log.debugOn()) log.debug("fetchNotifications", "pattern=<" + li.getObjectName() + ">; filter=" + filter); if (li.getObjectName().apply(candidate.getObjectName())) { log.debug("fetchNotifications", "pattern matches"); if (filter == null || filter.isNotificationEnabled(notif)) { log.debug("fetchNotifications", "filter matches"); matchedNotifs.add(new TargetedNotification(notif, li.getListenerID())); } } } } return matchedNotifs; }
synchronized (tuples) tuple = (NotificationTuple)tuples.get(notification.getListenerID()); Notification notif = notification.getNotification();