Search in sources :

Example 16 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport 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 17 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project tesb-studio-se by Talend.

the class JMXUtil method installBundle.

/**
     * for Job installation
     * 
     * @param bundle
     * @return
     * @throws ReflectionException
     */
public static long[] installBundle(File bundle) throws Exception {
    try {
        // MBeanServerConnection mbsc = createJMXconnection();
        String KARAF_BUNDLE_MBEAN = "org.apache.karaf:type=bundle,name=trun";
        ObjectName objectBundle = new ObjectName(KARAF_BUNDLE_MBEAN);
        Set<Object> existsBundles = ((TabularDataSupport) mbsc.getAttribute(objectBundle, "Bundles")).keySet();
        Object bundleId = mbsc.invoke(objectBundle, "install", new Object[] { "file:" + bundle.getAbsolutePath() }, new String[] { String.class.getName() });
        Set<Object> newBundles = ((TabularDataSupport) mbsc.getAttribute(objectBundle, "Bundles")).keySet();
        newBundles.removeAll(existsBundles);
        Object[] bundleIds = newBundles.toArray();
        long[] newIds = new long[bundleIds.length];
        for (int i = 0; i < bundleIds.length; i++) {
            String id = bundleIds[i].toString();
            newIds[i] = Long.parseLong(id.substring(1, id.length() - 1));
            mbsc.invoke(objectBundle, "start", new Object[] { String.valueOf(newIds[i]) }, new String[] { String.class.getName() });
        }
        // bundleId instanceof Long ? (long) bundleId : 0;
        return newIds;
    } finally {
    // closeJMXConnection();
    }
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) ObjectName(javax.management.ObjectName)

Example 18 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport 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 19 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project aries by apache.

the class BundleState method listBundles.

private TabularData listBundles(Collection<String> items) throws IOException {
    Bundle[] containerBundles = bundleContext.getBundles();
    List<BundleData> bundleDatas = new ArrayList<BundleData>();
    if (containerBundles != null) {
        for (Bundle containerBundle : containerBundles) {
            bundleDatas.add(new BundleData(bundleContext, containerBundle, packageAdmin, startLevel));
        }
    }
    TabularData bundleTable = new TabularDataSupport(BUNDLES_TYPE);
    for (BundleData bundleData : bundleDatas) {
        bundleTable.put(bundleData.toCompositeData(items));
    }
    return bundleTable;
}
Also used : Bundle(org.osgi.framework.Bundle) FrameworkUtils.resolveBundle(org.apache.aries.jmx.util.FrameworkUtils.resolveBundle) FrameworkUtils.getServicesInUseByBundle(org.apache.aries.jmx.util.FrameworkUtils.getServicesInUseByBundle) TabularDataSupport(javax.management.openmbean.TabularDataSupport) ArrayList(java.util.ArrayList) BundleData(org.apache.aries.jmx.codec.BundleData) TabularData(javax.management.openmbean.TabularData)

Example 20 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project aries by apache.

the class BundleState method getHeaders.

private TabularData getHeaders(Dictionary<String, String> bundleHeaders) {
    List<Header> headers = new ArrayList<Header>();
    Enumeration<String> keys = bundleHeaders.keys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        headers.add(new Header(key, bundleHeaders.get(key)));
    }
    TabularData headerTable = new TabularDataSupport(HEADERS_TYPE);
    for (Header header : headers) {
        headerTable.put(header.toCompositeData());
    }
    return headerTable;
}
Also used : Header(org.apache.aries.jmx.codec.BundleData.Header) TabularDataSupport(javax.management.openmbean.TabularDataSupport) ArrayList(java.util.ArrayList) TabularData(javax.management.openmbean.TabularData)

Aggregations

TabularDataSupport (javax.management.openmbean.TabularDataSupport)103 TabularData (javax.management.openmbean.TabularData)67 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)60 CompositeData (javax.management.openmbean.CompositeData)51 CompositeType (javax.management.openmbean.CompositeType)50 TabularType (javax.management.openmbean.TabularType)36 Map (java.util.Map)27 OpenDataException (javax.management.openmbean.OpenDataException)24 HashMap (java.util.HashMap)11 Bundle (org.osgi.framework.Bundle)10 IOException (java.io.IOException)7 ObjectName (javax.management.ObjectName)7 OpenType (javax.management.openmbean.OpenType)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 Test (org.junit.Test)6 ConcurrentMap (java.util.concurrent.ConcurrentMap)5 MBeanException (javax.management.MBeanException)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)4 Dictionary (java.util.Dictionary)4