use of org.osgi.jmx.framework.BundleStateMBean 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.osgi.jmx.framework.BundleStateMBean in project aries by apache.
the class BundleStateMBeanTest method testBundleIDsAttribute.
@Test
public void testBundleIDsAttribute() throws Exception {
Set<Long> expectedIDs = new HashSet<Long>();
for (Bundle b : context().getBundles()) {
expectedIDs.add(b.getBundleId());
}
BundleStateMBean mbean = getMBean(OBJECTNAME, BundleStateMBean.class);
long[] actual = mbean.getBundleIds();
Set<Long> actualIDs = new HashSet<Long>();
for (long id : actual) {
actualIDs.add(id);
}
assertEquals(expectedIDs, actualIDs);
}
Aggregations