Search in sources :

Example 61 with CompositeDataSupport

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;
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 62 with CompositeDataSupport

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;
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Example 63 with CompositeDataSupport

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);
}
Also used : ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) CompositeType(javax.management.openmbean.CompositeType)

Example 64 with CompositeDataSupport

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))))) });
}
Also used : MBeanInfo(javax.management.MBeanInfo) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) ObjectName(javax.management.ObjectName) CompositeType(javax.management.openmbean.CompositeType) Test(org.junit.jupiter.api.Test)

Example 65 with CompositeDataSupport

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);
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) TabularType(javax.management.openmbean.TabularType) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) ConfigSource(org.apache.deltaspike.core.spi.config.ConfigSource) OpenDataException(javax.management.openmbean.OpenDataException) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeType(javax.management.openmbean.CompositeType)

Aggregations

CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)166 CompositeData (javax.management.openmbean.CompositeData)107 CompositeType (javax.management.openmbean.CompositeType)105 TabularDataSupport (javax.management.openmbean.TabularDataSupport)78 OpenDataException (javax.management.openmbean.OpenDataException)66 TabularData (javax.management.openmbean.TabularData)46 HashMap (java.util.HashMap)36 TabularType (javax.management.openmbean.TabularType)30 Map (java.util.Map)26 OpenType (javax.management.openmbean.OpenType)15 ObjectName (javax.management.ObjectName)12 MBeanServer (javax.management.MBeanServer)8 Test (org.junit.Test)8 IOException (java.io.IOException)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 MBeanException (javax.management.MBeanException)6 JsonArray (javax.json.JsonArray)5 JsonObject (javax.json.JsonObject)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)4