Search in sources :

Example 96 with TabularDataSupport

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

the class JmxFeature method getConfigFileList.

static TabularData getConfigFileList(List<ConfigFileInfo> configFiles) throws OpenDataException {
    TabularDataSupport table = new TabularDataSupport(FEATURE_CONFIG_FILES_TABLE);
    for (ConfigFileInfo configFile : configFiles) {
        String[] itemNames = FeaturesServiceMBean.FEATURE_CONFIG_FILES;
        Object[] itemValues = { configFile.getFinalname() };
        CompositeData config = new CompositeDataSupport(FEATURE_CONFIG_FILES, itemNames, itemValues);
        table.put(config);
    }
    return table;
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) ConfigFileInfo(org.apache.karaf.features.ConfigFileInfo)

Example 97 with TabularDataSupport

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

the class JmxProperty method tableFrom.

public static TabularData tableFrom(Dictionary properties) {
    TabularDataSupport table = new TabularDataSupport(PROPERTY_TABLE);
    Enumeration p = properties.keys();
    while (p.hasMoreElements()) {
        Object key = p.nextElement();
        Object value = properties.get(key);
        table.put(new JmxProperty(String.valueOf(key), String.valueOf(value)).asCompositeData());
    }
    return table;
}
Also used : Enumeration(java.util.Enumeration) TabularDataSupport(javax.management.openmbean.TabularDataSupport)

Example 98 with TabularDataSupport

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

the class BundlesMBeanImpl method getDiag.

@Override
public TabularData getDiag() throws MBeanException {
    try {
        CompositeType diagType = new CompositeType("Diag", "OSGi Bundle Diag", new String[] { "Name", "Status", "Diag" }, new String[] { "Bundle Name", "Current Status", "Diagnostic" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING });
        TabularType tableType = new TabularType("Diagnostics", "Tables of all bundles diagnostic", diagType, new String[] { "Name" });
        TabularData table = new TabularDataSupport(tableType);
        Bundle[] bundles = bundleContext.getBundles();
        for (Bundle bundle : bundles) {
            BundleInfo bundleInfo = bundleService.getInfo(bundle);
            String name = ShellUtil.getBundleName(bundle);
            String status = bundleInfo.getState().toString();
            String diag = bundleService.getDiag(bundle);
            CompositeData data = new CompositeDataSupport(diagType, new String[] { "Name", "Status", "Diag" }, new Object[] { name, status, diag });
            table.put(data);
        }
        return table;
    } catch (Exception e) {
        throw new MBeanException(null, e.toString());
    }
}
Also used : BundleInfo(org.apache.karaf.bundle.core.BundleInfo) TabularDataSupport(javax.management.openmbean.TabularDataSupport) Bundle(org.osgi.framework.Bundle) TabularType(javax.management.openmbean.TabularType) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) CompositeType(javax.management.openmbean.CompositeType) TabularData(javax.management.openmbean.TabularData)

Example 99 with TabularDataSupport

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

the class BundlesMBeanImpl method getBundles.

public TabularData getBundles() throws MBeanException {
    try {
        CompositeType bundleType = new CompositeType("Bundle", "OSGi Bundle", new String[] { "ID", "Name", "Symbolic Name", "Version", "Start Level", "State", "Update Location" }, new String[] { "ID of the Bundle", "Name of the Bundle", "Symbolic Name of the Bundle", "Version of the Bundle", "Start Level of the Bundle", "Current State of the Bundle", "Update location of the Bundle" }, new OpenType[] { SimpleType.LONG, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.STRING, SimpleType.STRING });
        TabularType tableType = new TabularType("Bundles", "Tables of all bundles", bundleType, new String[] { "ID" });
        TabularData table = new TabularDataSupport(tableType);
        Bundle[] bundles = bundleContext.getBundles();
        for (Bundle bundle : bundles) {
            try {
                BundleInfo info = bundleService.getInfo(bundle);
                String bundleStateString = info.getState().toString();
                CompositeData data = new CompositeDataSupport(bundleType, new String[] { "ID", "Name", "Symbolic Name", "Version", "Start Level", "State", "Update Location" }, new Object[] { info.getBundleId(), info.getName(), info.getSymbolicName(), info.getVersion(), info.getStartLevel(), bundleStateString, info.getUpdateLocation() });
                table.put(data);
            } catch (Exception e) {
                LOG.error(e.getMessage(), e);
            }
        }
        return table;
    } catch (Exception e) {
        throw new MBeanException(null, e.toString());
    }
}
Also used : BundleInfo(org.apache.karaf.bundle.core.BundleInfo) TabularDataSupport(javax.management.openmbean.TabularDataSupport) Bundle(org.osgi.framework.Bundle) TabularType(javax.management.openmbean.TabularType) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) CompositeType(javax.management.openmbean.CompositeType) TabularData(javax.management.openmbean.TabularData)

Example 100 with TabularDataSupport

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

the class PackagesMBeanImpl method getExports.

public TabularData getExports() {
    try {
        String[] names = new String[] { "Name", "Version", "ID", "Bundle Name" };
        CompositeType bundleType = new CompositeType("PackageExport", "Exported packages", names, new String[] { "Package name", "Version of the Package", "ID of the Bundle", "Bundle symbolic name" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.LONG, SimpleType.STRING });
        TabularType tableType = new TabularType("PackageExports", "Exported packages", bundleType, new String[] { "Name", "Version", "ID" });
        TabularData table = new TabularDataSupport(tableType);
        List<PackageVersion> exports = packageService.getExports();
        for (PackageVersion export : exports) {
            for (Bundle bundle : export.getBundles()) {
                Object[] data = new Object[] { export.getPackageName(), export.getVersion().toString(), bundle.getBundleId(), bundle.getSymbolicName() };
                CompositeData comp = new CompositeDataSupport(bundleType, names, data);
                LOGGER.debug("Adding CompositeDataSupport {}", comp);
                table.put(comp);
            }
        }
        return table;
    } catch (RuntimeException e) {
        // To avoid the exception gets swallowed by jmx
        LOGGER.error(e.getMessage(), e);
        throw e;
    } catch (OpenDataException e) {
        LOGGER.error(e.getMessage(), e);
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) TabularType(javax.management.openmbean.TabularType) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) PackageVersion(org.apache.karaf.packages.core.PackageVersion) TabularData(javax.management.openmbean.TabularData) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeType(javax.management.openmbean.CompositeType)

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