Search in sources :

Example 46 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project ddf by codice.

the class ResourceDownloadTest method setupMockMBeanServer.

private void setupMockMBeanServer(boolean isRegistered, boolean throwMBeanRegException) throws Exception {
    when(mockMBeanServer.isRegistered(resourceDownloadObjectName)).thenReturn(isRegistered);
    if (throwMBeanRegException) {
        doThrow(new MBeanRegistrationException(new Exception(), "")).when(mockMBeanServer).registerMBean(any(StandardMBean.class), eq(resourceDownloadObjectName));
        doThrow(new MBeanRegistrationException(new Exception(), "")).when(mockMBeanServer).unregisterMBean(resourceDownloadObjectName);
    }
}
Also used : StandardMBean(javax.management.StandardMBean) MBeanRegistrationException(javax.management.MBeanRegistrationException) MBeanRegistrationException(javax.management.MBeanRegistrationException) IOException(java.io.IOException) ResourceNotFoundException(ddf.catalog.resource.ResourceNotFoundException) MalformedObjectNameException(javax.management.MalformedObjectNameException) ResourceNotSupportedException(ddf.catalog.resource.ResourceNotSupportedException) MBeanException(javax.management.MBeanException)

Example 47 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project ddf by codice.

the class UndeliveredMessages method registerMbean.

private void registerMbean() {
    try {
        undeliveredMessagesObjectName = new ObjectName(UndeliveredMessages.class.getName() + M_BEAN_NAME);
    } catch (MalformedObjectNameException e) {
        LOGGER.warn("Unable to create MBean: [{}]. For more " + "information, set logging level to DEBUG.", undeliveredMessagesObjectName);
        LOGGER.debug("Unable to create MBean: [{}].", undeliveredMessagesObjectName, e);
    }
    if (mBeanServer == null) {
        LOGGER.warn("Could not register MBean: [{}], MBean server is null.", undeliveredMessagesObjectName);
        return;
    }
    try {
        try {
            mBeanServer.registerMBean(this, undeliveredMessagesObjectName);
            LOGGER.info("Registered MBean under object name: {}", undeliveredMessagesObjectName);
        } catch (InstanceAlreadyExistsException e) {
            // Try to remove and re-register
            mBeanServer.unregisterMBean(undeliveredMessagesObjectName);
            mBeanServer.registerMBean(this, undeliveredMessagesObjectName);
            LOGGER.info("Re-registered MBean: [{}]", undeliveredMessagesObjectName);
        }
    } catch (MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
        LOGGER.warn("Could not register MBean: [{}]. For more information, set " + "logging level to DEBUG.", undeliveredMessagesObjectName);
        LOGGER.debug("Could not register MBean: [{}].", undeliveredMessagesObjectName, e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) InstanceNotFoundException(javax.management.InstanceNotFoundException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 48 with MBeanRegistrationException

use of javax.management.MBeanRegistrationException in project ddf by codice.

the class TestMigratable method initWhenMBeanUnregistrationFails.

@Test(expected = MBeanRegistrationException.class)
public void initWhenMBeanUnregistrationFails() throws Exception {
    ConfigurationMigrationManager configurationMigrationManager = createConfigurationMigrationManager();
    when(mBeanServer.registerMBean(configurationMigrationManager, configMigrationServiceObjectName)).thenThrow(new InstanceAlreadyExistsException());
    doThrow(new MBeanRegistrationException(new Exception())).when(mBeanServer).unregisterMBean(configMigrationServiceObjectName);
    configurationMigrationManager.init();
}
Also used : InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) MigrationException(org.codice.ddf.migration.MigrationException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) IOException(java.io.IOException) MalformedObjectNameException(javax.management.MalformedObjectNameException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

MBeanRegistrationException (javax.management.MBeanRegistrationException)48 ObjectName (javax.management.ObjectName)39 MalformedObjectNameException (javax.management.MalformedObjectNameException)35 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)31 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)29 InstanceNotFoundException (javax.management.InstanceNotFoundException)21 MBeanServer (javax.management.MBeanServer)20 StandardMBean (javax.management.StandardMBean)8 IOException (java.io.IOException)7 RuntimeOperationsException (javax.management.RuntimeOperationsException)5 MalformedURLException (java.net.MalformedURLException)4 JMRuntimeException (javax.management.JMRuntimeException)3 MBeanException (javax.management.MBeanException)3 ObjectInstance (javax.management.ObjectInstance)3 PrivilegedActionException (java.security.PrivilegedActionException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ReflectionException (javax.management.ReflectionException)2 Test (org.junit.Test)2 Logger (ch.qos.logback.classic.Logger)1