/** * 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); } }
/** * 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); } }
/** * 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); } } }
/** * 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); } }
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); }
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); }
/** * 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); }
/** * 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); } }
public void handleNotification(Notification notification, Object handback) { notification.setSource(mirror.getLocalObjectName()); listener.handleNotification(notification, handback); } }
public void handleNotification(Notification notification, Object handback) { notification.setSource(mirror.getLocalObjectName()); listener.handleNotification(notification, handback); } }
/** * * 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); }
public void handleNotification(Notification notification, Object handback) { notification.setSource(mirror.getLocalObjectName()); listener.handleNotification(notification, handback); } }
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); }
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); }
((Notification)args[x]).setSource(name);
((Notification)args[x]).setSource(name);
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); }