Search in sources :

Example 1 with RegistrableStandardEmitterMBean

use of org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean in project aries by apache.

the class MBeanHolder method create.

static <T> MBeanHolder create(final T mbean, final ObjectName requestedObjectName) {
    if (mbean instanceof DynamicMBean) {
        return new MBeanHolder(mbean, requestedObjectName);
    } else if (mbean == null) {
        return null;
    }
    Class<?> mbeanClass = mbean.getClass();
    // This is all in aid of getting new StandardMBean to work.
    @SuppressWarnings("unchecked") Class<T> mbeanInterface = (Class<T>) getMBeanInterface(mbeanClass);
    if (mbeanInterface == null) {
        return null;
    }
    if (mbeanInterface.getName().equals(mbeanClass.getName().concat("MBean")) || mbeanInterface.getName().equals(mbeanClass.getName().concat("MXBean"))) {
        return new MBeanHolder(mbean, requestedObjectName);
    }
    try {
        StandardMBean stdMbean = new RegistrableStandardEmitterMBean(mbean, mbeanInterface);
        return new MBeanHolder(stdMbean, requestedObjectName);
    } catch (NotCompliantMBeanException e) {
        LoggerFactory.getLogger(MBeanHolder.class).error("create: Cannot create StandardMBean for " + mbean + " of type " + mbeanClass + " for interface " + mbeanInterface, e);
        return null;
    }
}
Also used : DynamicMBean(javax.management.DynamicMBean) StandardMBean(javax.management.StandardMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) RegistrableStandardEmitterMBean(org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean)

Example 2 with RegistrableStandardEmitterMBean

use of org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean in project aries by apache.

the class ServiceStateMBeanHandler method open.

/**
 * @see org.apache.aries.jmx.MBeanHandler#open()
 */
public void open() {
    serviceStateMBean = new ServiceState(bundleContext, stateConfig, logger);
    try {
        mbean = new RegistrableStandardEmitterMBean(serviceStateMBean, ServiceStateMBean.class);
    } catch (NotCompliantMBeanException e) {
        logger.log(LogService.LOG_ERROR, "Failed to instantiate MBean for " + ServiceStateMBean.class.getName(), e);
    }
    agentContext.registerMBean(this);
}
Also used : ServiceStateMBean(org.osgi.jmx.framework.ServiceStateMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) RegistrableStandardEmitterMBean(org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean)

Example 3 with RegistrableStandardEmitterMBean

use of org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean in project aries by apache.

the class BundleStateMBeanHandler method open.

/**
 * @see org.apache.aries.jmx.MBeanHandler#open()
 */
public void open() {
    packageAdminRef = bundleContext.getServiceReference(PackageAdmin.class.getName());
    PackageAdmin packageAdmin = (PackageAdmin) bundleContext.getService(packageAdminRef);
    startLevelRef = bundleContext.getServiceReference(StartLevel.class.getName());
    StartLevel startLevel = (StartLevel) bundleContext.getService(startLevelRef);
    bundleStateMBean = new BundleState(bundleContext, packageAdmin, startLevel, stateConfig, logger);
    try {
        mbean = new RegistrableStandardEmitterMBean(bundleStateMBean, BundleStateMBean.class);
    } catch (NotCompliantMBeanException e) {
        logger.log(LogService.LOG_ERROR, "Failed to instantiate MBean for " + BundleStateMBean.class.getName(), e);
    }
    agentContext.registerMBean(this);
}
Also used : PackageAdmin(org.osgi.service.packageadmin.PackageAdmin) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) RegistrableStandardEmitterMBean(org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean) StartLevel(org.osgi.service.startlevel.StartLevel) BundleStateMBean(org.osgi.jmx.framework.BundleStateMBean)

Example 4 with RegistrableStandardEmitterMBean

use of org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean in project aries by apache.

the class BundleWiringStateMBeanHandler method open.

/* (non-Javadoc)
     * @see org.apache.aries.jmx.MBeanHandler#open()
     */
public void open() {
    revisionsStateMBean = new BundleWiringState(bundleContext, logger);
    try {
        mbean = new RegistrableStandardEmitterMBean(revisionsStateMBean, BundleWiringStateMBean.class);
    } catch (NotCompliantMBeanException e) {
        logger.log(LogService.LOG_ERROR, "Failed to instantiate MBean for " + BundleWiringStateMBean.class.getName(), e);
    }
    agentContext.registerMBean(this);
}
Also used : BundleWiringStateMBean(org.osgi.jmx.framework.wiring.BundleWiringStateMBean) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) RegistrableStandardEmitterMBean(org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean)

Aggregations

NotCompliantMBeanException (javax.management.NotCompliantMBeanException)4 RegistrableStandardEmitterMBean (org.apache.aries.jmx.util.shared.RegistrableStandardEmitterMBean)4 DynamicMBean (javax.management.DynamicMBean)1 StandardMBean (javax.management.StandardMBean)1 BundleStateMBean (org.osgi.jmx.framework.BundleStateMBean)1 ServiceStateMBean (org.osgi.jmx.framework.ServiceStateMBean)1 BundleWiringStateMBean (org.osgi.jmx.framework.wiring.BundleWiringStateMBean)1 PackageAdmin (org.osgi.service.packageadmin.PackageAdmin)1 StartLevel (org.osgi.service.startlevel.StartLevel)1