use of org.osgi.jmx.framework.PackageStateMBean 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);
}
use of org.osgi.jmx.framework.PackageStateMBean in project aries by apache.
the class PackageStateMBeanTest method testMBeanInterface.
@Test
public void testMBeanInterface() throws IOException {
PackageStateMBean packagaState = getMBean(PackageStateMBean.OBJECTNAME, PackageStateMBean.class);
assertNotNull(packagaState);
long[] exportingBundles = packagaState.getExportingBundles("org.osgi.jmx.framework", "1.7.0");
assertNotNull(exportingBundles);
assertTrue("Should find a bundle exporting org.osgi.jmx.framework", exportingBundles.length > 0);
long[] exportingBundles2 = packagaState.getExportingBundles("test", "1.0.0");
assertNull("Shouldn't find a bundle exporting test package", exportingBundles2);
long[] importingBundlesId = packagaState.getImportingBundles("org.osgi.jmx.framework", "1.7.0", exportingBundles[0]);
assertTrue("Should find bundles importing org.osgi.jmx.framework", importingBundlesId.length > 0);
TabularData table = packagaState.listPackages();
assertNotNull("TabularData containing CompositeData with packages info shouldn't be null", table);
assertEquals("TabularData should be a type PACKAGES", PackageStateMBean.PACKAGES_TYPE, table.getTabularType());
Collection<?> colData = table.values();
assertNotNull("Collection of CompositeData shouldn't be null", colData);
assertFalse("Collection of CompositeData should contain elements", colData.isEmpty());
boolean isRemovalPending = packagaState.isRemovalPending("org.osgi.jmx.framework", "1.7.0", exportingBundles[0]);
assertFalse("Should removal pending on org.osgi.jmx.framework be false", isRemovalPending);
}
Aggregations