try {
if (mBeanServer.isRegistered(objectName)) {
mBeanServer.unregisterMBean(objectName);
}
BaseEmitterBean mbean = mbeans.get(objectName);
mbean.dispose();
} catch (Exception e) {
LOG.warn("Error unregistering object instance " + objectName + " . Error was " + e.getMessage(), e);
}
}
mbeans.clear();