MBeanRegistrationEventListener.javaAPI DocGlassfish v2 API5737Fri May 04 22:33:16 BST 2007com.sun.enterprise.admin.alert


public class MBeanRegistrationEventListener extends Object implements NotificationListener
Class MBeanRegistrationEventListener listens to MBeanRegistered event. The main purpose of this class is to introspect the 'name' element in objectName of the MBean (or Monitor) registered and check to see if it matches with any of the names listed for alert-subscription. If it matches then the listener will be subscribed with the MBean.
Hemanth Puttaswamy

Fields Summary
private List
private MBeanServer
private static final String
Constructors Summary
public MBeanRegistrationEventListener(List alertSubscriptions)
Constructor which accepts a list of AlertSubscriptions based on domain.xml entries.

        this.alertSubscriptions = alertSubscriptions;
        mbeanServer = 
Methods Summary
public voidhandleNotification( notification, java.lang.Object handBack)
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
        try {
            MBeanServerNotification mbeanServerNotification =
                (MBeanServerNotification) notification;
            String registeredMbeanName =
                    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 = 
                if( matches( subscription.getMonitorNames(), 
                    registeredMbeanName ))
                            subscription.getNotificationFilter(), null );
        } catch( Exception e ) {
             new ErrorManager().error( "Error In " +
                  " MBeanServerRegistrationEventListener  ", e,
                  ErrorManager.GENERIC_FAILURE );
private booleanmatches(java.util.List monitorNames, java.lang.String registeredMBeanName)
A simple utility method to check to see if the registeredMBeanName matches with one of the monitorNames for alert subscription.

        Iterator iterator = monitorNames.iterator( );
        while( iterator.hasNext( ) ) {
            if( registeredMBeanName.equals( (String) ) ) {
                return true;
        return false;