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);
}
}
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);
}
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;
}
}
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);
}
}
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());
}
}
Aggregations