Module
JMX- Notification Emitter Action - Generated Code
Authors: Alexandre Neubert, Thomas Leveque, Jean-Francois Denise
Notification
Emitter Action
The code is generated at the end of the target MBean class except the
added implemented NotificationEmitter interface declaration.
The following code is an example for one Notification (
javax.management.Notification
class, com.toto.newjmxclass8.type as type
and NewNotification Description as description)
:
/**
* MBean Notification support
* You shouldn't update these methods
*/
// <editor-fold defaultstate="collapsed" desc="
Generated Code ">
public void
addNotificationListener(NotificationListener listener,
NotificationFilter filter, Object
handback)
throws IllegalArgumentException {
broadcaster.addNotificationListener(listener, filter, handback);
}
public MBeanNotificationInfo[] getNotificationInfo()
{
return new
MBeanNotificationInfo[] {
new MBeanNotificationInfo(new String[] {
NOTIF_TYPE_0},
javax.management.Notification.class.getName(),
"NewNotification Description"),
new MBeanNotificationInfo(new String[] {
AttributeChangeNotification.ATTRIBUTE_CHANGE},
javax.management.AttributeChangeNotification.class.getName(),
"NewNotification Description")
};
}
public void
removeNotificationListener(NotificationListener listener)
throws ListenerNotFoundException {
broadcaster.removeNotificationListener(listener);
}
public void
removeNotificationListener(NotificationListener listener,
NotificationFilter filter, Object
handback)
throws ListenerNotFoundException {
broadcaster.removeNotificationListener(listener, filter, handback);
}
// </editor-fold>
private synchronized long getNextSeqNumber() {
return seqNumber++;
}
private long seqNumber;
private final NotificationBroadcasterSupport
broadcaster =
new NotificationBroadcasterSupport();
/**
* Notification types definitions. To use when
creating JMX Notifications.
*/
private static final String NOTIF_TYPE_0 =
"com.toto.newjmxclass8.type";