Search in sources :

Example 1 with LogManagerMBean

use of org.apache.felix.jmood.compendium.LogManagerMBean 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 2 with LogManagerMBean

use of org.apache.felix.jmood.compendium.LogManagerMBean 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)

Aggregations

InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)2 MBeanRegistrationException (javax.management.MBeanRegistrationException)2 MalformedObjectNameException (javax.management.MalformedObjectNameException)2 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)2 ObjectName (javax.management.ObjectName)2 ConfigAdminManager (org.apache.felix.jmood.compendium.ConfigAdminManager)2 ConfigAdminManagerMBean (org.apache.felix.jmood.compendium.ConfigAdminManagerMBean)2 LogManager (org.apache.felix.jmood.compendium.LogManager)2 LogManagerMBean (org.apache.felix.jmood.compendium.LogManagerMBean)2 UserManager (org.apache.felix.jmood.compendium.UserManager)2 UserManagerMBean (org.apache.felix.jmood.compendium.UserManagerMBean)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)1 LogService (org.osgi.service.log.LogService)1 UserAdmin (org.osgi.service.useradmin.UserAdmin)1