org.springframework.jmx.export.notification
Class ModelMBeanNotificationPublisher

java.lang.Object
  extended by org.springframework.jmx.export.notification.ModelMBeanNotificationPublisher
All Implemented Interfaces:
NotificationPublisher

public class ModelMBeanNotificationPublisher
extends java.lang.Object
implements NotificationPublisher

NotificationPublisher implementation that uses the infrastructure provided by the ModelMBean interface to track javax.management.NotificationListeners and send Notifications to those listeners.

Since:
2.0
Author:
Rob Harrop, Juergen Hoeller, Rick Evans
See Also:
ModelMBeanNotificationBroadcaster, NotificationPublisherAware

Field Summary
private  java.lang.Object managedResource
          The managed resource associated with the modelMBean.
private  javax.management.modelmbean.ModelMBeanNotificationBroadcaster modelMBean
          The ModelMBean instance wrapping the managed resource into which this NotificationPublisher will be injected.
private  javax.management.ObjectName objectName
          The ObjectName associated with the modelMBean.
 
Constructor Summary
ModelMBeanNotificationPublisher(javax.management.modelmbean.ModelMBeanNotificationBroadcaster modelMBean, javax.management.ObjectName objectName, java.lang.Object managedResource)
          Create a new instance of the ModelMBeanNotificationPublisher class that will publish all Notifications to the supplied ModelMBean.
 
Method Summary
private  void replaceNotificationSourceIfNecessary(javax.management.Notification notification)
          From the javadoc:
 void sendNotification(javax.management.Notification notification)
          Send the supplied Notification using the wrapped ModelMBean instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modelMBean

private final javax.management.modelmbean.ModelMBeanNotificationBroadcaster modelMBean
The ModelMBean instance wrapping the managed resource into which this NotificationPublisher will be injected.


objectName

private final javax.management.ObjectName objectName
The ObjectName associated with the modelMBean.


managedResource

private final java.lang.Object managedResource
The managed resource associated with the modelMBean.

Constructor Detail

ModelMBeanNotificationPublisher

public ModelMBeanNotificationPublisher(javax.management.modelmbean.ModelMBeanNotificationBroadcaster modelMBean,
                                       javax.management.ObjectName objectName,
                                       java.lang.Object managedResource)
Create a new instance of the ModelMBeanNotificationPublisher class that will publish all Notifications to the supplied ModelMBean.

Parameters:
modelMBean - the target ModelMBean; must not be null
objectName - the ObjectName of the source ModelMBean
managedResource - the managed resource exposed by the supplied ModelMBean
Throws:
java.lang.IllegalArgumentException - if any of the parameters is null
Method Detail

sendNotification

public void sendNotification(javax.management.Notification notification)
Send the supplied Notification using the wrapped ModelMBean instance.

Specified by:
sendNotification in interface NotificationPublisher
Parameters:
notification - the Notification to be sent
Throws:
java.lang.IllegalArgumentException - if the supplied notification is null
UnableToSendNotificationException - if the supplied notification could not be sent

replaceNotificationSourceIfNecessary

private void replaceNotificationSourceIfNecessary(javax.management.Notification notification)
From the javadoc:

"It is strongly recommended that notification senders use the object name rather than a reference to the MBean object as the source."

Parameters:
notification - the Notification whose EventObject.getSource() might need massaging