Search in sources :

Example 71 with CompositeType

use of javax.management.openmbean.CompositeType in project deltaspike by apache.

the class DynamicMBeanWrapper method toTabularData.

private TabularData toTabularData(final String typeName, final String description, final Table table) {
    final OpenType<?>[] types = new OpenType<?>[table.getColumnNames().size()];
    for (int i = 0; i < types.length; i++) {
        types[i] = SimpleType.STRING;
    }
    try {
        final String[] keys = table.getColumnNames().toArray(new String[table.getColumnNames().size()]);
        final CompositeType ct = new CompositeType(typeName, description, keys, keys, types);
        final TabularType type = new TabularType(typeName, description, ct, keys);
        final TabularDataSupport data = new TabularDataSupport(type);
        for (final Collection<String> line : table.getLines()) {
            data.put(new CompositeDataSupport(ct, keys, line.toArray(new Object[line.size()])));
        }
        return data;
    } catch (final OpenDataException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 72 with CompositeType

use of javax.management.openmbean.CompositeType in project geode by apache.

the class OpenTypeConverter method makeTabularConverter.

private static OpenTypeConverter makeTabularConverter(Type objType, boolean sortedMap, Type keyType, Type valueType) throws OpenDataException {
    final String objTypeName = objType.toString();
    final OpenTypeConverter keyConverter = toConverter(keyType);
    final OpenTypeConverter valueConverter = toConverter(valueType);
    final OpenType keyOpenType = keyConverter.getOpenType();
    final OpenType valueOpenType = valueConverter.getOpenType();
    final CompositeType rowType = new CompositeType(objTypeName, objTypeName, keyValueArray, keyValueArray, new OpenType[] { keyOpenType, valueOpenType });
    final TabularType tabularType = new TabularType(objTypeName, objTypeName, rowType, keyArray);
    return new TableConverter(objType, sortedMap, tabularType, keyConverter, valueConverter);
}
Also used : OpenType(javax.management.openmbean.OpenType) TabularType(javax.management.openmbean.TabularType) CompositeType(javax.management.openmbean.CompositeType)

Example 73 with CompositeType

use of javax.management.openmbean.CompositeType in project jackrabbit by apache.

the class QueryStatManager method asTabularData.

private TabularData asTabularData(QueryStatDto[] data) {
    TabularDataSupport tds = null;
    try {
        CompositeType ct = QueryStatCompositeTypeFactory.getCompositeType();
        TabularType tt = new TabularType(QueryStatDto.class.getName(), "Query History", ct, QueryStatCompositeTypeFactory.index);
        tds = new TabularDataSupport(tt);
        for (QueryStatDto q : data) {
            tds.put(new CompositeDataSupport(ct, QueryStatCompositeTypeFactory.names, QueryStatCompositeTypeFactory.getValues(q)));
        }
        return tds;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : QueryStatDto(org.apache.jackrabbit.api.stats.QueryStatDto) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) OpenDataException(javax.management.openmbean.OpenDataException) CompositeType(javax.management.openmbean.CompositeType)

Example 74 with CompositeType

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

the class InstanceToTableMapper method tableFrom.

public static TabularData tableFrom(List<Instance> instances) {
    try {
        CompositeType rowType = createRowType();
        TabularType tableType = new TabularType("Instances", "Table of all Karaf instances", rowType, new String[] { InstancesMBean.INSTANCE_NAME });
        TabularDataSupport table = new TabularDataSupport(tableType);
        for (Instance instance : instances) {
            CompositeDataSupport row = mapInstance(instance, rowType);
            table.put(row);
        }
        return table;
    } catch (OpenDataException e) {
        throw new IllegalStateException("Error building instance table", e);
    }
}
Also used : Instance(org.apache.karaf.instance.core.Instance) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 75 with CompositeType

use of javax.management.openmbean.CompositeType 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)

Aggregations

CompositeType (javax.management.openmbean.CompositeType)82 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)55 CompositeData (javax.management.openmbean.CompositeData)50 TabularDataSupport (javax.management.openmbean.TabularDataSupport)50 TabularData (javax.management.openmbean.TabularData)47 TabularType (javax.management.openmbean.TabularType)27 OpenType (javax.management.openmbean.OpenType)23 OpenDataException (javax.management.openmbean.OpenDataException)22 Map (java.util.Map)20 ObjectName (javax.management.ObjectName)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 MBeanServer (javax.management.MBeanServer)6 ArrayType (javax.management.openmbean.ArrayType)6 ConcurrentMap (java.util.concurrent.ConcurrentMap)5 MBeanException (javax.management.MBeanException)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)3 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3