I have written a series of MBeans (and associated JUnit tests) that perform the following code within its start() method:
MBeanServerNotificationFilter filter = new MBeanServerNotificationFilter();
filter.enableAllObjectNames();
filter.enableType(MBeanServerNotification.REGISTRATION_NOTIFICATION);
filter.enableType(MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
getMBeanServer().addNotificationListener(new ObjectName("JMImplementation:type=MBeanServerDelegate"), regListener, filter, null);
I am also performing a JNDI lookup of the MBean server (using the RMIAdaptor method). When the stop() method of the MBean is called the notification listener is unregistered:
getMBeanServer().removeNotificationListener(new ObjectName("JMImplementation:type=MBeanServerDelegate"), regListener);
The first time I exercise the tests everything runs fine and all test complete. Every subsequent run the tests run much, much, MUCH slower. Any ideas on why the performance degrades?
BTW: Running the tests within their own JVM/MBeanServer they do not exhibit this problem.