Search in sources :

Example 66 with StandardMBean

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

the class FrameworkMBeanHandler 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);
    ServiceReference startLevelRef = context.getServiceReference(StartLevel.class.getCanonicalName());
    StartLevel startLevel = (StartLevel) context.getService(startLevelRef);
    FrameworkMBean framework = new Framework(context, startLevel, packageAdmin);
    try {
        mbean = new StandardMBean(framework, FrameworkMBean.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) StartLevel(org.osgi.service.startlevel.StartLevel) FrameworkMBean(org.osgi.jmx.framework.FrameworkMBean) ServiceReference(org.osgi.framework.ServiceReference)

Example 67 with StandardMBean

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

the class ProvisioningServiceMBeanHandler method constructInjectMBean.

/**
 * @see org.apache.aries.jmx.AbstractCompendiumHandler#constructInjectMBean(java.lang.Object)
 */
@Override
protected StandardMBean constructInjectMBean(Object targetService) {
    ProvisioningService psMBean = new ProvisioningService((org.osgi.service.provisioning.ProvisioningService) targetService);
    StandardMBean mbean = null;
    try {
        mbean = new StandardMBean(psMBean, ProvisioningServiceMBean.class);
    } catch (NotCompliantMBeanException e) {
        Logger logger = agentContext.getLogger();
        logger.log(LogService.LOG_ERROR, "Failed to instantiate MBean for " + ProvisioningServiceMBean.class.getName(), e);
    }
    return mbean;
}
Also used : ProvisioningServiceMBean(org.osgi.jmx.service.provisioning.ProvisioningServiceMBean) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) Logger(org.apache.aries.jmx.Logger)

Example 68 with StandardMBean

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

the class ConfigurationAdminMBeanHandler method constructInjectMBean.

/**
 * @see org.apache.aries.jmx.AbstractCompendiumHandler#constructInjectMBean(java.lang.Object)
 */
@Override
protected StandardMBean constructInjectMBean(Object targetService) {
    ConfigurationAdminMBean caMBean = new org.apache.aries.jmx.cm.ConfigurationAdmin((org.osgi.service.cm.ConfigurationAdmin) targetService);
    StandardMBean mbean = null;
    try {
        mbean = new StandardMBean(caMBean, ConfigurationAdminMBean.class);
    } catch (NotCompliantMBeanException e) {
        Logger logger = agentContext.getLogger();
        logger.log(LogService.LOG_ERROR, "Failed to instantiate MBean for " + ConfigurationAdminMBean.class.getName(), e);
    }
    return mbean;
}
Also used : ConfigurationAdminMBean(org.osgi.jmx.service.cm.ConfigurationAdminMBean) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) Logger(org.apache.aries.jmx.Logger)

Example 69 with StandardMBean

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

the class GridMBeanSelfTest method testMissedDescriptionMBeanInfo.

/**
 * Tests correct MBean interface.
 *
 * @throws Exception Thrown if test fails.
 */
@Test
public void testMissedDescriptionMBeanInfo() throws Exception {
    try {
        StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), GridMBeanInterfaceBadAgain.class);
        mbean.getMBeanInfo();
    } catch (AssertionError ignored) {
        return;
    }
    assert false;
}
Also used : StandardMBean(javax.management.StandardMBean) IgniteStandardMXBean(org.apache.ignite.internal.mxbean.IgniteStandardMXBean) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 70 with StandardMBean

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

the class GridMBeanSelfTest method testMissedNameMBeanInfo.

/**
 * Tests correct MBean interface.
 *
 * @throws Exception Thrown if test fails.
 */
@Test
public void testMissedNameMBeanInfo() throws Exception {
    try {
        StandardMBean mbean = new IgniteStandardMXBean(new GridMBeanImplementation(), GridMBeanInterfaceBad.class);
        mbean.getMBeanInfo();
    } catch (AssertionError ignored) {
        return;
    }
    assert false;
}
Also used : StandardMBean(javax.management.StandardMBean) IgniteStandardMXBean(org.apache.ignite.internal.mxbean.IgniteStandardMXBean) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.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