use of javax.management.openmbean.TabularData in project aries by apache.
the class BundleWiringStateMBeanTest method getJmxAttributes.
@SuppressWarnings("unchecked")
private Map<String, Object> getJmxAttributes(CompositeData jmxCapReq) {
TabularData jmxAttributes = (TabularData) jmxCapReq.get(BundleWiringStateMBean.ATTRIBUTES);
Map<String, Object> aMap = new HashMap<String, Object>();
for (CompositeData jmxAttr : (Collection<CompositeData>) jmxAttributes.values()) {
PropertyData<Object> pd = PropertyData.from(jmxAttr);
Object val = pd.getValue();
if (val instanceof Object[]) {
val = Arrays.asList((Object[]) val);
}
aMap.put(pd.getKey(), val);
}
return aMap;
}
use of javax.management.openmbean.TabularData in project aries by apache.
the class BundleWiringStateMBeanTest method getJmxDirectives.
@SuppressWarnings("unchecked")
private Map<String, String> getJmxDirectives(CompositeData jmxCapReq) {
TabularData jmxDirectives = (TabularData) jmxCapReq.get(BundleWiringStateMBean.DIRECTIVES);
Map<String, String> dMap = new HashMap<String, String>();
for (CompositeData jmxDir : (Collection<CompositeData>) jmxDirectives.values()) {
dMap.put((String) jmxDir.get(BundleWiringStateMBean.KEY), (String) jmxDir.get(BundleWiringStateMBean.VALUE));
}
return dMap;
}
use of javax.management.openmbean.TabularData in project aries by apache.
the class BundleWiringStateMBeanTest method testRevisionsWiring.
@Test
public void testRevisionsWiring() throws Exception {
TabularData jmxWiringTable = brsMBean.getRevisionsWiring(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
Assert.assertEquals(1, jmxWiringTable.size());
CompositeData jmxWiring = (CompositeData) jmxWiringTable.values().iterator().next();
Assert.assertEquals(BundleWiringStateMBean.BUNDLE_WIRING_TYPE, jmxWiring.getCompositeType());
Assert.assertEquals(bundleA.getBundleId(), jmxWiring.get(BundleWiringStateMBean.BUNDLE_ID));
BundleWiring bw = (BundleWiring) bundleA.adapt(BundleWiring.class);
assertBundleWiring(bw, jmxWiring);
}
use of javax.management.openmbean.TabularData in project aries by apache.
the class BundleWiringStateMBeanTest method testRevisionsWiringClosure.
@Test
public void testRevisionsWiringClosure() throws Exception {
TabularData jmxWiringClosure = brsMBean.getRevisionsWiringClosure(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
CompositeData jmxWiringA = jmxWiringClosure.get(new Object[] { bundleA.getBundleId(), 0 });
assertBundleWiring((BundleWiring) bundleA.adapt(BundleWiring.class), jmxWiringA);
Bundle b = context().getBundleByName("org.apache.aries.jmx.test.bundleb");
int bRevID = findRevisionID(jmxWiringA, b);
CompositeData jmxWiringB = jmxWiringClosure.get(new Object[] { b.getBundleId(), bRevID });
assertBundleWiring((BundleWiring) b.adapt(BundleWiring.class), jmxWiringB);
Bundle cm = context().getBundleByName("org.apache.felix.configadmin");
int cmRevID = findRevisionID(jmxWiringA, cm);
CompositeData jmxWiringCM = jmxWiringClosure.get(new Object[] { cm.getBundleId(), cmRevID });
assertBundleWiring((BundleWiring) cm.adapt(BundleWiring.class), jmxWiringCM);
Bundle sb = context().getBundle(0);
int sbRevID = findRevisionID(jmxWiringA, sb);
CompositeData jmxWiringSB = jmxWiringClosure.get(new Object[] { sb.getBundleId(), sbRevID });
assertBundleWiring((BundleWiring) sb.adapt(BundleWiring.class), jmxWiringSB);
}
use of javax.management.openmbean.TabularData in project aries by apache.
the class ServiceData method toCompositeData.
public CompositeData toCompositeData(Collection<String> itemNames) {
Map<String, Object> items = new HashMap<String, Object>();
items.put(IDENTIFIER, this.serviceId);
if (itemNames.contains(BUNDLE_IDENTIFIER))
items.put(BUNDLE_IDENTIFIER, this.bundleId);
if (itemNames.contains(OBJECT_CLASS))
items.put(OBJECT_CLASS, this.serviceInterfaces);
TabularData propertiesTable = new TabularDataSupport(JmxConstants.PROPERTIES_TYPE);
for (PropertyData<? extends Object> propertyData : this.properties) {
propertiesTable.put(propertyData.toCompositeData());
}
items.put(PROPERTIES, propertiesTable);
if (itemNames.contains(USING_BUNDLES))
items.put(USING_BUNDLES, toLong(this.usingBundles));
String[] allItemNames = SERVICE_TYPE.keySet().toArray(new String[] {});
Object[] itemValues = new Object[allItemNames.length];
for (int i = 0; i < allItemNames.length; i++) {
itemValues[i] = items.get(allItemNames[i]);
}
try {
return new CompositeDataSupport(SERVICE_TYPE, allItemNames, itemValues);
} catch (OpenDataException e) {
throw new IllegalStateException("Failed to create CompositeData for ServiceReference with " + Constants.SERVICE_ID + " [" + this.serviceId + "]", e);
}
}
Aggregations