Search in sources :

Example 36 with MBeanParameterInfo

use of javax.management.MBeanParameterInfo in project tdi-studio-se by Talend.

the class OperationsLabelProvider method getMethodSignature.

/**
     * Gets the method signature.
     * 
     * @param info The operation info
     * @return The method signature
     */
private static String getMethodSignature(MBeanOperationInfo info) {
    StringBuffer buffer = new StringBuffer();
    buffer.append(info.getName());
    //$NON-NLS-1$
    buffer.append("(");
    StringBuffer paramBuffer = new StringBuffer();
    for (MBeanParameterInfo parameterInfo : info.getSignature()) {
        if (paramBuffer.length() != 0) {
            //$NON-NLS-1$
            paramBuffer.append(", ");
        }
        String param = parameterInfo.getType();
        if (param.startsWith("[")) {
            //$NON-NLS-1$
            param = Signature.toString(param);
        }
        int index = param.lastIndexOf('.');
        if (index > 0) {
            param = param.substring(index + 1);
        }
        paramBuffer.append(param);
    }
    buffer.append(paramBuffer);
    //$NON-NLS-1$
    buffer.append(")");
    return buffer.toString();
}
Also used : MBeanParameterInfo(javax.management.MBeanParameterInfo)

Example 37 with MBeanParameterInfo

use of javax.management.MBeanParameterInfo in project kernel by exoplatform.

the class TestExoMBeanAttribute method test3.

public void test3(Bean bean, String getterName, String setterName) throws Exception {
    MBeanOperationInfo[] operationInfos = bean.info.getOperations();
    assertNotNull(operationInfos);
    assertEquals(2, operationInfos.length);
    MBeanOperationInfo setStringInfo = bean.info.getOperation(setterName);
    assertNotNull(setStringInfo);
    assertEquals(setterName, setStringInfo.getName());
    assertEquals("void", setStringInfo.getReturnType());
    MBeanParameterInfo[] setStringParameterInfos = setStringInfo.getSignature();
    assertEquals(1, setStringParameterInfos.length);
    MBeanParameterInfo attributeParameterInfo = setStringParameterInfos[0];
    assertEquals("java.lang.String", attributeParameterInfo.getType());
    MBeanOperationInfo getStringInfo = bean.info.getOperation(getterName);
    assertNotNull(getStringInfo);
    assertEquals(getterName, getStringInfo.getName());
    assertEquals("java.lang.String", getStringInfo.getReturnType());
    assertEquals(0, getStringInfo.getSignature().length);
    MBeanAttributeInfo[] attributeInfos = bean.info.getAttributes();
    assertNotNull(attributeInfos);
    assertEquals(1, attributeInfos.length);
    MBeanAttributeInfo attributeInfo = attributeInfos[0];
    assertEquals("String", attributeInfo.getName());
    assertEquals("java.lang.String", attributeInfo.getType());
    assertEquals(true, attributeInfo.isReadable());
    assertEquals(true, attributeInfo.isWritable());
    MBean3_0.string = null;
    assertEquals(null, server.invoke(bean.name, setterName, new Object[] { "Foo" }, new String[] { "java.lang.String" }));
    assertEquals("Foo", MBean3_0.string);
    server.setAttribute(bean.name, new Attribute("String", "Bar"));
    assertEquals("Bar", MBean3_0.string);
    MBean3_0.string = "Juu";
    assertEquals("Juu", server.invoke(bean.name, getterName, new Object[0], new String[0]));
    MBean3_0.string = "Daa";
    assertEquals("Daa", server.getAttribute(bean.name, "String"));
}
Also used : Attribute(javax.management.Attribute) MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Example 38 with MBeanParameterInfo

use of javax.management.MBeanParameterInfo in project kernel by exoplatform.

the class TestExoMBeanAttribute method test2.

public void test2(Bean bean, String setterName) throws Exception {
    MBeanOperationInfo[] operationInfos = bean.info.getOperations();
    assertNotNull(operationInfos);
    assertEquals(1, operationInfos.length);
    MBeanOperationInfo operationInfo = operationInfos[0];
    assertNotNull(operationInfo);
    assertEquals(setterName, operationInfo.getName());
    assertEquals("void", operationInfo.getReturnType());
    MBeanParameterInfo[] attributeParameterInfos = operationInfo.getSignature();
    assertEquals(1, attributeParameterInfos.length);
    MBeanParameterInfo attributeParameterInfo = attributeParameterInfos[0];
    assertEquals("java.lang.String", attributeParameterInfo.getType());
    MBeanAttributeInfo[] attributeInfos = bean.info.getAttributes();
    assertNotNull(attributeInfos);
    assertEquals(1, attributeInfos.length);
    MBeanAttributeInfo attributeInfo = attributeInfos[0];
    assertEquals("String", attributeInfo.getName());
    assertEquals("java.lang.String", attributeInfo.getType());
    assertEquals(false, attributeInfo.isReadable());
    assertEquals(true, attributeInfo.isWritable());
    MBean2_0.string = null;
    assertEquals(null, server.invoke(bean.name, setterName, new Object[] { "Foo" }, new String[] { "java.lang.String" }));
    assertEquals("Foo", MBean2_0.string);
    server.setAttribute(bean.name, new Attribute("String", "Bar"));
    assertEquals("Bar", MBean2_0.string);
}
Also used : Attribute(javax.management.Attribute) MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Example 39 with MBeanParameterInfo

