Search in sources :

Example 1 with ManagedBus

use of org.apache.cxf.bus.ManagedBus in project cxf by apache.

the class InstrumentationManagerImpl method init.

@PostConstruct
public void init() {
    if (bus != null && bus.getExtension(MBeanServer.class) != null) {
        enabled = true;
        createMBServerConnectorFactory = false;
        mbs = bus.getExtension(MBeanServer.class);
    }
    if (isEnabled()) {
        if (mbs == null) {
            // return platform mbean server if the option is specified.
            if (usePlatformMBeanServer) {
                mbs = ManagementFactory.getPlatformMBeanServer();
            } else {
                String mbeanServerID = mbeanServerIDMap.get(mbeanServerName);
                List<MBeanServer> servers = null;
                if (mbeanServerID != null) {
                    servers = CastUtils.cast(MBeanServerFactory.findMBeanServer(mbeanServerID));
                }
                if (servers == null || servers.isEmpty()) {
                    mbs = MBeanServerFactory.createMBeanServer(mbeanServerName);
                    try {
                        mbeanServerID = (String) mbs.getAttribute(getDelegateName(), "MBeanServerId");
                        mbeanServerIDMap.put(mbeanServerName, mbeanServerID);
                    } catch (JMException e) {
                    // ignore
                    }
                } else {
                    mbs = servers.get(0);
                }
            }
        }
        if (createMBServerConnectorFactory) {
            mcf = MBServerConnectorFactory.getInstance();
            mcf.setMBeanServer(mbs);
            mcf.setThreaded(isThreaded());
            mcf.setDaemon(isDaemon());
            mcf.setServiceUrl(getJMXServiceURL());
            try {
                mcf.createConnector();
            } catch (IOException ex) {
                connectFailed = true;
                LOG.log(Level.SEVERE, "START_CONNECTOR_FAILURE_MSG", new Object[] { ex });
            }
        }
        if (!connectFailed && null != bus) {
            try {
                // Register Bus here since we can guarantee that Instrumentation
                // infrastructure has been initialized.
                ManagedBus mbus = new ManagedBus(bus);
                register(mbus);
                if (LOG.isLoggable(Level.INFO)) {
                    LOG.info("registered " + mbus.getObjectName());
                }
            } catch (JMException jmex) {
                LOG.log(Level.SEVERE, "REGISTER_FAILURE_MSG", new Object[] { bus, jmex });
            }
        }
    }
    if (null != bus) {
        bus.setExtension(this, InstrumentationManager.class);
        BusLifeCycleManager blcm = bus.getExtension(BusLifeCycleManager.class);
        if (null != blcm) {
            blcm.registerLifeCycleListener(this);
        }
    }
}
Also used : ManagedBus(org.apache.cxf.bus.ManagedBus) JMException(javax.management.JMException) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) IOException(java.io.IOException) MBeanServer(javax.management.MBeanServer) PostConstruct(javax.annotation.PostConstruct)

Example 2 with ManagedBus

use of org.apache.cxf.bus.ManagedBus in project cxf by apache.

the class InstrumentationManagerImpl method setBus.

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;
}
Also used : ManagedBus(org.apache.cxf.bus.ManagedBus) JMException(javax.management.JMException) InstrumentationManager(org.apache.cxf.management.InstrumentationManager)

Example 3 with ManagedBus

use of org.apache.cxf.bus.ManagedBus in project jbossws-cxf by jbossws.

the class InstrumentationManagerExtImpl method initMBeanServer.

public void initMBeanServer() {
    this.setServer(this.getJBossMbeanServer());
    ManagedBus mbus = new ManagedBus(this.getBus());
    try {
        register(mbus);
    } catch (JMException e) {
        Loggers.ROOT_LOGGER.errorRegisteringBus(this.getBus(), e);
    }
}
Also used : ManagedBus(org.apache.cxf.bus.ManagedBus) JMException(javax.management.JMException)

Aggregations

JMException (javax.management.JMException)3 ManagedBus (org.apache.cxf.bus.ManagedBus)3 IOException (java.io.IOException)1 PostConstruct (javax.annotation.PostConstruct)1 MBeanServer (javax.management.MBeanServer)1 BusLifeCycleManager (org.apache.cxf.buslifecycle.BusLifeCycleManager)1 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)1