code: 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);
          }
      }
docs: Register a notification listener which listens for registration and deregistration of MBeans at a certain server
  
  @param pServer server to register to
  @param pListener listener to register
  @param pObjectNameToFilter object name which should be listen for. If null, listens for any MBean registration