Search in sources :

Example 31 with StandardMBean

use of javax.management.StandardMBean in project aries by apache.

the class PackageStateMBeanHandler method open.

/**
 * @see org.apache.aries.jmx.MBeanHandler#open()
 */
public void open() {
    ServiceReference adminRef = context.getServiceReference(PackageAdmin.class.getCanonicalName());
    PackageAdmin packageAdmin = (PackageAdmin) context.getService(adminRef);
    PackageStateMBean packageState = new PackageState(context, packageAdmin);
    try {
        mbean = new StandardMBean(packageState, PackageStateMBean.class);
    } catch (NotCompliantMBeanException e) {
        logger.log(LogService.LOG_ERROR, "Not compliant MBean", e);
    }
    agentContext.registerMBean(this);
}
Also used : PackageAdmin(org.osgi.service.packageadmin.PackageAdmin) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) PackageStateMBean(org.osgi.jmx.framework.PackageStateMBean) ServiceReference(org.osgi.framework.ServiceReference)

Example 32 with StandardMBean

use of javax.management.StandardMBean in project aries by apache.

the class PermissionAdminMBeanHandler method constructInjectMBean.

/**
 * @see org.apache.aries.jmx.AbstractCompendiumHandler#constructInjectMBean(java.lang.Object)
 */
@Override
protected StandardMBean constructInjectMBean(Object targetService) {
    PermissionAdminMBean paMBean = new PermissionAdmin((org.osgi.service.permissionadmin.PermissionAdmin) targetService);
    StandardMBean mbean = null;
    try {
        mbean = new StandardMBean(paMBean, PermissionAdminMBean.class);
    } catch (NotCompliantMBeanException e) {
        Logger logger = agentContext.getLogger();
        logger.log(LogService.LOG_ERROR, "Not compliant MBean", e);
    }
    return mbean;
}
Also used : StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) PermissionAdminMBean(org.osgi.jmx.service.permissionadmin.PermissionAdminMBean) Logger(org.apache.aries.jmx.Logger)

Example 33 with StandardMBean

use of javax.management.StandardMBean 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 34 with StandardMBean

use of javax.management.StandardMBean in project aries by apache.

the class Activator method registerMBeans.

protected void registerMBeans(MBeanServer mbeanServer) {
    // register BlueprintStateMBean to MBean server
    LOGGER.debug("Registering bundle state monitor with MBeanServer: {} with name: {}", mbeanServer, blueprintStateName);
    try {
        StandardMBean blueprintState = new RegistrableStandardEmitterMBean(new BlueprintState(bundleContext), BlueprintStateMBean.class);
        mbeanServer.registerMBean(blueprintState, blueprintStateName);
    } catch (InstanceAlreadyExistsException e) {
        LOGGER.debug("Cannot register BlueprintStateMBean");
    } catch (MBeanRegistrationException e) {
        LOGGER.error("Cannot register BlueprintStateMBean", e);
    } catch (NotCompliantMBeanException e) {
        LOGGER.error("Cannot register BlueprintStateMBean", e);
    }
    // register BlueprintMetadataMBean to MBean server
    LOGGER.debug("Registering bundle metadata monitor with MBeanServer: {} with name: {}", mbeanServer, blueprintMetadataName);
    try {
        StandardMBean blueprintMetadata = new StandardMBean(new BlueprintMetadata(bundleContext), BlueprintMetadataMBean.class);
        mbeanServer.registerMBean(blueprintMetadata, blueprintMetadataName);
    } catch (InstanceAlreadyExistsException e) {
        LOGGER.debug("Cannot register BlueprintMetadataMBean");
    } catch (MBeanRegistrationException e) {
        LOGGER.error("Cannot register BlueprintMetadataMBean", e);
    } catch (NotCompliantMBeanException e) {
        LOGGER.error("Cannot register BlueprintMetadataMBean", e);
    }
}
Also used : StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException)

Example 35 with StandardMBean

use of javax.management.StandardMBean in project spring-framework by spring-projects.

the class JmxUtilsTests method isMBeanWithStandardMBeanWrapper.

@Test
void isMBeanWithStandardMBeanWrapper() throws NotCompliantMBeanException {
    StandardMBean mbean = new StandardMBean(new JmxTestBean(), IJmxTestBean.class);
    assertThat(JmxUtils.isMBean(mbean.getClass())).as("Standard MBean not detected correctly").isTrue();
}
Also used : StandardMBean(javax.management.StandardMBean) JmxTestBean(org.springframework.jmx.JmxTestBean) IJmxTestBean(org.springframework.jmx.IJmxTestBean) Test(org.junit.jupiter.api.Test)

Aggregations

StandardMBean (javax.management.StandardMBean)70 ObjectName (javax.management.ObjectName)32 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)21 MBeanServer (javax.management.MBeanServer)17 MalformedObjectNameException (javax.management.MalformedObjectNameException)16 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)12 MBeanRegistrationException (javax.management.MBeanRegistrationException)9 Test (org.junit.Test)9 JMException (javax.management.JMException)7 IOException (java.io.IOException)6 Logger (org.apache.aries.jmx.Logger)6 InstanceNotFoundException (javax.management.InstanceNotFoundException)5 Activate (org.apache.felix.scr.annotations.Activate)5 IgniteStandardMXBean (org.apache.ignite.internal.mxbean.IgniteStandardMXBean)5 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)5 MBeanInfo (javax.management.MBeanInfo)4 OpenDataException (javax.management.openmbean.OpenDataException)4 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)3 CompositeType (javax.management.openmbean.CompositeType)3 OpenType (javax.management.openmbean.OpenType)3