javax.management.Notification.setSource()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(74)

本文整理了Java中javax.management.Notification.setSource()方法的一些代码示例,展示了Notification.setSource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Notification.setSource()方法的具体详情如下:
包路径:javax.management.Notification
类名称:Notification
方法名:setSource

Notification.setSource介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Replaces the notification source if necessary to do so.
 * From the {@link Notification javadoc}:
 * <i>"It is strongly recommended that notification senders use the object name
 * rather than a reference to the MBean object as the source."</i>
 * @param notification the {@link Notification} whose
 * {@link javax.management.Notification#getSource()} might need massaging
 */
private void replaceNotificationSourceIfNecessary(Notification notification) {
  if (notification.getSource() == null || notification.getSource().equals(this.managedResource)) {
    notification.setSource(this.objectName);
  }
}

代码示例来源:origin: org.springframework/spring-context

/**
 * Replaces the notification source if necessary to do so.
 * From the {@link Notification javadoc}:
 * <i>"It is strongly recommended that notification senders use the object name
 * rather than a reference to the MBean object as the source."</i>
 * @param notification the {@link Notification} whose
 * {@link javax.management.Notification#getSource()} might need massaging
 */
private void replaceNotificationSourceIfNecessary(Notification notification) {
  if (notification.getSource() == null || notification.getSource().equals(this.managedResource)) {
    notification.setSource(this.objectName);
  }
}

代码示例来源:origin: spring-projects/spring-batch

/**
   * Publish the provided message to an external listener if there is one.
   * 
   * @param message the message to publish
   */
  private void publish(String message) {
    if (notificationPublisher != null) {
      Notification notification = new Notification("JobExecutionApplicationEvent", this, notificationCount++,
          message);
      /*
       * We can't create a notification with a null source, but we can set
       * it to null after creation(!). We want it to be null so that
       * Spring will replace it automatically with the ObjectName (in
       * ModelMBeanNotificationPublisher).
       */
      notification.setSource(null);
      notificationPublisher.sendNotification(notification);
    }
  }
}

代码示例来源:origin: spring-projects/spring-batch

/**
 * Publish the provided message to an external listener if there is one.
 * 
 * @param message the message to publish
 */
private void publish(String message) {
  if (notificationPublisher != null) {
    Notification notification = new Notification("JobExecutionApplicationEvent", this, notificationCount++,
        message);
    /*
     * We can't create a notification with a null source, but we can set
     * it to null after creation(!). We want it to be null so that
     * Spring will replace it automatically with the ObjectName (in
     * ModelMBeanNotificationPublisher).
     */
    notification.setSource(null);
    notificationPublisher.sendNotification(notification);
  }
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-jmx

public void handleNotification(Notification notification, Object handback)
{
 if (notification == null)
   return;
 // Forward the notification with the object name as source
 // FIXME: This overwrites the original source, there is no way
 //        to put it back with the current spec
 notification.setSource(name);
 listener.handleNotification(notification, handback);
}

代码示例来源:origin: org.jboss.mx/jboss-jmx

public void handleNotification(Notification notification, Object handback)
{
 if (notification == null)
   return;
 // Forward the notification with the object name as source
 // FIXME: This overwrites the original source, there is no way
 //        to put it back with the current spec
 notification.setSource(name);
 listener.handleNotification(notification, handback);
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-j2se

/**
 * This method is called before a notification is sent to see whether
 * the listener wants the notification.
 *
 * @param notification the notification to be sent.
 * @return true if the listener wants the notification, false otherwise
 */
public boolean isNotificationEnabled(Notification notification)
{
  // replace with the real source of the event
  notification.setSource(source);
  return this.delegate.isNotificationEnabled(notification);
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Replaces the notification source if necessary to do so.
 * From the {@link Notification javadoc}:
 * <i>"It is strongly recommended that notification senders use the object name
 * rather than a reference to the MBean object as the source."</i>
 * @param notification the {@link Notification} whose
 * {@link javax.management.Notification#getSource()} might need massaging
 */
private void replaceNotificationSourceIfNecessary(Notification notification) {
  if (notification.getSource() == null || notification.getSource().equals(this.managedResource)) {
    notification.setSource(this.objectName);
  }
}

代码示例来源:origin: org.terracotta/terracotta-ee

public void handleNotification(Notification notification, Object handback) {
  notification.setSource(mirror.getLocalObjectName());
  listener.handleNotification(notification, handback);
 }
}

代码示例来源:origin: org.terracotta/terracotta-l1-ee

public void handleNotification(Notification notification, Object handback) {
  notification.setSource(mirror.getLocalObjectName());
  listener.handleNotification(notification, handback);
 }
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-cluster

/**
* 
* Broadcast a notifcation remotely to the partition participants
* 
* @param notification
*/
protected void sendNotificationRemote(Notification notification) throws Exception
{
 // Overriding the source MBean with its ObjectName
 // to ensure that it can be safely transferred over the wire
 notification.setSource(this.getServiceName());
 
 this.service.handleEvent(notification);
}

代码示例来源:origin: org.terracotta/terracotta-l1

public void handleNotification(Notification notification, Object handback) {
  notification.setSource(mirror.getLocalObjectName());
  listener.handleNotification(notification, handback);
 }
}

代码示例来源:origin: io.snappydata/gemfire-hydra-tests

public void sendNotificationToMe(String name) {
 long sequence = sequenceNumber++;
 Notification n = new AttributeChangeNotification(this, sequenceNumber, System.currentTimeMillis(),
   name, "A", "long", sequence, sequenceNumber);
 n.setSource(RemoteTestModule.getMyVmid());
 sendNotification(n);
}

代码示例来源:origin: io.snappydata/gemfire-hydra-tests

public void sendNotificationToMe(String name) {
 long sequence = sequenceNumber++;
 Notification n = new AttributeChangeNotification(this, sequenceNumber, System.currentTimeMillis(),
   name, "A", "long", sequence, sequenceNumber);
 n.setSource(RemoteTestModule.getMyVmid());
 sendNotification(n);
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-jmx

((Notification)args[x]).setSource(name);

代码示例来源:origin: org.jboss.mx/jboss-jmx

((Notification)args[x]).setSource(name);

代码示例来源:origin: apache/felix

public void handleNotification(Notification notification, Object handback)
{
  // The JMX spec does not specify how to change the source to be the ObjectName
  // of the broadcaster. If we serialize the calls to the listeners, then it's
  // possible to change the source and restore it back to the old value before
  // calling the next listener; but if we want to support concurrent calls
  // to the listeners, this is not possible. Here I chose to support concurrent
  // calls so I change the value once and I never restore it.
  Object src = notification.getSource();
  if (!(src instanceof ObjectName))
  {
   // Change the source to be the ObjectName of the notification broadcaster
   // if we are not already an ObjectName (compliant with RI behaviour)
   notification.setSource(objectName);
  }
  // Notify the real listener
  NotificationListener listener = getTargetListener();
  listener.handleNotification(notification, handback);
}

相关文章