public class ModelMBeanNotificationPublisher extends java.lang.Object implements NotificationPublisher
NotificationPublisher
implementation that uses the infrastructure
provided by the <code>ModelMBean</code> interface to track
<code>javax.management.NotificationListeners</code>
and send <code>Notifications</code> to those listeners.NotificationPublisherAware
Modifier and Type | Field and Description |
---|---|
private java.lang.Object |
managedResource
The managed resource associated with the <code>modelMBean</code>.
|
private javax.management.modelmbean.ModelMBeanNotificationBroadcaster |
modelMBean
The <code>ModelMBean</code> instance wrapping the managed resource into which this
NotificationPublisher will be injected. |
private javax.management.ObjectName |
objectName
The <code>ObjectName</code> associated with the <code>modelMBean</code>.
|
Constructor and Description |
---|
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 <code>Notifications</code>
to the supplied <code>ModelMBean</code>. |
Modifier and Type | Method and Description |
---|---|
private void |
replaceNotificationSourceIfNecessary(javax.management.Notification notification)
From the <code>javadoc</code>:
|
void |
sendNotification(javax.management.Notification notification)
Send the supplied <code>Notification</code> using the wrapped
<code>ModelMBean</code> instance.
|
private final javax.management.modelmbean.ModelMBeanNotificationBroadcaster modelMBean
NotificationPublisher
will be injected.private final javax.management.ObjectName objectName
private final java.lang.Object managedResource
public ModelMBeanNotificationPublisher(javax.management.modelmbean.ModelMBeanNotificationBroadcaster modelMBean, javax.management.ObjectName objectName, java.lang.Object managedResource)
ModelMBeanNotificationPublisher
class
that will publish all <code>Notifications</code>
to the supplied <code>ModelMBean</code>.modelMBean
- the target <code>ModelMBean</code>; must not be null
objectName
- the <code>ObjectName</code> of the source <code>ModelMBean</code>managedResource
- the managed resource exposed by the supplied <code>ModelMBean</code>java.lang.IllegalArgumentException
- if any of the parameters is null
public void sendNotification(javax.management.Notification notification)
sendNotification
in interface NotificationPublisher
notification
- the <code>Notification</code> to be sentjava.lang.IllegalArgumentException
- if the supplied notification
is null
UnableToSendNotificationException
- if the supplied notification
could not be sentprivate void replaceNotificationSourceIfNecessary(javax.management.Notification notification)
"It is strongly recommended that notification senders use the object name rather than a reference to the MBean object as the source."
notification
- the <code>Notification</code> whose
EventObject.getSource()
might need massaging