/**
  * {@inheritDoc}
  *
  * @see org.helios.apmrouter.jmx.mbeanserver.MBeanServerConnectionAdmin#onNotification(int,
  *     javax.management.Notification, java.lang.Object)
  */
 @Override
 public void onNotification(int requestId, Notification notification, Object handback) {
   NotificationListener listener = registeredListeners.get(requestId);
   if (listener != null) {
     listener.handleNotification(notification, handback);
   }
 }
Esempio n. 2
0
 /**
  * Return true if the notification was sent successfully, false otherwise.
  *
  * @param type
  * @param message
  * @return true if the notification succeeded
  */
 public boolean notify(final String type, String message) {
   try {
     Notification n =
         new Notification(
             type,
             this,
             sequence.incrementAndGet(),
             System.currentTimeMillis(),
             "[" + type + "] " + message);
     sendNotification(n);
     for (NotificationListener listener : listeners) {
       listener.handleNotification(n, this);
     }
     return true;
   } catch (Exception x) {
     if (log.isDebugEnabled()) {
       log.debug("Notify failed. Type=" + type + "; Message=" + message, x);
     }
     return false;
   }
 }
    void dispatchNotification(
        TargetedNotification tn, Integer myListenerID, Map<Integer, ClientListenerInfo> listeners) {
      final Notification notif = tn.getNotification();
      final Integer listenerID = tn.getListenerID();

      if (listenerID.equals(myListenerID)) return;
      final ClientListenerInfo li = listeners.get(listenerID);

      if (li == null) {
        logger.trace("NotifFetcher.dispatch", "Listener ID not in map");
        return;
      }

      NotificationListener l = li.getListener();
      Object h = li.getHandback();
      try {
        l.handleNotification(notif, h);
      } catch (RuntimeException e) {
        final String msg = "Failed to forward a notification " + "to a listener";
        logger.trace("NotifFetcher-run", msg, e);
      }
    }