use of javax.management.MBeanRegistrationException in project ddf by codice.
the class ResourceCacheServiceTest method setupMockMBeanServer.
private void setupMockMBeanServer(boolean isRegistered, boolean throwMBeanRegException) throws Exception {
when(mockMBeanServer.isRegistered(resourceCacheServiceObjectName)).thenReturn(isRegistered);
if (throwMBeanRegException) {
doThrow(new MBeanRegistrationException(new Exception(), "")).when(mockMBeanServer).registerMBean(any(StandardMBean.class), eq(resourceCacheServiceObjectName));
doThrow(new MBeanRegistrationException(new Exception(), "")).when(mockMBeanServer).unregisterMBean(resourceCacheServiceObjectName);
}
}
use of javax.management.MBeanRegistrationException in project ddf by codice.
the class TestMigratable method initWhenMBeanReRegistrationFails.
@Test(expected = MBeanRegistrationException.class)
public void initWhenMBeanReRegistrationFails() throws Exception {
ConfigurationMigrationManager configurationMigrationManager = createConfigurationMigrationManager();
when(mBeanServer.registerMBean(configurationMigrationManager, configMigrationServiceObjectName)).thenThrow(new InstanceAlreadyExistsException(), new MBeanRegistrationException(new Exception()));
configurationMigrationManager.init();
}
use of javax.management.MBeanRegistrationException 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.MBeanRegistrationException in project ddf by codice.
the class ApplicationServiceBeanTest method testDestroyWhenUnregisterMBeanThrowsMBeanRegistrationException.
/**
* Tests the {@link ApplicationServiceBean#destroy()} method
* for the case where an MBeanRegistrationException is thrown
* by mBeanServer.unregisterMBean(...)
*
* @throws Exception
*/
@Test(expected = ApplicationServiceException.class)
public void testDestroyWhenUnregisterMBeanThrowsMBeanRegistrationException() throws Exception {
ApplicationServiceBean serviceBean = new ApplicationServiceBean(testAppService, testConfigAdminExt, mBeanServer);
doThrow(new MBeanRegistrationException(new Exception())).when(mBeanServer).unregisterMBean(any(ObjectName.class));
serviceBean.destroy();
}
use of javax.management.MBeanRegistrationException 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);
}
}
Aggregations