If the event type is REGISTRATION_NOTIFICATION and if the 'name' element
in registered MBean's ObjectName matches one of names in the alert
subscriptions then we will add the Notification Listener and the Filter
to the MBean.
if( !notification.getType().equals(
MBeanServerNotification.REGISTRATION_NOTIFICATION ) )
{
// We are only interested in Registration event
return;
}
try {
MBeanServerNotification mbeanServerNotification =
(MBeanServerNotification) notification;
String registeredMbeanName =
mbeanServerNotification.getMBeanName().getKeyProperty(
NAME_PROPERTY_KEY );
// Registered ObjectName doesn't have the 'name' key value. So,
// no action needs to be taken.
if( registeredMbeanName == null ) return;
Iterator iterator = alertSubscriptions.iterator( );
while ( iterator.hasNext( ) ) {
AlertSubscriptionInfo subscription =
(AlertSubscriptionInfo)iterator.next();
if( matches( subscription.getMonitorNames(),
registeredMbeanName ))
{
mbeanServer.addNotificationListener(
mbeanServerNotification.getMBeanName(),
subscription.getNotificationListener(),
subscription.getNotificationFilter(), null );
}
}
} catch( Exception e ) {
new ErrorManager().error( "Error In " +
" MBeanServerRegistrationEventListener ", e,
ErrorManager.GENERIC_FAILURE );
}