use of javax.management.MBeanParameterInfo in project kernel by exoplatform.

the class TestExoMBeanOperation method test2.

public void test2() throws Exception {
    Bean bean = register("domain:name=mbean", MBean2.class);
    MBeanOperationInfo[] operationInfos = bean.info.getOperations();
    assertNotNull(operationInfos);
    assertEquals(1, operationInfos.length);
    MBeanOperationInfo operationInfo = operationInfos[0];
    assertNotNull(operationInfo);
    assertEquals("op", operationInfo.getName());
    assertEquals("op_desc", operationInfo.getDescription());
    assertEquals("java.lang.String", operationInfo.getReturnType());
    MBeanParameterInfo[] parameterInfos = operationInfo.getSignature();
    assertNotNull(parameterInfos);
    assertEquals(1, parameterInfos.length);
    MBeanParameterInfo parameterInfo = parameterInfos[0];
    assertNotNull(parameterInfo);
    assertEquals("arg_desc", parameterInfo.getDescription());
    assertEquals("java.lang.Integer", parameterInfo.getType());
    MBeanAttributeInfo[] mbeanAttributeInfos = bean.info.getAttributes();
    assertNotNull(mbeanAttributeInfos);
    assertEquals(0, mbeanAttributeInfos.length);
    assertEquals("5", server.invoke(bean.name, "op", new Object[] { 5 }, new String[] { "java.lang.Integer" }));
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Example 40 with MBeanParameterInfo

use of javax.management.MBeanParameterInfo in project kernel by exoplatform.

the class TestExoMBeanOperation method test4.

public void test4() throws Exception {
    Bean bean = register("domain:name=mbean", MBean4.class);
    MBeanOperationInfo[] operationInfos = bean.info.getOperations();
    assertNotNull(operationInfos);
    assertEquals(2, operationInfos.length);
    MBeanOperationInfo operation1Info = bean.info.getOperation("op1");
    assertNotNull(operation1Info);
    assertEquals("op1", operation1Info.getName());
    assertEquals("java.lang.String", operation1Info.getReturnType());
    MBeanParameterInfo[] operation1ParameterInfos = operation1Info.getSignature();
    assertNotNull(operation1ParameterInfos);
    assertEquals(1, operation1ParameterInfos.length);
    MBeanParameterInfo operation1ParameterInfo = operation1ParameterInfos[0];
    assertNotNull(operation1ParameterInfo);
    assertEquals("java.lang.Boolean", operation1ParameterInfo.getType());
    MBeanOperationInfo operation2Info = bean.info.getOperation("op2");
    assertNotNull(operation2Info);
    assertEquals("op2", operation2Info.getName());
    assertEquals("java.lang.String", operation2Info.getReturnType());
    MBeanParameterInfo[] operation2ParameterInfos = operation2Info.getSignature();
    assertNotNull(operation2ParameterInfos);
    assertEquals(1, operation2ParameterInfos.length);
    MBeanParameterInfo operation2ParameterInfo = operation2ParameterInfos[0];
    assertNotNull(operation2ParameterInfo);
    assertEquals("java.lang.Integer", operation2ParameterInfo.getType());
    MBeanAttributeInfo[] mbeanAttributeInfos = bean.info.getAttributes();
    assertNotNull(mbeanAttributeInfos);
    assertEquals(0, mbeanAttributeInfos.length);
    assertEquals("true", server.invoke(bean.name, "op1", new Object[] { true }, new String[] { "java.lang.Boolean" }));
    assertEquals("7", server.invoke(bean.name, "op2", new Object[] { 7 }, new String[] { "java.lang.Integer" }));
}
Also used : MBeanOperationInfo(javax.management.MBeanOperationInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Aggregations

MBeanParameterInfo (javax.management.MBeanParameterInfo)42 MBeanOperationInfo (javax.management.MBeanOperationInfo)25 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)14 MBeanInfo (javax.management.MBeanInfo)12 Descriptor (javax.management.Descriptor)7 ArrayList (java.util.ArrayList)6 ObjectName (javax.management.ObjectName)6 Test (org.junit.Test)5 MBeanConstructorInfo (javax.management.MBeanConstructorInfo)4 ModelMBeanOperationInfo (javax.management.modelmbean.ModelMBeanOperationInfo)4 Annotation (java.lang.annotation.Annotation)3 Method (java.lang.reflect.Method)3 TreeMap (java.util.TreeMap)3 Attribute (javax.management.Attribute)3 MBeanNotificationInfo (javax.management.MBeanNotificationInfo)3 DescriptorSupport (javax.management.modelmbean.DescriptorSupport)3 ImmutableDescriptor (javax.management.ImmutableDescriptor)2 OpenMBeanOperationInfoSupport (javax.management.openmbean.OpenMBeanOperationInfoSupport)2 OpenMBeanParameterInfo (javax.management.openmbean.OpenMBeanParameterInfo)2 OpenType (javax.management.openmbean.OpenType)2