Search in sources :

Example 71 with InstanceAlreadyExistsException

use of javax.management.InstanceAlreadyExistsException in project wikidata-query-rdf by wikimedia.

the class ThrottlingFilter method registerMBean.

/**
 * Register this Filter as an MBean.
 *
 * On successful registration, the {@link ObjectName} used for registration
 * will be stored into the instance field {@link ThrottlingFilter#objectName}.
 *
 * @param filterName
 */
private void registerMBean(String filterName) {
    try {
        ObjectName objectName = new ObjectName(ThrottlingFilter.class.getName(), "filterName", filterName);
        MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
        platformMBeanServer.registerMBean(this, objectName);
        this.objectName = objectName;
        log.info("ThrottlingFilter MBean registered as {}.", objectName);
    } catch (MalformedObjectNameException e) {
        log.error("filter name {} is invalid as an MBean property.", filterName, e);
    } catch (InstanceAlreadyExistsException e) {
        log.error("MBean for ThrottlingFilter has already been registered.", e);
    } catch (NotCompliantMBeanException | MBeanRegistrationException e) {
        log.error("Could not register MBean for ThrottlingFilter.", e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName) MBeanServer(javax.management.MBeanServer)

Example 72 with InstanceAlreadyExistsException

use of javax.management.InstanceAlreadyExistsException in project felix by apache.

the class CompendiumHandler method handleEvent.

private void handleEvent(ServiceReference serviceReference, String iService, int eType) {
    try {
        if (iService.equals(ConfigurationAdmin.class.getName())) {
            switch(eType) {
                case ServiceEvent.REGISTERED:
                    ConfigAdminManagerMBean ca = new ConfigAdminManager(ac);
                    server.registerMBean(ca, new ObjectName(ObjectNames.CM_SERVICE));
                    break;
                case ServiceEvent.UNREGISTERING:
                    server.unregisterMBean(new ObjectName(ObjectNames.CM_SERVICE));
                    break;
                default:
                    break;
            }
        }
        if (iService.equals(LogService.class.getName())) {
            switch(eType) {
                case ServiceEvent.REGISTERED:
                    LogManagerMBean lm = new LogManager(ac);
                    server.registerMBean(lm, new ObjectName(ObjectNames.LOG_SERVICE));
                    break;
                case ServiceEvent.UNREGISTERING:
                    server.unregisterMBean(new ObjectName(ObjectNames.LOG_SERVICE));
                    break;
                default:
                    break;
            }
        }
        if (iService.equals(UserAdmin.class.getName())) {
            switch(eType) {
                case ServiceEvent.REGISTERED:
                    UserManagerMBean um = new UserManager(ac);
                    server.registerMBean(um, new ObjectName(ObjectNames.UA_SERVICE));
                    break;
                case ServiceEvent.UNREGISTERING:
                    server.unregisterMBean(new ObjectName(ObjectNames.UA_SERVICE));
                    break;
                default:
                    break;
            }
        }
    } catch (InstanceAlreadyExistsException e) {
        ac.error("Unexpected error", e);
    } catch (MBeanRegistrationException e) {
        ac.error("Unexpected error", e);
    } catch (NotCompliantMBeanException e) {
        ac.error("Unexpected error", e);
    } catch (MalformedObjectNameException e) {
        ac.error("Unexpected error", e);
    } catch (NullPointerException e) {
        ac.error("Unexpected error", e);
    } catch (InstanceNotFoundException e) {
        ac.error("Unexpected error", e);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) UserAdmin(org.osgi.service.useradmin.UserAdmin) UserManagerMBean(org.apache.felix.jmood.compendium.UserManagerMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ConfigAdminManager(org.apache.felix.jmood.compendium.ConfigAdminManager) ConfigAdminManagerMBean(org.apache.felix.jmood.compendium.ConfigAdminManagerMBean) ObjectName(javax.management.ObjectName) UserManager(org.apache.felix.jmood.compendium.UserManager) LogManagerMBean(org.apache.felix.jmood.compendium.LogManagerMBean) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) LogManager(org.apache.felix.jmood.compendium.LogManager) LogService(org.osgi.service.log.LogService) MBeanRegistrationException(javax.management.MBeanRegistrationException)

Example 73 with InstanceAlreadyExistsException

use of javax.management.InstanceAlreadyExistsException in project felix by apache.

the class CompendiumHandler method initController.

public void initController() {
    try {
        if (ac.getConfigurationAdmin() != null) {
            ConfigAdminManagerMBean ca = new ConfigAdminManager(ac);
            server.registerMBean(ca, new ObjectName(ObjectNames.CM_SERVICE));
        }
        if (ac.getLogservice() != null) {
            LogManagerMBean lm = new LogManager(ac);
            server.registerMBean(lm, new ObjectName(ObjectNames.LOG_SERVICE));
        }
        if (ac.getUserAdmin() != null) {
            UserManagerMBean um = new UserManager(ac);
            server.registerMBean(um, new ObjectName(ObjectNames.UA_SERVICE));
        }
    } catch (InstanceAlreadyExistsException e) {
        ac.error("Unexpected error", e);
    } catch (MBeanRegistrationException e) {
        ac.error("Unexpected error", e);
    } catch (NotCompliantMBeanException e) {
        ac.error("Unexpected error", e);
    } catch (MalformedObjectNameException e) {
        ac.error("Unexpected error", e);
    } catch (NullPointerException e) {
        ac.error("Unexpected error", e);
    }
    ac.getBundleContext().addServiceListener(sl);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) UserManagerMBean(org.apache.felix.jmood.compendium.UserManagerMBean) UserManager(org.apache.felix.jmood.compendium.UserManager) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ConfigAdminManager(org.apache.felix.jmood.compendium.ConfigAdminManager) LogManagerMBean(org.apache.felix.jmood.compendium.LogManagerMBean) LogManager(org.apache.felix.jmood.compendium.LogManager) ConfigAdminManagerMBean(org.apache.felix.jmood.compendium.ConfigAdminManagerMBean) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 74 with InstanceAlreadyExistsException

use of javax.management.InstanceAlreadyExistsException in project felix by apache.

the class MBeanRegistrator method registerBundleMBean.

private void registerBundleMBean(Bundle bundle) {
    try {
        server.registerMBean(new ManagedBundle(bundle, ac), new ObjectName(ObjectNames.BUNDLE + InstrumentationSupport.getSymbolicName(bundle)));
        ac.debug("registered mbean for " + bundle.getSymbolicName());
    } catch (InstanceAlreadyExistsException iaee) {
        ac.error("unexpected error:", iaee);
    } catch (MBeanRegistrationException mre) {
        ac.error("unexpected error:", mre);
    } catch (NotCompliantMBeanException ncme) {
        ac.error("unexpected error:", ncme);
    } catch (MalformedObjectNameException mone) {
        ac.error("unexpected error:", mone);
    } catch (NullPointerException npe) {
        ac.error("unexpected error:", npe);
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Example 75 with InstanceAlreadyExistsException

use of javax.management.InstanceAlreadyExistsException in project felix by apache.

the class AgentActivator method register.

private void register(ServiceReference serviceReference) {
    String name = this.getObjectNameString(serviceReference);
    Object mbean = bc.getService(serviceReference);
    ObjectName objectName = null;
    try {
        // Unique identification of MBeans
        objectName = new ObjectName(name);
    } catch (MalformedObjectNameException e) {
        e.printStackTrace();
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
    try {
        // Uniquely identify the MBean and register it with the MBeanServer
        server.registerMBean(mbean, objectName);
    } catch (InstanceAlreadyExistsException e1) {
        e1.printStackTrace();
    } catch (MBeanRegistrationException e1) {
        e1.printStackTrace();
    } catch (NotCompliantMBeanException e1) {
        e1.printStackTrace();
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Aggregations

InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)116 ObjectName (javax.management.ObjectName)87 MBeanRegistrationException (javax.management.MBeanRegistrationException)73 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)70 MalformedObjectNameException (javax.management.MalformedObjectNameException)64 MBeanServer (javax.management.MBeanServer)48 InstanceNotFoundException (javax.management.InstanceNotFoundException)37 IOException (java.io.IOException)13 ObjectInstance (javax.management.ObjectInstance)12 Test (org.junit.Test)12 StandardMBean (javax.management.StandardMBean)9 MBeanException (javax.management.MBeanException)7 ReflectionException (javax.management.ReflectionException)7 HashMap (java.util.HashMap)5 JMRuntimeException (javax.management.JMRuntimeException)4 RuntimeOperationsException (javax.management.RuntimeOperationsException)4 MalformedURLException (java.net.MalformedURLException)3 AttributeNotFoundException (javax.management.AttributeNotFoundException)3 DynamicMBean (javax.management.DynamicMBean)3 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)3