public void unregister(ObjectName name) throws JMException { if (!isEnabled() || connectFailed) { return; } if (LOG.isLoggable(Level.INFO)) { LOG.info("unregistering MBean " + name); } busMBeans.remove(name); mbs.unregisterMBean(name); }
public void shutdown() { if (!isEnabled()) { return; } if (mcf != null) { try { mcf.destroy(); } catch (IOException ex) { LOG.log(Level.SEVERE, "STOP_CONNECTOR_FAILURE_MSG", new Object[] {ex}); } } //Using the array to hold the busMBeans to avoid the CurrentModificationException Object[] mBeans = busMBeans.toArray(); for (Object name : mBeans) { busMBeans.remove(name); try { unregister((ObjectName)name); } catch (JMException jmex) { LOG.log(Level.SEVERE, "UNREGISTER_FAILURE_MSG", new Object[]{name, jmex}); } } }
public void register(Object obj, ObjectName name, boolean forceRegistration) throws JMException { if (!isEnabled() || connectFailed) { return; } //Try to register as a Standard MBean try { registerMBeanWithServer(obj, persist(name), forceRegistration); } catch (NotCompliantMBeanException e) { //If this is not a "normal" MBean, then try to deploy it using JMX annotations ModelMBeanAssembler assembler = new ModelMBeanAssembler(); ModelMBeanInfo mbi = assembler.getModelMbeanInfo(obj.getClass()); register(obj, name, mbi, forceRegistration); } }
mbs = bus.getExtension(MBeanServer.class); if (isEnabled()) { if (mbs == null) {
assertEquals("service:jmx:rmi:///jndi/rmi://localhost:" + port + "/jmxrmi", imi.getJMXServiceURL()); assertTrue(imi.isEnabled()); assertNotNull(imi.getMBeanServer());
assertNotNull(im); InstrumentationManagerImpl impl = (InstrumentationManagerImpl)im; assertTrue(impl.isEnabled()); assertNotNull(impl.getMBeanServer());
assertNotNull(im); InstrumentationManagerImpl impl = (InstrumentationManagerImpl)im; assertTrue(impl.isEnabled()); assertNotNull(impl.getMBeanServer());
@Test public void testManagedSpringBus() throws Exception { SpringBusFactory factory = new SpringBusFactory(); Bus bus = factory.createBus(); InstrumentationManager im = bus.getExtension(InstrumentationManager.class); assertNotNull(im); InstrumentationManagerImpl imi = (InstrumentationManagerImpl)im; assertEquals("service:jmx:rmi:///jndi/rmi://localhost:9913/jmxrmi", imi.getJMXServiceURL()); assertTrue(!imi.isEnabled()); assertNull(imi.getMBeanServer()); //Test that registering without an MBeanServer is a no-op im.register(imi, new ObjectName("org.apache.cxf:foo=bar")); bus.shutdown(true); }