use of javax.management.openmbean.CompositeDataSupport in project jdk8u_jdk by JetBrains.
the class TabularDataOrderTest method makeTable.
private static TabularData makeTable() throws OpenDataException {
TabularData td = new TabularDataSupport(tt);
for (Map.Entry<String, Integer> entry : stringToValue.entrySet()) {
CompositeData cd = new CompositeDataSupport(ct, new String[] { "name", "int" }, new Object[] { entry.getKey(), entry.getValue() });
td.put(cd);
}
return td;
}
use of javax.management.openmbean.CompositeDataSupport 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);
}
}
use of javax.management.openmbean.CompositeDataSupport in project aries by apache.
the class BundleEventData method toCompositeData.
/**
* Returns CompositeData representing a BundleEvent typed by {@link BundleStateMBean#BUNDLE_EVENT_TYPE}
*
* @return
*/
public CompositeData toCompositeData() {
CompositeData result = null;
Map<String, Object> items = new HashMap<String, Object>();
items.put(IDENTIFIER, this.bundleId);
items.put(SYMBOLIC_NAME, this.bundleSymbolicName);
items.put(LOCATION, this.location);
items.put(EVENT, this.eventType);
try {
result = new CompositeDataSupport(BUNDLE_EVENT_TYPE, items);
} catch (OpenDataException e) {
throw new IllegalStateException("Failed to create CompositeData for BundleEvent for Bundle [" + this.bundleId + "]", e);
}
return result;
}
use of javax.management.openmbean.CompositeDataSupport in project aries by apache.
the class ServiceEventDataTest method testFrom.
@Test
public void testFrom() throws Exception {
Map<String, Object> items = new HashMap<String, Object>();
items.put(IDENTIFIER, new Long(7));
items.put(BUNDLE_IDENTIFIER, new Long(67));
items.put(BUNDLE_LOCATION, "string");
items.put(BUNDLE_SYMBOLIC_NAME, "test");
items.put(OBJECT_CLASS, new String[] { "org.apache.aries.jmx.Mock" });
items.put(EVENT, ServiceEvent.MODIFIED);
CompositeData compositeData = new CompositeDataSupport(SERVICE_EVENT_TYPE, items);
ServiceEventData event = ServiceEventData.from(compositeData);
assertEquals(7, event.getServiceId());
assertEquals(67, event.getBundleId());
assertArrayEquals(new String[] { "org.apache.aries.jmx.Mock" }, event.getServiceInterfaces());
assertEquals("test", event.getBundleSymbolicName());
assertEquals("string", event.getBundleLocation());
assertEquals(ServiceEvent.MODIFIED, event.getEventType());
}
use of javax.management.openmbean.CompositeDataSupport in project aries by apache.
the class BundleEventDataTest method testFrom.
@Test
public void testFrom() throws Exception {
Map<String, Object> items = new HashMap<String, Object>();
items.put(IDENTIFIER, new Long(7));
items.put(SYMBOLIC_NAME, "t");
items.put(LOCATION, "l");
items.put(EVENT, BundleEvent.RESOLVED);
CompositeData compositeData = new CompositeDataSupport(BUNDLE_EVENT_TYPE, items);
BundleEventData event = BundleEventData.from(compositeData);
assertEquals(7, event.getBundleId());
assertEquals("t", event.getBundleSymbolicName());
assertEquals("l", event.getLocation());
assertEquals(BundleEvent.RESOLVED, event.getEventType());
}
Aggregations