public void registerMBeans(Collection<P6LoadableOptions> allOptions) throws MBeanRegistrationException, InstanceNotFoundException, MalformedObjectNameException, NotCompliantMBeanException { boolean jmx = true; String jmxPrefix = ""; for (P6LoadableOptions options : allOptions) { if (options instanceof P6SpyOptions) { jmx = ((P6SpyOptions) options).getJmx(); jmxPrefix = ((P6SpyOptions) options).getJmxPrefix(); break; } } if (!jmx) { return; } // unreg possible conflicting ones first unregisterAllMBeans(jmxPrefix); // reg all for (P6LoadableOptions options : allOptions) { try { registerMBean(options, jmxPrefix); } catch (InstanceAlreadyExistsException e) { // sounds like someone registered beans already (before we had a chance to do so) // so let's just make things consistent and re-register again registerMBeans(allOptions); } } }
public void registerMBeans(Collection<P6LoadableOptions> allOptions) throws MBeanRegistrationException, InstanceNotFoundException, MalformedObjectNameException, NotCompliantMBeanException { boolean jmx = true; String jmxPrefix = ""; for (P6LoadableOptions options : allOptions) { if (options instanceof P6SpyOptions) { jmx = ((P6SpyOptions) options).getJmx(); jmxPrefix = ((P6SpyOptions) options).getJmxPrefix(); break; } } if (!jmx) { return; } // unreg possible conflicting ones first unregisterAllMBeans(jmxPrefix); // reg all for (P6LoadableOptions options : allOptions) { try { registerMBean(options, jmxPrefix); } catch (InstanceAlreadyExistsException e) { // sounds like someone registered beans already (before we had a chance to do so) // so let's just make things consistent and re-register again registerMBeans(allOptions); } } }