use of org.apache.cxf.buslifecycle.BusLifeCycleManager 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);
}
}
}
use of org.apache.cxf.buslifecycle.BusLifeCycleManager in project cxf by apache.
the class ExtensionManagerBus method initialize.
public void initialize() {
setState(BusState.INITIALIZING);
Collection<? extends BusCreationListener> ls = getExtension(ConfiguredBeanLocator.class).getBeansOfType(BusCreationListener.class);
for (BusCreationListener l : ls) {
l.busCreated(this);
}
doInitializeInternal();
BusLifeCycleManager lifeCycleManager = this.getExtension(BusLifeCycleManager.class);
if (null != lifeCycleManager) {
lifeCycleManager.initComplete();
}
setState(BusState.RUNNING);
}
Aggregations