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;
}
}
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);
}
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);
}
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);
}
Aggregations