use of javax.management.openmbean.CompositeDataSupport in project openj9 by eclipse.
the class TestThreadInfo method createGoodCompositeDataNoLockInfo.
/**
* @return a new <code>CompositeData</code> instance representing a
* <code>ThreadInfo</code>, does not contain 'LockInfo'.
*/
protected static CompositeData createGoodCompositeDataNoLockInfo() {
CompositeData result = null;
CompositeType cType = createGoodThreadInfoCompositeTypeNoLockInfo();
try {
result = new CompositeDataSupport(cType, typeNamesGlobal, valuesGoodCompositeDataNoLockInfo);
} catch (OpenDataException e) {
e.printStackTrace();
}
return result;
}
use of javax.management.openmbean.CompositeDataSupport in project openj9 by eclipse.
the class TestThreadInfo method createBadCompositeData.
/**
* Returns a new <code>CompositeData</code> instance which has been
* intentionally constructed with attributes that <i>should</i> prevent the
* creation of a new <code>ThreadInfo</code>.
*
* @return a new <code>CompositeData</code> instance representing a
* <code>ThreadInfo</code>.
*/
protected static CompositeData createBadCompositeData() {
CompositeData result = null;
CompositeType cType = createBadThreadInfoCompositeType();
try {
result = new CompositeDataSupport(cType, badTypeNames, valuesCompositeDataGlobal);
} catch (OpenDataException e) {
e.printStackTrace();
}
return result;
}
use of javax.management.openmbean.CompositeDataSupport in project activemq-artemis by apache.
the class OpenTypeSupport method convert.
public static CompositeData convert(MessageReference ref) throws OpenDataException {
CompositeType ct;
ICoreMessage message = ref.getMessage().toCore();
Map<String, Object> fields;
byte type = message.getType();
switch(type) {
case Message.TEXT_TYPE:
ct = TEXT_FACTORY.getCompositeType();
fields = TEXT_FACTORY.getFields(ref);
break;
default:
ct = BYTES_FACTORY.getCompositeType();
fields = BYTES_FACTORY.getFields(ref);
break;
}
return new CompositeDataSupport(ct, fields);
}
use of javax.management.openmbean.CompositeDataSupport in project neo4j by neo4j.
the class JmxQueryProcedureTest method shouldHandleCompositeAttributes.
@Test
void shouldHandleCompositeAttributes() throws Throwable {
// given
ObjectName beanName = new ObjectName("org.neo4j:chevyMakesTheTruck=bobMcCoshMakesTheDifference");
when(jmxServer.queryNames(new ObjectName("*:*"), null)).thenReturn(asSet(beanName));
when(jmxServer.getMBeanInfo(beanName)).thenReturn(new MBeanInfo("org.neo4j.SomeMBean", "This is a description", new MBeanAttributeInfo[] { new MBeanAttributeInfo("name", "differenceMaker", "Who makes the difference?", true, false, false) }, null, null, null));
when(jmxServer.getAttribute(beanName, "name")).thenReturn(new CompositeDataSupport(new CompositeType("myComposite", "Composite description", new String[] { "key1", "key2" }, new String[] { "Can't be empty", "Also can't be empty" }, new OpenType<?>[] { SimpleType.STRING, SimpleType.INTEGER }), map("key1", "Hello", "key2", 123)));
JmxQueryProcedure procedure = new JmxQueryProcedure(ProcedureSignature.procedureName("bob"), jmxServer);
// when
RawIterator<AnyValue[], ProcedureException> result = procedure.apply(null, new AnyValue[] { stringValue("*:*") }, EMPTY_RESOURCE_TRACKER);
// then
assertThat(asList(result)).contains(new AnyValue[] { stringValue("org.neo4j:chevyMakesTheTruck=bobMcCoshMakesTheDifference"), stringValue("This is a description"), ValueUtils.of(map(attributeName, map("description", "Who makes the difference?", "value", map("description", "Composite description", "properties", map("key1", "Hello", "key2", 123))))) });
}
use of javax.management.openmbean.CompositeDataSupport in project deltaspike by apache.
the class DeltaSpikeConfigInfo method getConfigSources.
@Override
public TabularData getConfigSources() {
ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(appConfigClassLoader);
String typeName = "ConfigSources";
OpenType<?>[] types = new OpenType<?>[] { SimpleType.INTEGER, SimpleType.STRING };
String[] keys = new String[] { "Ordinal", "ConfigSource" };
CompositeType ct = new CompositeType(typeName, typeName, keys, keys, types);
TabularType type = new TabularType(typeName, typeName, ct, keys);
TabularDataSupport configSourceInfo = new TabularDataSupport(type);
ConfigSource[] configSources = ConfigResolver.getConfigSources();
for (ConfigSource configSource : configSources) {
configSourceInfo.put(new CompositeDataSupport(ct, keys, new Object[] { configSource.getOrdinal(), configSource.getConfigName() }));
}
return configSourceInfo;
} catch (OpenDataException e) {
throw new RuntimeException(e);
} finally {
// set back the original TCCL
Thread.currentThread().setContextClassLoader(originalCl);
}
}
Aggregations