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

The following examples show how to use javax.management.openmbean.SimpleType#BYTE . 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: OpenTypeSupport.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Override
protected void init() throws OpenDataException {
   super.init();
   body = new ArrayType(SimpleType.BYTE, true);
   addItem(CompositeDataConstants.BODY, CompositeDataConstants.BODY_DESCRIPTION, body);
}
 
Example 3
Source File: ModelControllerMBeanTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Test
public void testDeploymentViaJmx() throws Exception {
    ObjectName testDeploymentModelName = new ObjectName("" + RESOLVED_DOMAIN + ":deployment=" + DEPLOYMENT);
    assertNoMBean(testDeploymentModelName);
    File jarFile = new File(DEPLOYMENT);
    Files.deleteIfExists(jarFile.toPath());
    ServiceActivatorDeploymentUtil.createServiceActivatorDeployment(jarFile, "jboss.test:service="+DEPLOYMENT, Dynamic.class);
    try (InputStream in = Files.newInputStream(jarFile.toPath())) {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        int i = in.read();
        while (i != -1) {
            bout.write(i);
            i = in.read();
        }

        byte[] bytes = bout.toByteArray();

        //Upload the content
        byte[] hash = (byte[]) connection.invoke(RESOLVED_ROOT_MODEL_NAME, "uploadDeploymentBytes", new Object[]{bytes}, new String[]{byte.class.getName()});

        String[] names = {"hash"};
        String[] descriptions = { "the content hash" };
        OpenType<?>[] types = { new ArrayType<>(SimpleType.BYTE, true)};
        CompositeType contentType = new CompositeType("contents", "the contents", names, descriptions, types);
        Map<String, Object> values = Collections.singletonMap("hash", hash);
        CompositeData contents = new CompositeDataSupport(contentType, values);

        //Deploy it
        connection.invoke(RESOLVED_ROOT_MODEL_NAME,
                "addDeployment",
                new Object[]{DEPLOYMENT, DEPLOYMENT, new CompositeData[]{contents}, Boolean.TRUE},
                new String[]{String.class.getName(), String.class.getName(), CompositeData.class.getName(), Boolean.class.getName()});

        //Make sure the test deployment mbean and the management model mbean for the deployment are there
        Assert.assertTrue((Boolean) connection.getAttribute(testDeploymentModelName, "enabled"));

        //Undeploy
        connection.invoke(testDeploymentModelName, "undeploy", new Object[0], new String[0]);

        //Check the app was undeployed
        Assert.assertFalse((Boolean) connection.getAttribute(testDeploymentModelName, "enabled"));

        //Remove
        connection.invoke(testDeploymentModelName, "remove", new Object[0], new String[0]);
        assertNoMBean(testDeploymentModelName);
    } finally {
        Files.deleteIfExists(jarFile.toPath());
    }
}