Search in sources :

Example 21 with CompositeDataSupport

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;
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TabularData(javax.management.openmbean.TabularData)

Example 22 with CompositeDataSupport

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);
    }
}
Also used : HashMap(java.util.HashMap) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) TabularData(javax.management.openmbean.TabularData) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport)

Example 23 with CompositeDataSupport

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;
}
Also used : HashMap(java.util.HashMap) OpenDataException(javax.management.openmbean.OpenDataException) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport)

Example 24 with CompositeDataSupport

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());
}
Also used : HashMap(java.util.HashMap) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) Test(org.junit.Test)

Example 25 with CompositeDataSupport

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());
}
Also used : HashMap(java.util.HashMap) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) Test(org.junit.Test)

Aggregations

CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)92 CompositeData (javax.management.openmbean.CompositeData)68 TabularDataSupport (javax.management.openmbean.TabularDataSupport)60 CompositeType (javax.management.openmbean.CompositeType)55 TabularData (javax.management.openmbean.TabularData)43 OpenDataException (javax.management.openmbean.OpenDataException)25 HashMap (java.util.HashMap)21 Map (java.util.Map)19 TabularType (javax.management.openmbean.TabularType)19 OpenType (javax.management.openmbean.OpenType)10 Test (org.junit.Test)8 ObjectName (javax.management.ObjectName)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 MBeanServer (javax.management.MBeanServer)6 IOException (java.io.IOException)5 MBeanException (javax.management.MBeanException)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)3 MBeanInfo (javax.management.MBeanInfo)3 Bundle (org.osgi.framework.Bundle)3