public static void addMBeanRegistrationListener ( MBeanServerConnection pServer , NotificationListener pListener , ObjectName pObjectNameToFilter ) { MBeanServerNotificationFilter filter = new MBeanServerNotificationFilter ( ) ; if ( pObjectNameToFilter == null ) { filter . enableAllObjectNames ( ) ; } else { filter . enableObjectName ( pObjectNameToFilter ) ; } try { pServer . addNotificationListener ( getMBeanServerDelegateName ( ) , pListener , filter , null ) ; } catch ( InstanceNotFoundException e ) { throw new IllegalStateException ( "Cannot find " + getMBeanServerDelegateName ( ) + " in server " + pServer , e ) ; } catch ( IOException e ) { throw new IllegalStateException ( "IOException while registering notification listener for " + getMBeanServerDelegateName ( ) , e ) ; } }
Register a notification listener which listens for registration and deregistration of MBeans at a certain server