protected ObjectName getObjectName(P6LoadableOptions mBean, String jmxPrefix) throws MalformedObjectNameException { return new ObjectName(getPackageName(jmxPrefix) + ":name=" + mBean.getClass().getName()); }
public void unregisterAllMBeans(String jmxPrefix) throws MBeanRegistrationException, MalformedObjectNameException { // those we have reference to final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); for (ObjectName mBeanObjectName : mBeans) { try { mbs.unregisterMBean(mBeanObjectName); } catch (InstanceNotFoundException e) { // this just means someone unregistered our beans already // but we're OK with that and it can't cause failure } } mBeans.clear(); // to prevent naming conflicts: let's unreg also possible leftovers (with the same prefix) for (ObjectName objectName : mbs.queryNames(new ObjectName(getPackageName(jmxPrefix) + ":name=com.p6spy.*"), null)) { try { mbs.unregisterMBean(objectName); } catch (InstanceNotFoundException e) { // this just means someone unregistered the bean earlier than us // (quite unprobable, but parallel unreg could happen) // but we're OK with that and it can't cause failure } } }
private void checkMBeanAppendProperty(final String jmxPrefix, final boolean appendProperty) throws Exception { final Boolean append = (Boolean) jmxClient.getAttribute( P6MBeansRegistry.getPackageName(jmxPrefix), P6SpyOptions.class.getName(), JMX_PROPERTY_APPEND); Assert.assertEquals(append, appendProperty); }
private void checkMBeanNotExposed(final String jmxPrefix) throws Exception { // jmx is not exposed after unreg any more try { jmxClient.getAttribute(P6MBeansRegistry.getPackageName(null), P6SpyOptions.class.getName(), JMX_PROPERTY_APPEND); } catch (InstanceNotFoundException e) { // we should end up here return; } Assert.fail(); } }
protected ObjectName getObjectName(P6LoadableOptions mBean, String jmxPrefix) throws MalformedObjectNameException { return new ObjectName(getPackageName(jmxPrefix) + ":name=" + mBean.getClass().getName()); }
public void unregisterAllMBeans(String jmxPrefix) throws MBeanRegistrationException, MalformedObjectNameException { // those we have reference to final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); for (ObjectName mBeanObjectName : mBeans) { try { mbs.unregisterMBean(mBeanObjectName); } catch (InstanceNotFoundException e) { // this just means someone unregistered our beans already // but we're OK with that and it can't cause failure } } mBeans.clear(); // to prevent naming conflicts: let's unreg also possible leftovers (with the same prefix) for (ObjectName objectName : mbs.queryNames(new ObjectName(getPackageName(jmxPrefix) + ":name=com.p6spy.*"), null)) { try { mbs.unregisterMBean(objectName); } catch (InstanceNotFoundException e) { // this just means someone unregistered the bean earlier than us // (quite unprobable, but parallel unreg could happen) // but we're OK with that and it can't cause failure } } }