Java Code Examples for javax.management.openmbean.SimpleType#BOOLEAN

The following examples show how to use javax.management.openmbean.SimpleType#BOOLEAN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AttributeNodeForSimpleType.java    From datakernel with Apache License 2.0 6 votes vote down vote up
private static SimpleType<?> simpleTypeOf(Class<?> clazz) throws IllegalArgumentException {
	if (clazz == boolean.class || clazz == Boolean.class) {
		return SimpleType.BOOLEAN;
	} else if (clazz == byte.class || clazz == Byte.class) {
		return SimpleType.BYTE;
	} else if (clazz == short.class || clazz == Short.class) {
		return SimpleType.SHORT;
	} else if (clazz == char.class || clazz == Character.class) {
		return SimpleType.CHARACTER;
	} else if (clazz == int.class || clazz == Integer.class) {
		return SimpleType.INTEGER;
	} else if (clazz == long.class || clazz == Long.class) {
		return SimpleType.LONG;
	} else if (clazz == float.class || clazz == Float.class) {
		return SimpleType.FLOAT;
	} else if (clazz == double.class || clazz == Double.class) {
		return SimpleType.DOUBLE;
	} else if (clazz == String.class) {
		return SimpleType.STRING;
	} else {
		throw new IllegalArgumentException("There is no SimpleType for " + clazz.getName());
	}
}
 
Example 2
Source File: JMXUtils.java    From alfresco-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static OpenType<?> getOpenType(Object o)
{
    if(o instanceof Long)
    {
        return SimpleType.LONG;
    }
    else if(o instanceof String)
    {
        return SimpleType.STRING;
    }
    else if(o instanceof Date)
    {
        return SimpleType.DATE;
    }
    else if(o instanceof Integer)
    {
        return SimpleType.INTEGER;
    }
    else if(o instanceof Boolean)
    {
        return SimpleType.BOOLEAN;
    }
    else if(o instanceof Double)
    {
        return SimpleType.DOUBLE;
    }
    else if(o instanceof Float)
    {
        return SimpleType.FLOAT;
    }
    else
    {
        throw new IllegalArgumentException();
    }
}
 
Example 3
Source File: CompatibilityTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws Exception {
    compositeTypeV6 = new CompositeType(
        StackTraceElement.class.getName(),
        "StackTraceElement",
        new String[]{
            "className", "methodName", "fileName", "nativeMethod", "lineNumber"
        },
        new String[]{
            "className", "methodName", "fileName", "nativeMethod", "lineNumber"
        },
        new OpenType[]{
            SimpleType.STRING,
            SimpleType.STRING,
            SimpleType.STRING,
            SimpleType.BOOLEAN,
            SimpleType.INTEGER
        }
    );

    itemsV6 = new HashMap<>();
    itemsV6.put("className", "MyClass");
    itemsV6.put("methodName", "myMethod");
    itemsV6.put("fileName", "MyClass.java");
    itemsV6.put("nativeMethod", false);
    itemsV6.put("lineNumber", 123);

    compositeDataV6 = new CompositeDataSupport(compositeTypeV6, itemsV6);
}
 
Example 4
Source File: JmxFeedTest.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Test
public void testJmxAttributeOfTypeTabularDataProviderConvertedToMap() throws Exception {
    // Create the CompositeType and TabularData
    CompositeType compositeType = new CompositeType(
            "typeName",
            "description",
            new String[] {"myint", "mystring", "mybool"},    // item names
            new String[] {"myint", "mystring", "mybool"},    // item descriptions, can't be null or empty string
            new OpenType<?>[] {SimpleType.INTEGER, SimpleType.STRING, SimpleType.BOOLEAN}
    );
    TabularType tt = new TabularType(
            "typeName",
            "description",
            compositeType,
            new String[] {"myint"}
    );
    TabularDataSupport tds = new TabularDataSupport(tt);
    tds.put(new CompositeDataSupport(
            compositeType,
            new String[] {"mybool", "myint", "mystring"},
            new Object[] {true, 1234, "on"}
    ));

    // Create MBean
    GeneralisedDynamicMBean mbean = jmxService.registerMBean(ImmutableMap.of(attributeName, tds), objectName);

    feed = JmxFeed.builder()
            .entity(entity)
            .pollAttribute(new JmxAttributePollConfig<Map>(mapAttribute)
                    .objectName(objectName)
                    .attributeName(attributeName)
                    .onSuccess((Function)JmxValueFunctions.tabularDataToMap()))
            .build();

    // Starts with value defined when registering...
    assertSensorEventually(
            mapAttribute, 
            ImmutableMap.of("myint", 1234, "mystring", "on", "mybool", Boolean.TRUE), 
            TIMEOUT_MS);
}
 
Example 5
Source File: TypeConverters.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
OpenType<?> getOpenType() {
    return SimpleType.BOOLEAN;
}