public void setPersistentBusId(String id) { persistentBusId = sanitize(id); }
public InstrumentationManagerImpl(Bus bus) { this(); readJMXProperties(bus); this.bus = bus; }
public void register(Object obj, ObjectName name) throws JMException { register(obj, name, false); }
@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); } } }
@Bean public InstrumentationManager instrumentationManager(Bus cxf) { InstrumentationManagerImpl impl = new InstrumentationManagerImpl(); impl.setEnabled(true); impl.setBus(cxf); impl.setUsePlatformMBeanServer(TRUE); return impl; }
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(); } catch (IOException ex) { connectFailed = true; register(mbus); if (LOG.isLoggable(Level.INFO)) { LOG.info("registered " + mbus.getObjectName());
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); } }
@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); }
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 unregister(ManagedComponent component) throws JMException { ObjectName name = component.getObjectName(); unregister(persist(name)); }
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); }
private void register(Object obj, ObjectName name, ModelMBeanInfo mbi, boolean forceRegistration) throws JMException { RequiredModelMBean rtMBean = (RequiredModelMBean)mbs.instantiate("javax.management.modelmbean.RequiredModelMBean"); rtMBean.setModelMBeanInfo(mbi); try { rtMBean.setManagedResource(obj, "ObjectReference"); } catch (InvalidTargetObjectTypeException itotex) { throw new JMException(itotex.getMessage()); } registerMBeanWithServer(rtMBean, persist(name), forceRegistration); }
public void postShutdown() { this.shutdown(); }
private void readJMXProperties(Bus b) { if (b != null) { persistentBusId = getBusProperty(b, "bus.jmx.persistentBusId", persistentBusId); mbeanServerName = getBusProperty(b, "bus.jmx.serverName", mbeanServerName); usePlatformMBeanServer = getBusProperty(b, "bus.jmx.usePlatformMBeanServer", usePlatformMBeanServer); createMBServerConnectorFactory = getBusProperty(b, "bus.jmx.createMBServerConnectorFactory", createMBServerConnectorFactory); daemon = getBusProperty(b, "bus.jmx.daemon", daemon); threaded = getBusProperty(b, "bus.jmx.threaded", threaded); enabled = getBusProperty(b, "bus.jmx.enabled", enabled); jmxServiceURL = getBusProperty(b, "bus.jmx.JMXServiceURL", jmxServiceURL); } }
private int getURLLocalHostPort(String url) { int portStart = url.indexOf("localhost") + 10; int portEnd; int port = 0; if (portStart > 0) { portEnd = indexNotOfNumber(url, portStart); if (portEnd > portStart) { final String portString = url.substring(portStart, portEnd); port = Integer.parseInt(portString); } } return port; }
&& url.getProtocol().compareToIgnoreCase("rmi") == 0) { try { int port = getURLLocalHostPort(serviceUrl); try { LocateRegistry.createRegistry(port);
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 {
public ObjectName register(ManagedComponent i) throws JMException { return register(i, false); }
public void setBus(Bus bus) { if (this.bus == null) { readJMXProperties(bus); } else { // possibly this bus was reassigned from another im bean InstrumentationManager im = bus.getExtension(InstrumentationManager.class); if (this != im) { bus.setExtension(this, InstrumentationManager.class); try { ManagedBus mbus = new ManagedBus(bus); im.unregister(mbus); if (LOG.isLoggable(Level.INFO)) { LOG.info("unregistered " + mbus.getObjectName()); } } catch (JMException e) { // ignore } } } this.bus = bus; }
public ObjectName register(ManagedComponent i, boolean forceRegistration) throws JMException { ObjectName name = i.getObjectName(); register(i, name, forceRegistration); return name; }