use of javax.management.JMException in project cxf by apache.
the class CounterRepository method createCounter.
public Counter createCounter(ObjectName on) {
Counter counter = new ResponseTimeCounter(on);
InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
if (null != im) {
try {
im.register(counter);
} catch (JMException e) {
LOG.log(Level.WARNING, "INSTRUMENTATION_REGISTER_FAULT_MSG", new Object[] { on, e });
}
}
return counter;
}
use of javax.management.JMException in project cxf by apache.
the class InstrumentationManagerImpl method init.
@PostConstruct
public void init() {
if (bus != null && bus.getExtension(MBeanServer.class) != null) {
enabled = true;
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 (!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 javax.management.JMException in project vibur-dbcp by vibur.
the class ViburMonitoring method unregisterMBean.
static void unregisterMBean(ViburDBCPDataSource dataSource) {
try {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName objectName = new ObjectName(dataSource.getJmxName());
if (mbs.isRegistered(objectName)) {
mbs.unregisterMBean(objectName);
} else {
logger.debug(dataSource.getJmxName() + " is not registered.");
}
} catch (JMException e) {
logger.warn("Unable to unregister mBean {}", dataSource.getJmxName(), e);
}
}
use of javax.management.JMException in project vibur-dbcp by vibur.
the class ViburMonitoring method registerMBean.
static void registerMBean(ViburDBCPDataSource dataSource) {
try {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName objectName = new ObjectName(dataSource.getJmxName());
if (!mbs.isRegistered(objectName)) {
mbs.registerMBean(new ViburMonitoring(dataSource), objectName);
} else {
logger.warn(dataSource.getJmxName() + " is already registered.");
}
} catch (JMException e) {
logger.warn("Unable to register mBean {}", dataSource.getJmxName(), e);
}
}
use of javax.management.JMException in project alfresco-repository by Alfresco.
the class DynamicMBeanExporter method registerMBean.
/*
* (non-Javadoc)
* @see org.alfresco.enterprise.repo.management.DynamicMBeanExportOperations#registerMBean(java.lang.Object,
* javax.management.ObjectName)
*/
@SuppressWarnings("unchecked")
public ObjectName registerMBean(Object managedResource, ObjectName objectName) {
Object mbean;
if (isMBean(managedResource.getClass())) {
mbean = managedResource;
} else {
mbean = createAndConfigureMBean(managedResource, managedResource.getClass().getName());
}
ObjectName actualObjectName = objectName;
try {
doRegister(mbean, actualObjectName);
} catch (JMException e) {
throw new RuntimeException(e);
}
return actualObjectName;
}
Aggregations