use of javax.management.openmbean.CompositeDataSupport in project karaf by apache.
the class ServicesMBeanImpl method getServices.
public TabularData getServices(long bundleId, boolean inUse) throws MBeanException {
try {
CompositeType serviceType = new CompositeType("Service", "OSGi Service", new String[] { "Interfaces", "Properties" }, new String[] { "Interfaces class name of the service", "Properties of the service" }, new OpenType[] { new ArrayType(1, SimpleType.STRING), new ArrayType(1, SimpleType.STRING) });
TabularType tableType = new TabularType("Services", "Table of OSGi Services", serviceType, new String[] { "Interfaces", "Properties" });
TabularData table = new TabularDataSupport(tableType);
Bundle[] bundles;
if (bundleId >= 0) {
bundles = new Bundle[] { bundleContext.getBundle(bundleId) };
} else {
bundles = bundleContext.getBundles();
}
for (Bundle bundle : bundles) {
try {
ServiceReference[] serviceReferences;
if (inUse) {
serviceReferences = bundle.getServicesInUse();
} else {
serviceReferences = bundle.getRegisteredServices();
}
if (serviceReferences != null) {
for (ServiceReference reference : serviceReferences) {
String[] interfaces = (String[]) reference.getProperty("objectClass");
List<String> properties = new ArrayList<>();
for (String key : reference.getPropertyKeys()) {
properties.add(key + " = " + reference.getProperty(key));
}
CompositeData data = new CompositeDataSupport(serviceType, new String[] { "Interfaces", "Properties" }, new Object[] { interfaces, properties.toArray(new String[0]) });
table.put(data);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
return table;
} catch (Exception e) {
throw new MBeanException(null, e.toString());
}
}
use of javax.management.openmbean.CompositeDataSupport in project karaf by apache.
the class JmxFeature method getConfigElementTable.
static TabularData getConfigElementTable(Properties props) throws OpenDataException {
TabularDataSupport table = new TabularDataSupport(FEATURE_CONFIG_ELEMENT_TABLE);
for (Object key : props.keySet()) {
String[] itemNames = FeaturesServiceMBean.FEATURE_CONFIG_ELEMENT;
Object[] itemValues = { key, props.getProperty((String) key) };
CompositeData element = new CompositeDataSupport(FEATURE_CONFIG_ELEMENT, itemNames, itemValues);
table.put(element);
}
return table;
}
use of javax.management.openmbean.CompositeDataSupport in project karaf by apache.
the class JmxRepository method getFeatureIdentifierTable.
static TabularData getFeatureIdentifierTable(List<Feature> features) throws OpenDataException {
TabularDataSupport table = new TabularDataSupport(JmxFeature.FEATURE_IDENTIFIER_TABLE);
for (Feature feature : features) {
String[] itemNames = new String[] { FeaturesServiceMBean.FEATURE_NAME, FeaturesServiceMBean.FEATURE_VERSION };
Object[] itemValues = new Object[] { feature.getName(), feature.getVersion() };
CompositeData ident = new CompositeDataSupport(JmxFeature.FEATURE_IDENTIFIER, itemNames, itemValues);
table.put(ident);
}
return table;
}
use of javax.management.openmbean.CompositeDataSupport in project sling by apache.
the class HealthCheckMBean method logData.
private TabularData logData(final Result er) throws OpenDataException {
final TabularDataSupport result = new TabularDataSupport(LOG_TABLE_TYPE);
int i = 1;
for (final ResultLog.Entry e : er) {
final Map<String, Object> data = new HashMap<String, Object>();
data.put(INDEX_COLUMN, i++);
data.put(LEVEL_COLUMN, e.getStatus().toString());
data.put(MESSAGE_COLUMN, e.getMessage());
result.put(new CompositeDataSupport(LOG_ROW_TYPE, data));
}
return result;
}
use of javax.management.openmbean.CompositeDataSupport in project jdk8u_jdk by JetBrains.
the class MonitorInfoCompositeData method getCompositeData.
protected CompositeData getCompositeData() {
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
// monitorInfoItemNames!
int len = monitorInfoItemNames.length;
Object[] values = new Object[len];
CompositeData li = LockInfoCompositeData.toCompositeData(lock);
for (int i = 0; i < len; i++) {
String item = monitorInfoItemNames[i];
if (item.equals(LOCKED_STACK_FRAME)) {
StackTraceElement ste = lock.getLockedStackFrame();
values[i] = (ste != null ? StackTraceElementCompositeData.toCompositeData(ste) : null);
} else if (item.equals(LOCKED_STACK_DEPTH)) {
values[i] = new Integer(lock.getLockedStackDepth());
} else {
values[i] = li.get(item);
}
}
try {
return new CompositeDataSupport(monitorInfoCompositeType, monitorInfoItemNames, values);
} catch (OpenDataException e) {
// Should never reach here
throw new AssertionError(e);
}
}
Aggregations