Search in sources :

Example 66 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException 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 67 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException 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 68 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException 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 69 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException 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 70 with NotCompliantMBeanException

use of javax.management.NotCompliantMBeanException 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

NotCompliantMBeanException (javax.management.NotCompliantMBeanException)106 ObjectName (javax.management.ObjectName)73 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)71 MBeanRegistrationException (javax.management.MBeanRegistrationException)71 MalformedObjectNameException (javax.management.MalformedObjectNameException)59 MBeanServer (javax.management.MBeanServer)39 InstanceNotFoundException (javax.management.InstanceNotFoundException)23 StandardMBean (javax.management.StandardMBean)20 MBeanException (javax.management.MBeanException)8 ReflectionException (javax.management.ReflectionException)8 IOException (java.io.IOException)7 ObjectInstance (javax.management.ObjectInstance)5 AttributeNotFoundException (javax.management.AttributeNotFoundException)4 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)4 ListenerNotFoundException (javax.management.ListenerNotFoundException)4 Logger (org.apache.aries.jmx.Logger)4 MalformedURLException (java.net.MalformedURLException)3 DynamicMBean (javax.management.DynamicMBean)3 IntrospectionException (javax.management.IntrospectionException)3 JMRuntimeException (javax.management.JMRuntimeException)3