Search in sources :

Example 1 with MBeanHandler

use of org.apache.aries.jmx.MBeanHandler in project aries by apache.

the class JMXAgentImpl method unregisterMBeans.

/**
 * @see org.apache.aries.jmx.agent.JMXAgent#unregisterMBeans(javax.management.MBeanServer)
 */
public synchronized void unregisterMBeans(final MBeanServer server) {
    for (MBeanHandler mBeanHandler : mbeansHandlers.keySet()) {
        if (mbeansHandlers.get(mBeanHandler) == Boolean.TRUE) {
            try {
                String name = mBeanHandler.getName();
                StandardMBean mbean = mBeanHandler.getMbean();
                if (mbean != null) {
                    logger.log(LogService.LOG_INFO, "Unregistering " + mbean.getMBeanInterface().getName() + " to MBeanServer " + server + " with name " + name);
                    server.unregisterMBean(new ObjectName(name));
                }
            } catch (MBeanRegistrationException e) {
                logger.log(LogService.LOG_ERROR, "Can't unregister MBean", e);
            } catch (InstanceNotFoundException e) {
                logger.log(LogService.LOG_ERROR, "MBean doesn't exist in the repository", e);
            } catch (MalformedObjectNameException e) {
                logger.log(LogService.LOG_ERROR, "Try to unregister with no valid objectname", e);
            } catch (NullPointerException e) {
                logger.log(LogService.LOG_ERROR, "Name of objectname can't be null ", e);
            } catch (Exception e) {
                logger.log(LogService.LOG_ERROR, "Cannot unregister MBean: " + mBeanHandler, e);
            }
        }
    }
    mbeanServers.remove(server);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) StandardMBean(javax.management.StandardMBean) InstanceNotFoundException(javax.management.InstanceNotFoundException) ConfigurationAdminMBeanHandler(org.apache.aries.jmx.cm.ConfigurationAdminMBeanHandler) ProvisioningServiceMBeanHandler(org.apache.aries.jmx.provisioning.ProvisioningServiceMBeanHandler) MBeanHandler(org.apache.aries.jmx.MBeanHandler) PackageStateMBeanHandler(org.apache.aries.jmx.framework.PackageStateMBeanHandler) PermissionAdminMBeanHandler(org.apache.aries.jmx.permissionadmin.PermissionAdminMBeanHandler) BundleStateMBeanHandler(org.apache.aries.jmx.framework.BundleStateMBeanHandler) UserAdminMBeanHandler(org.apache.aries.jmx.useradmin.UserAdminMBeanHandler) FrameworkMBeanHandler(org.apache.aries.jmx.framework.FrameworkMBeanHandler) BundleWiringStateMBeanHandler(org.apache.aries.jmx.framework.wiring.BundleWiringStateMBeanHandler) ServiceStateMBeanHandler(org.apache.aries.jmx.framework.ServiceStateMBeanHandler) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) InstanceNotFoundException(javax.management.InstanceNotFoundException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MalformedObjectNameException(javax.management.MalformedObjectNameException) ObjectName(javax.management.ObjectName)

Example 2 with MBeanHandler

use of org.apache.aries.jmx.MBeanHandler in project aries by apache.

the class JMXAgentImpl method start.

/**
 * @see org.apache.aries.jmx.agent.JMXAgent#start()
 */
public synchronized void start() {
    logger.log(LogService.LOG_INFO, "Starting JMX OSGi agent");
    // Initialize static handlers
    // Those handlers do not track dependencies
    JMXAgentContext agentContext = new JMXAgentContext(context, this, logger);
    MBeanHandler frameworkHandler = new FrameworkMBeanHandler(agentContext);
    mbeansHandlers.put(frameworkHandler, Boolean.FALSE);
    frameworkHandler.open();
    MBeanHandler bundleStateHandler = new BundleStateMBeanHandler(agentContext, stateConfig);
    mbeansHandlers.put(bundleStateHandler, Boolean.FALSE);
    bundleStateHandler.open();
    MBeanHandler revisionsStateHandler = new BundleWiringStateMBeanHandler(agentContext);
    mbeansHandlers.put(revisionsStateHandler, Boolean.FALSE);
    revisionsStateHandler.open();
    MBeanHandler serviceStateHandler = new ServiceStateMBeanHandler(agentContext, stateConfig);
    mbeansHandlers.put(serviceStateHandler, Boolean.FALSE);
    serviceStateHandler.open();
    MBeanHandler packageStateHandler = new PackageStateMBeanHandler(agentContext);
    mbeansHandlers.put(packageStateHandler, Boolean.FALSE);
    packageStateHandler.open();
    MBeanHandler permissionAdminHandler = new PermissionAdminMBeanHandler(agentContext);
    mbeansHandlers.put(permissionAdminHandler, Boolean.FALSE);
    permissionAdminHandler.open();
    MBeanHandler userAdminHandler = new UserAdminMBeanHandler(agentContext);
    mbeansHandlers.put(userAdminHandler, Boolean.FALSE);
    userAdminHandler.open();
    MBeanHandler configAdminHandler = new ConfigurationAdminMBeanHandler(agentContext);
    mbeansHandlers.put(configAdminHandler, Boolean.FALSE);
    configAdminHandler.open();
    MBeanHandler provServiceHandler = new ProvisioningServiceMBeanHandler(agentContext);
    mbeansHandlers.put(provServiceHandler, Boolean.FALSE);
    provServiceHandler.open();
    // Track mbean servers
    mbeanServiceTracker = new MBeanServiceTracker(agentContext);
    mbeanServiceTracker.open();
}
Also used : PermissionAdminMBeanHandler(org.apache.aries.jmx.permissionadmin.PermissionAdminMBeanHandler) MBeanServiceTracker(org.apache.aries.jmx.MBeanServiceTracker) FrameworkMBeanHandler(org.apache.aries.jmx.framework.FrameworkMBeanHandler) PackageStateMBeanHandler(org.apache.aries.jmx.framework.PackageStateMBeanHandler) ProvisioningServiceMBeanHandler(org.apache.aries.jmx.provisioning.ProvisioningServiceMBeanHandler) BundleStateMBeanHandler(org.apache.aries.jmx.framework.BundleStateMBeanHandler) UserAdminMBeanHandler(org.apache.aries.jmx.useradmin.UserAdminMBeanHandler) ConfigurationAdminMBeanHandler(org.apache.aries.jmx.cm.ConfigurationAdminMBeanHandler) ProvisioningServiceMBeanHandler(org.apache.aries.jmx.provisioning.ProvisioningServiceMBeanHandler) MBeanHandler(org.apache.aries.jmx.MBeanHandler) PackageStateMBeanHandler(org.apache.aries.jmx.framework.PackageStateMBeanHandler) PermissionAdminMBeanHandler(org.apache.aries.jmx.permissionadmin.PermissionAdminMBeanHandler) BundleStateMBeanHandler(org.apache.aries.jmx.framework.BundleStateMBeanHandler) UserAdminMBeanHandler(org.apache.aries.jmx.useradmin.UserAdminMBeanHandler) FrameworkMBeanHandler(org.apache.aries.jmx.framework.FrameworkMBeanHandler) BundleWiringStateMBeanHandler(org.apache.aries.jmx.framework.wiring.BundleWiringStateMBeanHandler) ServiceStateMBeanHandler(org.apache.aries.jmx.framework.ServiceStateMBeanHandler) ServiceStateMBeanHandler(org.apache.aries.jmx.framework.ServiceStateMBeanHandler) ConfigurationAdminMBeanHandler(org.apache.aries.jmx.cm.ConfigurationAdminMBeanHandler) BundleWiringStateMBeanHandler(org.apache.aries.jmx.framework.wiring.BundleWiringStateMBeanHandler)

Example 3 with MBeanHandler

use of org.apache.aries.jmx.MBeanHandler in project aries by apache.

the class JMXAgentImpl method registerMBeans.

/**
 * @see org.apache.aries.jmx.agent.JMXAgent#registerMBeans(javax.management.MBeanServer)
 */
public synchronized void registerMBeans(final MBeanServer server) {
    for (MBeanHandler mbeanHandler : mbeansHandlers.keySet()) {
        if (mbeansHandlers.get(mbeanHandler) == Boolean.TRUE) {
            String name = mbeanHandler.getName();
            StandardMBean mbean = mbeanHandler.getMbean();
            if (mbean != null) {
                try {
                    logger.log(LogService.LOG_INFO, "Registering " + mbean.getMBeanInterface().getName() + " to MBeanServer " + server + " with name " + name);
                    server.registerMBean(mbean, new ObjectName(name));
                } catch (InstanceAlreadyExistsException e) {
                    logger.log(LogService.LOG_ERROR, "MBean is already registered", e);
                } catch (MBeanRegistrationException e) {
                    logger.log(LogService.LOG_ERROR, "Can't register MBean", e);
                } catch (NotCompliantMBeanException e) {
                    logger.log(LogService.LOG_ERROR, "MBean is not compliant MBean", e);
                } catch (MalformedObjectNameException e) {
                    logger.log(LogService.LOG_ERROR, "Try to register with no valid objectname", e);
                } catch (NullPointerException e) {
                    logger.log(LogService.LOG_ERROR, "Name of objectname can't be null", e);
                }
            }
        }
    }
    mbeanServers.put(server, Boolean.TRUE);
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ConfigurationAdminMBeanHandler(org.apache.aries.jmx.cm.ConfigurationAdminMBeanHandler) ProvisioningServiceMBeanHandler(org.apache.aries.jmx.provisioning.ProvisioningServiceMBeanHandler) MBeanHandler(org.apache.aries.jmx.MBeanHandler) PackageStateMBeanHandler(org.apache.aries.jmx.framework.PackageStateMBeanHandler) PermissionAdminMBeanHandler(org.apache.aries.jmx.permissionadmin.PermissionAdminMBeanHandler) BundleStateMBeanHandler(org.apache.aries.jmx.framework.BundleStateMBeanHandler) UserAdminMBeanHandler(org.apache.aries.jmx.useradmin.UserAdminMBeanHandler) FrameworkMBeanHandler(org.apache.aries.jmx.framework.FrameworkMBeanHandler) BundleWiringStateMBeanHandler(org.apache.aries.jmx.framework.wiring.BundleWiringStateMBeanHandler) ServiceStateMBeanHandler(org.apache.aries.jmx.framework.ServiceStateMBeanHandler) MBeanRegistrationException(javax.management.MBeanRegistrationException) ObjectName(javax.management.ObjectName)

Aggregations

MBeanHandler (org.apache.aries.jmx.MBeanHandler)3 ConfigurationAdminMBeanHandler (org.apache.aries.jmx.cm.ConfigurationAdminMBeanHandler)3 BundleStateMBeanHandler (org.apache.aries.jmx.framework.BundleStateMBeanHandler)3 FrameworkMBeanHandler (org.apache.aries.jmx.framework.FrameworkMBeanHandler)3 PackageStateMBeanHandler (org.apache.aries.jmx.framework.PackageStateMBeanHandler)3 ServiceStateMBeanHandler (org.apache.aries.jmx.framework.ServiceStateMBeanHandler)3 BundleWiringStateMBeanHandler (org.apache.aries.jmx.framework.wiring.BundleWiringStateMBeanHandler)3 PermissionAdminMBeanHandler (org.apache.aries.jmx.permissionadmin.PermissionAdminMBeanHandler)3 ProvisioningServiceMBeanHandler (org.apache.aries.jmx.provisioning.ProvisioningServiceMBeanHandler)3 UserAdminMBeanHandler (org.apache.aries.jmx.useradmin.UserAdminMBeanHandler)3 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 StandardMBean (javax.management.StandardMBean)2 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 MBeanServiceTracker (org.apache.aries.jmx.MBeanServiceTracker)1