private static final Logger LOG = LogUtils.getL7dLogger(ManagedApiFeature.class);
@Override
public void initialize(Server server, Bus bus) {
ManagedApi mApi = new ManagedApi(bus, server.getEndpoint(), server);
ManagedEndpoint mEndpoint = new ManagedEndpoint(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);
iMgr.register(mEndpoint);
ServerLifeCycleManager slcMgr = bus.getExtension(ServerLifeCycleManager.class);
if (slcMgr != null) {
slcMgr.registerListener(mApi);
slcMgr.registerListener(mEndpoint);
mApi.startServer(server);
mEndpoint.startServer(server);
}
} catch (JMException jmex) {
jmex.printStackTrace();
LOG.log(Level.WARNING, "Registering ManagedApi failed.", jmex);