private void sendNotification(String message, Map<String, Object> status) {

    Notification notification =
        new Notification(
            PlatformMonitor.RESOURCE_STATUS_TYPE, platformMonitor, this.sequenceNumber++, message);

    notification.setUserData(status);

    super.sendNotification(notification);
  }
Пример #2
0
 // Switch this object state to the desired value an send
 // a notification. Don't call this method from within a
 // synchronized block!
 //
 private final void setStateAndNotify(ScanState desired) {
   final ScanState old = state;
   if (old == desired) return;
   state = desired;
   final AttributeChangeNotification n =
       new AttributeChangeNotification(
           this,
           getNextSeqNumber(),
           System.currentTimeMillis(),
           "state change",
           "State",
           ScanState.class.getName(),
           String.valueOf(old),
           String.valueOf(desired));
   broadcaster.sendNotification(n);
 }
Пример #3
0
  // Notifies of a matching file.
  private boolean notifyMatch(File file) {
    try {
      final Notification n =
          new Notification(
              FILE_MATCHES_NOTIFICATION, this, getNextSeqNumber(), file.getAbsolutePath());

      // This method *is not* called from any synchronized block, so
      // we can happily call broadcaster.sendNotification() here.
      // Note that verifying whether a method is called from within
      // a synchronized block demends a thoroughful code reading,
      // examining each of the 'parent' methods in turn.
      //
      broadcaster.sendNotification(n);
      return true;
    } catch (Exception x) {
      LOG.fine("Failed to notify: " + file.getAbsolutePath());
    }
    return false;
  }
  @Override
  public void sendNotification(Notification aNotification) {
    PreparedStatement stmt = null;
    try {
      // prepare the insert statement
      stmt = connection.prepareStatement(NOTIF_INSERT_SQL);
      stmt.setString(1, aNotification.getMessage());
      stmt.setLong(2, aNotification.getSequenceNumber());
      if (aNotification.getSource() instanceof Serializable) {
        stmt.setObject(3, aNotification.getSource());
      } else {
        stmt.setObject(3, "No source");
      }
      stmt.setLong(4, aNotification.getTimeStamp());
      stmt.setString(5, aNotification.getType());
      if (aNotification.getUserData() instanceof Serializable) {
        stmt.setObject(6, aNotification.getUserData());
      } else {
        stmt.setObject(6, "No user data");
      }

      // execute amnd commit
      stmt.executeUpdate();

      // this should really be managed by the transaction
      // manager and connections
      connection.commit();
    } catch (Exception e) {
      LOG.error("Failed to persist notification", e);
    } finally {
      try {
        if (stmt != null) {
          stmt.close();
        }
      } catch (SQLException sqle) {
        LOG.error("failed to close statement", sqle);
      }
    }
    super.sendNotification(aNotification);
  }
Пример #5
0
 public void addConnectionNotificationListener(
     NotificationListener listener, NotificationFilter filter, Object handback) {
   connectionNotifier.addNotificationListener(listener, filter, handback);
 }
Пример #6
0
 /** MBeanNotification support - delegates to broadcaster. */
 public void removeNotificationListener(
     NotificationListener listener, NotificationFilter filter, Object handback)
     throws ListenerNotFoundException {
   broadcaster.removeNotificationListener(listener, filter, handback);
 }
Пример #7
0
 /** MBeanNotification support - delegates to broadcaster. */
 public void removeNotificationListener(NotificationListener listener)
     throws ListenerNotFoundException {
   broadcaster.removeNotificationListener(listener);
 }
Пример #8
0
 /** MBeanNotification support - delegates to broadcaster. */
 public void addNotificationListener(
     NotificationListener listener, NotificationFilter filter, Object handback)
     throws IllegalArgumentException {
   broadcaster.addNotificationListener(listener, filter, handback);
 }
Пример #9
0
 /*
  * @see javax.management.NotificationBroadcaster#getNotificationInfo()
  */
 public MBeanNotificationInfo[] getNotificationInfo() {
   return notifier.getNotificationInfo();
 }
Пример #10
0
 /*
  * @see org.tigris.gef.presentation.Fig#deleteFromModel()
  */
 @Override
 public void deleteFromModel() {
   super.deleteFromModel();
   firePropChange("remove", null, null);
   notifier.sendNotification(new Notification("remove", this, 0));
 }
Пример #11
0
 public void sendNotification(Notification notification)
     throws MBeanException, RuntimeOperationsException {
   if (m_generalBroadcaster != null) {
     m_generalBroadcaster.sendNotification(notification);
   }
 }
Пример #12
0
 public void removeNotificationListener(
     NotificationListener listener, NotificationFilter filter, Object handback)
     throws RuntimeOperationsException, ListenerNotFoundException {
   m_generalBroadcaster.removeNotificationListener(listener, filter, handback);
 }
Пример #13
0
 public void removeNotificationListener(NotificationListener listener)
     throws RuntimeOperationsException, ListenerNotFoundException {
   m_generalBroadcaster.removeNotificationListener(listener);
 }