use of javax.management.InstanceNotFoundException in project ddf by codice.
the class DataUsage method registerMbean.
private void registerMbean() {
try {
objectName = new ObjectName(DataUsage.class.getName() + ":service=datausage");
mBeanServer = ManagementFactory.getPlatformMBeanServer();
} catch (MalformedObjectNameException e) {
LOGGER.error("Unable to create Data Usage Configuration MBean.", e);
}
if (mBeanServer == null) {
return;
}
try {
try {
mBeanServer.registerMBean(this, objectName);
LOGGER.info("Registered Data Usage Configuration MBean under object name: {}", objectName.toString());
} catch (InstanceAlreadyExistsException e) {
// Try to remove and re-register
mBeanServer.unregisterMBean(objectName);
mBeanServer.registerMBean(this, objectName);
LOGGER.info("Re-registered Data Usage Configuration MBean");
}
} catch (MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
LOGGER.error("Could not register MBean [{}].", objectName.toString(), e);
}
}
use of javax.management.InstanceNotFoundException in project ddf by codice.
the class ApplicationServiceBeanTest method testDestroyWhenUnregisterMBeanThrowsInstanceNotFoundException.
/**
* Tests the {@link ApplicationServiceBean#destroy()} method
* for the case where an InstanceNotFoundException is thrown by mBeanServer.unregisterMBean(...)
*
* @throws Exception
*/
@Test(expected = ApplicationServiceException.class)
public void testDestroyWhenUnregisterMBeanThrowsInstanceNotFoundException() throws Exception {
ApplicationServiceBean serviceBean = new ApplicationServiceBean(testAppService, testConfigAdminExt, mBeanServer);
doThrow(new InstanceNotFoundException()).when(mBeanServer).unregisterMBean(objectName);
serviceBean.destroy();
}
use of javax.management.InstanceNotFoundException in project tomcat by apache.
the class SlowQueryReportJmx method deregisterJmx.
protected void deregisterJmx() {
try {
if (mbeans.remove(poolName) != null) {
ObjectName oname = getObjectName(getClass(), poolName);
ManagementFactory.getPlatformMBeanServer().unregisterMBean(oname);
}
} catch (MBeanRegistrationException e) {
log.debug("Jmx deregistration failed.", e);
} catch (InstanceNotFoundException e) {
log.debug("Jmx deregistration failed.", e);
} catch (MalformedObjectNameException e) {
log.warn("Jmx deregistration failed.", e);
} catch (RuntimeOperationsException e) {
log.warn("Jmx deregistration failed.", e);
}
}
use of javax.management.InstanceNotFoundException in project tomcat by apache.
the class DataSource method unregisterJmx.
/**
*
*/
protected void unregisterJmx() {
try {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.unregisterMBean(oname);
} catch (InstanceNotFoundException ignore) {
// NOOP
} catch (Exception e) {
log.error("Unable to unregister JDBC pool with JMX", e);
}
}
use of javax.management.InstanceNotFoundException in project jersey by jersey.
the class MBeansTest method checkResourceMBean.
private void checkResourceMBean(String name) throws MalformedObjectNameException {
final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
final ObjectName objectName = new ObjectName("org.glassfish.jersey:type=myApplication,subType=Uris,resource=\"" + name + "\"");
ObjectInstance mbean = null;
try {
mbean = mBeanServer.getObjectInstance(objectName);
} catch (InstanceNotFoundException e) {
Assert.fail("Resource MBean name '" + name + "' not found.");
}
assertNotNull(mbean);
}
Aggregations