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); } } }
mBeansRegistry.registerMBeans(allOptions.values());
private P6MBeansRegistry constructMBean(P6MBeansRegistry mBeansRegistry, final String jmxPrefix, final boolean appendProperty) throws Exception { // none to be reused registry if (null == mBeansRegistry) { mBeansRegistry = new P6MBeansRegistry(); } final P6OptionsRepository repo = new P6OptionsRepository(); final P6SpyOptions opts = new P6SpyOptions(repo); opts.load(opts.getDefaults()); opts.setAppend(appendProperty); opts.setJmxPrefix(jmxPrefix); repo.initCompleted(); mBeansRegistry.registerMBeans(new ArrayList<P6LoadableOptions>(Arrays.asList(opts))); checkMBeanAppendProperty(jmxPrefix, appendProperty); return mBeansRegistry; }
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); } } }
mBeansRegistry.registerMBeans(allOptions.values());
mBeansRegistry.registerMBeans(allOptions.values());