use of javax.management.openmbean.TabularDataSupport in project aries by apache.
the class ProvisioningServiceTest method testAddInformationWithTabularData.
@Test
@SuppressWarnings("unchecked")
public void testAddInformationWithTabularData() throws Exception {
org.osgi.service.provisioning.ProvisioningService provService = mock(org.osgi.service.provisioning.ProvisioningService.class);
ProvisioningService mbean = new ProvisioningService(provService);
TabularData data = new TabularDataSupport(PROPERTIES_TYPE);
PropertyData<byte[]> p1 = PropertyData.newInstance(PROVISIONING_AGENT_CONFIG, new byte[] { 20, 30, 40 });
data.put(p1.toCompositeData());
PropertyData<String> p2 = PropertyData.newInstance(PROVISIONING_SPID, "x.test");
data.put(p2.toCompositeData());
mbean.addInformation(data);
ArgumentCaptor<Dictionary> dictionaryArgument = ArgumentCaptor.forClass(Dictionary.class);
verify(provService).addInformation(dictionaryArgument.capture());
Dictionary<String, Object> info = dictionaryArgument.getValue();
assertEquals(2, info.size());
assertArrayEquals(new byte[] { 20, 30, 40 }, (byte[]) info.get(PROVISIONING_AGENT_CONFIG));
assertEquals("x.test", info.get(PROVISIONING_SPID));
}
use of javax.management.openmbean.TabularDataSupport in project aries by apache.
the class ProvisioningServiceTest method testSetInformation.
@Test
@SuppressWarnings("unchecked")
public void testSetInformation() throws Exception {
org.osgi.service.provisioning.ProvisioningService provService = mock(org.osgi.service.provisioning.ProvisioningService.class);
ProvisioningService mbean = new ProvisioningService(provService);
TabularData data = new TabularDataSupport(PROPERTIES_TYPE);
PropertyData<String> p1 = PropertyData.newInstance(PROVISIONING_REFERENCE, "rsh://0.0.0.0/provX");
data.put(p1.toCompositeData());
PropertyData<String> p2 = PropertyData.newInstance(PROVISIONING_SPID, "x.test");
data.put(p2.toCompositeData());
mbean.setInformation(data);
ArgumentCaptor<Dictionary> dictionaryArgument = ArgumentCaptor.forClass(Dictionary.class);
verify(provService).setInformation(dictionaryArgument.capture());
Dictionary<String, Object> info = dictionaryArgument.getValue();
assertEquals(2, info.size());
assertEquals("rsh://0.0.0.0/provX", info.get(PROVISIONING_REFERENCE));
assertEquals("x.test", info.get(PROVISIONING_SPID));
}
use of javax.management.openmbean.TabularDataSupport 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.TabularDataSupport 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.TabularDataSupport in project jackrabbit-oak by apache.
the class ConsolidatedDataStoreCacheStats method getCacheStats.
@Override
public TabularData getCacheStats() {
TabularDataSupport tds;
try {
TabularType tt = new TabularType(CacheStatsData.class.getName(), "Consolidated DataStore Cache Stats", CacheStatsData.TYPE, new String[] { "name" });
tds = new TabularDataSupport(tt);
for (DataStoreCacheStatsMBean stats : cacheStats) {
tds.put(new CacheStatsData(stats).toCompositeData());
}
} catch (OpenDataException e) {
throw new IllegalStateException(e);
}
return tds;
}
Aggregations