@Override public void initialize(Bus bus) { List<Server> servers = new ArrayList<Server>(); ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class); servers.addAll(serverRegistry.getServers()); for (Iterator<Server> iter = servers.iterator(); iter.hasNext();) { Server server = (Server) iter.next(); ManagedApi mApi = new ManagedApi(bus, server.getEndpoint(), server); InstrumentationManager iMgr = bus.getExtension(InstrumentationManager.class); if (iMgr == null) { iMgr = new InstrumentationManagerImpl(bus); } ((InstrumentationManagerImpl)iMgr).setUsePlatformMBeanServer(true); ((InstrumentationManagerImpl)iMgr).setCreateMBServerConnectorFactory(false); ((InstrumentationManagerImpl)iMgr).setEnabled(true); ((InstrumentationManagerImpl)iMgr).init(); if (iMgr != null) { try { iMgr.register(mApi); } catch (JMException jmex) { jmex.printStackTrace(); LOG.log(Level.WARNING, "Registering ManagedApi failed.", 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); } }
@Bean public InstrumentationManager instrumentationManager(Bus cxf) { InstrumentationManagerImpl impl = new InstrumentationManagerImpl(); impl.setEnabled(true); impl.setBus(cxf); impl.setUsePlatformMBeanServer(TRUE); return impl; }
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}); } } }
manager.setEnabled(true); manager.setServer(LocalMBeanServer.get()); manager.setDaemon(true); manager.init();
assertNotNull(im); InstrumentationManagerImpl imi = (InstrumentationManagerImpl)im; imi.setServer(ManagementFactory.getPlatformMBeanServer()); imi.setEnabled(true); imi.init();
mbs = bus.getExtension(MBeanServer.class); if (isEnabled()) { if (mbs == null) { mbs = MBeanServerFactory.createMBeanServer(mbeanServerName); try { mbeanServerID = (String) mbs.getAttribute(getDelegateName(), "MBeanServerId"); mbeanServerIDMap.put(mbeanServerName, mbeanServerID); mcf = MBServerConnectorFactory.getInstance(); mcf.setMBeanServer(mbs); mcf.setThreaded(isThreaded()); mcf.setDaemon(isDaemon()); mcf.setServiceUrl(getJMXServiceURL()); try { mcf.createConnector(); register(mbus); if (LOG.isLoggable(Level.INFO)) { LOG.info("registered " + mbus.getObjectName());
@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); }
assertNotNull(im); InstrumentationManagerImpl impl = (InstrumentationManagerImpl)im; assertTrue(impl.isEnabled()); assertNotNull(impl.getMBeanServer());
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); }
InstrumentationManagerImpl imi = (InstrumentationManagerImpl)im; 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());
@Override public void initialize(Server server, Bus bus) { ManagedApi mApi = new ManagedApi(bus, server.getEndpoint(), server); InstrumentationManager iMgr = bus.getExtension(InstrumentationManager.class); if (iMgr == null) { iMgr = new InstrumentationManagerImpl(bus); } ((InstrumentationManagerImpl)iMgr).setUsePlatformMBeanServer(true); ((InstrumentationManagerImpl)iMgr).setCreateMBServerConnectorFactory(false); ((InstrumentationManagerImpl)iMgr).setEnabled(true); ((InstrumentationManagerImpl)iMgr).init(); if (iMgr != null) { try { iMgr.register(mApi); ServerLifeCycleManager slcMgr = bus.getExtension(ServerLifeCycleManager.class); if (slcMgr != null) { slcMgr.registerListener(mApi); slcMgr.startServer(server); } } catch (JMException jmex) { jmex.printStackTrace(); LOG.log(Level.WARNING, "Registering ManagedApi failed.", jmex); } } }
InstrumentationManager iMgr = bus.getExtension(InstrumentationManager.class); if (iMgr == null) { iMgr = new InstrumentationManagerImpl(bus); ((InstrumentationManagerImpl)iMgr).setUsePlatformMBeanServer(true); ((InstrumentationManagerImpl)iMgr).setCreateMBServerConnectorFactory(false); ((InstrumentationManagerImpl)iMgr).setEnabled(true); ((InstrumentationManagerImpl)iMgr).init(); if (iMgr != null) { try {
InstrumentationManager iMgr = bus.getExtension(InstrumentationManager.class); if (iMgr == null) { iMgr = new InstrumentationManagerImpl(bus); ((InstrumentationManagerImpl)iMgr).setUsePlatformMBeanServer(true); ((InstrumentationManagerImpl)iMgr).setCreateMBServerConnectorFactory(false); ((InstrumentationManagerImpl)iMgr).setEnabled(true); ((InstrumentationManagerImpl)iMgr).init(); if (iMgr != null) { try {