Search in sources :

Example 1 with OpenMBeanParameterInfoSupport

use of javax.management.openmbean.OpenMBeanParameterInfoSupport in project jdk8u_jdk by JetBrains.

the class OpenMBeanInfoHashCodeNPETest method main.

public static void main(String[] args) throws Exception {
    System.out.println("---OpenMBeanInfoHashCodeNPETest-main ...");
    // ----
    System.out.println("\n---Testing on OpenMBeanInfohashCodeTest...");
    OpenMBeanAttributeInfo openMBeanAttributeInfo = new OpenMBeanAttributeInfoSupport("name", "description", SimpleType.INTEGER, true, true, false, null, new Integer[] { 1, 2, 3 });
    test(openMBeanAttributeInfo, "defaultValue");
    openMBeanAttributeInfo = new OpenMBeanAttributeInfoSupport("name", "description", SimpleType.INTEGER, true, true, false, 1, null);
    test(openMBeanAttributeInfo, "legalValues");
    // ----
    System.out.println("\n---Testing on OpenMBeanConstructorInfoSupport...");
    OpenMBeanConstructorInfo openMBeanConstructorInfo;
    openMBeanConstructorInfo = new OpenMBeanConstructorInfoSupport("name", "description", null, new DescriptorSupport());
    test(openMBeanConstructorInfo, "sigs");
    openMBeanConstructorInfo = new OpenMBeanConstructorInfoSupport("name", "description", new OpenMBeanParameterInfo[] {}, null);
    test(openMBeanConstructorInfo, "Descriptor");
    // ----
    System.out.println("\n---Testing on OpenMBeanOperationInfoSupport...");
    OpenMBeanOperationInfo openMBeanOperationInfo;
    openMBeanOperationInfo = new OpenMBeanOperationInfoSupport("name", "description", null, SimpleType.INTEGER, 1, new DescriptorSupport());
    test(openMBeanOperationInfo, "sigs");
    openMBeanOperationInfo = new OpenMBeanOperationInfoSupport("name", "description", new OpenMBeanParameterInfo[] {}, SimpleType.INTEGER, 1, null);
    test(openMBeanOperationInfo, "Descriptor");
    // ----
    System.out.println("\n---Testing on OpenMBeanParameterInfoSupport 1...");
    OpenMBeanParameterInfo openMBeanParameterInfo;
    openMBeanParameterInfo = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, null, -1, 1);
    test(openMBeanParameterInfo, "default value");
    openMBeanParameterInfo = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, 0, null, 1);
    test(openMBeanParameterInfo, "min value");
    openMBeanParameterInfo = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, 0, -1, null);
    test(openMBeanParameterInfo, "max value");
    // ----
    System.out.println("\n---Testing on OpenMBeanParameterInfoSupport 2...");
    openMBeanParameterInfo = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, 1, new Integer[] { -1, 1, 2 });
    openMBeanParameterInfo = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, null, new Integer[] { -1, 1, 2 });
    test(openMBeanParameterInfo, "default value");
    openMBeanParameterInfo = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, 1, null);
    test(openMBeanParameterInfo, "legal values");
    // ----
    System.out.println("\n---Testing on OpenMBeanInfoSupport...");
    String className = "toto";
    String description = "titi";
    OpenMBeanAttributeInfo[] attrInfos = new OpenMBeanAttributeInfo[] {};
    OpenMBeanConstructorInfo[] constrInfos = new OpenMBeanConstructorInfo[] {};
    OpenMBeanOperationInfo[] operaInfos = new OpenMBeanOperationInfo[] {};
    MBeanNotificationInfo[] notifInfos = new MBeanNotificationInfo[] {};
    OpenMBeanInfo ominfo = new OpenMBeanInfoSupport(null, description, attrInfos, constrInfos, operaInfos, notifInfos);
    test(ominfo, "class name");
    ominfo = new OpenMBeanInfoSupport(className, null, attrInfos, constrInfos, operaInfos, notifInfos);
    test(ominfo, "description");
    ominfo = new OpenMBeanInfoSupport(className, description, null, constrInfos, operaInfos, notifInfos);
    test(ominfo, "attrInfos");
    ominfo = new OpenMBeanInfoSupport(className, description, attrInfos, null, operaInfos, notifInfos);
    test(ominfo, "constructor infos");
    ominfo = new OpenMBeanInfoSupport(className, description, attrInfos, constrInfos, null, notifInfos);
    test(ominfo, "operation infos");
    ominfo = new OpenMBeanInfoSupport(className, description, attrInfos, constrInfos, operaInfos, null);
    test(ominfo, "notif infos");
    if (failed > 0) {
        throw new RuntimeException("Test failed: " + failed);
    } else {
        System.out.println("---Test: PASSED");
    }
}
Also used : OpenMBeanParameterInfo(javax.management.openmbean.OpenMBeanParameterInfo) OpenMBeanInfoSupport(javax.management.openmbean.OpenMBeanInfoSupport) DescriptorSupport(javax.management.modelmbean.DescriptorSupport) OpenMBeanParameterInfoSupport(javax.management.openmbean.OpenMBeanParameterInfoSupport) OpenMBeanConstructorInfo(javax.management.openmbean.OpenMBeanConstructorInfo) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) OpenMBeanAttributeInfo(javax.management.openmbean.OpenMBeanAttributeInfo) OpenMBeanConstructorInfoSupport(javax.management.openmbean.OpenMBeanConstructorInfoSupport) OpenMBeanAttributeInfoSupport(javax.management.openmbean.OpenMBeanAttributeInfoSupport) OpenMBeanOperationInfo(javax.management.openmbean.OpenMBeanOperationInfo) OpenMBeanOperationInfoSupport(javax.management.openmbean.OpenMBeanOperationInfoSupport) OpenMBeanInfo(javax.management.openmbean.OpenMBeanInfo)

Example 2 with OpenMBeanParameterInfoSupport

use of javax.management.openmbean.OpenMBeanParameterInfoSupport in project jdk8u_jdk by JetBrains.

the class MBeanInfoInteropTest method init.

private static void init() throws Exception {
    mbai = new MBeanAttributeInfo("name", "type", "descr", true, false, false);
    mbpi = new MBeanParameterInfo("name", "type", "descr");
    MBeanParameterInfo[] params = new MBeanParameterInfo[] { mbpi };
    mbci1 = new MBeanConstructorInfo("name", "descr", null);
    mbci2 = new MBeanConstructorInfo("name", "descr", params);
    mbni1 = new MBeanNotificationInfo(null, "name", "descr");
    mbni2 = new MBeanNotificationInfo(new String[] { "type" }, "name", "descr");
    mboi1 = new MBeanOperationInfo("name", "descr", null, "type", ACTION);
    mboi2 = new MBeanOperationInfo("name", "descr", params, "type", INFO);
    mbi1 = new MBeanInfo("class", "descr", null, null, null, null);
    mbi2 = new MBeanInfo("class", "descr", new MBeanAttributeInfo[] { mbai }, new MBeanConstructorInfo[] { mbci1, mbci2 }, new MBeanOperationInfo[] { mboi1, mboi2 }, new MBeanNotificationInfo[] { mbni1, mbni2 });
    ombai1 = new OpenMBeanAttributeInfoSupport("name", "descr", INTEGER, true, false, false);
    ombai2 = new OpenMBeanAttributeInfoSupport("name", "descr", INTEGER, true, false, false, 5);
    ombai3 = new OpenMBeanAttributeInfoSupport("name", "descr", INTEGER, true, false, false, 5, 1, 6);
    ombai4 = new OpenMBeanAttributeInfoSupport("name", "descr", INTEGER, true, false, false, 5, new Integer[] { 2, 3, 5, 7 });
    ombpi1 = new OpenMBeanParameterInfoSupport("name1", "descr", INTEGER);
    ombpi2 = new OpenMBeanParameterInfoSupport("name2", "descr", INTEGER, 5);
    ombpi3 = new OpenMBeanParameterInfoSupport("name3", "descr", INTEGER, 5, 1, 6);
    ombpi4 = new OpenMBeanParameterInfoSupport("name4", "descr", INTEGER, 5, new Integer[] { 2, 3, 5, 7 });
    OpenMBeanParameterInfo[] oparams = { ombpi1, ombpi2, ombpi3, ombpi4 };
    ombci1 = new OpenMBeanConstructorInfoSupport("name", "descr", null);
    ombci2 = new OpenMBeanConstructorInfoSupport("name", "descr", oparams);
    omboi1 = new OpenMBeanOperationInfoSupport("name", "descr", null, INTEGER, ACTION);
    omboi2 = new OpenMBeanOperationInfoSupport("name", "descr", oparams, INTEGER, ACTION);
    ombi1 = new OpenMBeanInfoSupport("class", "descr", null, null, null, null);
    ombi2 = new OpenMBeanInfoSupport("class", "descr", new OpenMBeanAttributeInfo[] { ombai1, ombai2, ombai3, ombai4 }, new OpenMBeanConstructorInfo[] { ombci1, ombci2 }, new OpenMBeanOperationInfo[] { omboi1, omboi2 }, new MBeanNotificationInfo[] { mbni1, mbni2 });
    Descriptor attrd = new DescriptorSupport(new String[] { "name=name", "descriptorType=attribute" });
    mmbai1 = new ModelMBeanAttributeInfo("name", "type", "descr", true, false, false);
    mmbai2 = new ModelMBeanAttributeInfo("name", "type", "descr", true, false, false, attrd);
    Descriptor constrd = new DescriptorSupport(new String[] { "name=name", "descriptorType=operation", "role=constructor" });
    mmbci1 = new ModelMBeanConstructorInfo("name", "descr", null);
    mmbci2 = new ModelMBeanConstructorInfo("name", "descr", null, constrd);
    mmbci3 = new ModelMBeanConstructorInfo("name", "descr", params);
    mmbci4 = new ModelMBeanConstructorInfo("name", "descr", params, constrd);
    Descriptor operd = new DescriptorSupport(new String[] { "name=name", "descriptorType=operation" });
    mmboi1 = new ModelMBeanOperationInfo("name", "descr", null, "type", ACTION);
    mmboi2 = new ModelMBeanOperationInfo("name", "descr", null, "type", ACTION, operd);
    mmboi3 = new ModelMBeanOperationInfo("name", "descr", params, "type", ACTION);
    mmboi4 = new ModelMBeanOperationInfo("name", "descr", params, "type", ACTION, operd);
    Descriptor notifd = new DescriptorSupport(new String[] { "name=name", "descriptorType=notification" });
    mmbni1 = new ModelMBeanNotificationInfo(null, "name", "descr");
    mmbni2 = new ModelMBeanNotificationInfo(null, "name", "descr", notifd);
    mmbni3 = new ModelMBeanNotificationInfo(new String[] { "type" }, "name", "descr");
    mmbni4 = new ModelMBeanNotificationInfo(new String[] { "type" }, "name", "descr", notifd);
    Descriptor mbeand = new DescriptorSupport(new String[] { "name=name", "descriptorType=mbean" });
    mmbi1 = new ModelMBeanInfoSupport("class", "descr", null, null, null, null);
    mmbi2 = new ModelMBeanInfoSupport("class", "descr", null, null, null, null, mbeand);
    mmbi3 = new ModelMBeanInfoSupport("class", "descr", new ModelMBeanAttributeInfo[] { mmbai1, mmbai2 }, new ModelMBeanConstructorInfo[] { mmbci1, mmbci2, mmbci3, mmbci4 }, new ModelMBeanOperationInfo[] { mmboi1, mmboi2, mmboi3, mmboi4 }, new ModelMBeanNotificationInfo[] { mmbni1, mmbni2, mmbni3, mmbni4 });
    mmbi4 = new ModelMBeanInfoSupport("class", "descr", new ModelMBeanAttributeInfo[] { mmbai1, mmbai2 }, new ModelMBeanConstructorInfo[] { mmbci1, mmbci2, mmbci3, mmbci4 }, new ModelMBeanOperationInfo[] { mmboi1, mmboi2, mmboi3, mmboi4 }, new ModelMBeanNotificationInfo[] { mmbni1, mmbni2, mmbni3, mmbni4 }, mbeand);
    objects = new Serializable[] { mbai, mbpi, mbci1, mbci2, mbni1, mbni2, mboi1, mboi2, mbi1, mbi2, ombai1, ombai2, ombai3, ombai4, ombpi1, ombpi2, ombpi3, ombpi4, ombci1, ombci2, omboi1, omboi2, ombi1, ombi2, mmbai1, mmbai2, mmbci1, mmbci2, mmbci3, mmbci4, mmboi1, mmboi2, mmboi3, mmboi4, mmbni1, mmbni2, mmbni3, mmbni4 };
}
Also used : ModelMBeanOperationInfo(javax.management.modelmbean.ModelMBeanOperationInfo) MBeanInfo(javax.management.MBeanInfo) OpenMBeanInfoSupport(javax.management.openmbean.OpenMBeanInfoSupport) OpenMBeanParameterInfoSupport(javax.management.openmbean.OpenMBeanParameterInfoSupport) ModelMBeanConstructorInfo(javax.management.modelmbean.ModelMBeanConstructorInfo) MBeanConstructorInfo(javax.management.MBeanConstructorInfo) OpenMBeanConstructorInfo(javax.management.openmbean.OpenMBeanConstructorInfo) ModelMBeanAttributeInfo(javax.management.modelmbean.ModelMBeanAttributeInfo) OpenMBeanAttributeInfo(javax.management.openmbean.OpenMBeanAttributeInfo) ModelMBeanInfoSupport(javax.management.modelmbean.ModelMBeanInfoSupport) OpenMBeanOperationInfoSupport(javax.management.openmbean.OpenMBeanOperationInfoSupport) OpenMBeanParameterInfo(javax.management.openmbean.OpenMBeanParameterInfo) ModelMBeanNotificationInfo(javax.management.modelmbean.ModelMBeanNotificationInfo) ModelMBeanOperationInfo(javax.management.modelmbean.ModelMBeanOperationInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) OpenMBeanOperationInfo(javax.management.openmbean.OpenMBeanOperationInfo) DescriptorSupport(javax.management.modelmbean.DescriptorSupport) ModelMBeanConstructorInfo(javax.management.modelmbean.ModelMBeanConstructorInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) ModelMBeanAttributeInfo(javax.management.modelmbean.ModelMBeanAttributeInfo) OpenMBeanAttributeInfo(javax.management.openmbean.OpenMBeanAttributeInfo) OpenMBeanConstructorInfo(javax.management.openmbean.OpenMBeanConstructorInfo) ModelMBeanNotificationInfo(javax.management.modelmbean.ModelMBeanNotificationInfo) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) OpenMBeanConstructorInfoSupport(javax.management.openmbean.OpenMBeanConstructorInfoSupport) Descriptor(javax.management.Descriptor) OpenMBeanAttributeInfoSupport(javax.management.openmbean.OpenMBeanAttributeInfoSupport) OpenMBeanOperationInfo(javax.management.openmbean.OpenMBeanOperationInfo) MBeanParameterInfo(javax.management.MBeanParameterInfo) OpenMBeanParameterInfo(javax.management.openmbean.OpenMBeanParameterInfo)

Example 3 with OpenMBeanParameterInfoSupport

use of javax.management.openmbean.OpenMBeanParameterInfoSupport in project drools by kiegroup.

the class KnowledgeBaseMonitoring method initOpenMBeanInfo.

/**
 *  Initialize the open mbean metadata
 */
private void initOpenMBeanInfo() {
    OpenMBeanAttributeInfoSupport[] attributes = new OpenMBeanAttributeInfoSupport[4];
    OpenMBeanConstructorInfoSupport[] constructors = new OpenMBeanConstructorInfoSupport[1];
    OpenMBeanOperationInfoSupport[] operations = new OpenMBeanOperationInfoSupport[2];
    MBeanNotificationInfo[] notifications = new MBeanNotificationInfo[0];
    try {
        // Define the attributes
        attributes[0] = new OpenMBeanAttributeInfoSupport(ATTR_ID, "Knowledge Base Id", SimpleType.STRING, true, false, false);
        attributes[1] = new OpenMBeanAttributeInfoSupport(ATTR_SESSION_COUNT, "Number of created sessions for this Knowledge Base", SimpleType.LONG, true, false, false);
        attributes[2] = new OpenMBeanAttributeInfoSupport(ATTR_GLOBALS, "List of globals", globalsTableType, true, false, false);
        attributes[3] = new OpenMBeanAttributeInfoSupport(ATTR_PACKAGES, "List of Packages", new ArrayType(1, SimpleType.STRING), true, false, false);
        // No arg constructor
        constructors[0] = new OpenMBeanConstructorInfoSupport("KnowledgeBaseMonitoringMXBean", "Constructs a KnowledgeBaseMonitoringMXBean instance.", new OpenMBeanParameterInfoSupport[0]);
        // Operations
        OpenMBeanParameterInfo[] params = new OpenMBeanParameterInfoSupport[0];
        operations[0] = new OpenMBeanOperationInfoSupport(OP_START_INTERNAL_MBEANS, "Creates, registers and starts all the dependent MBeans that allow monitor all the details in this KnowledgeBase.", params, SimpleType.VOID, MBeanOperationInfo.INFO);
        operations[1] = new OpenMBeanOperationInfoSupport(OP_STOP_INTERNAL_MBEANS, "Stops and disposes all the dependent MBeans that allow monitor all the details in this KnowledgeBase.", params, SimpleType.VOID, MBeanOperationInfo.INFO);
        // Build the info
        info = new OpenMBeanInfoSupport(this.getClass().getName(), "Knowledge Base Monitor MXBean", attributes, constructors, operations, notifications);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : OpenMBeanParameterInfo(javax.management.openmbean.OpenMBeanParameterInfo) OpenMBeanInfoSupport(javax.management.openmbean.OpenMBeanInfoSupport) OpenMBeanParameterInfoSupport(javax.management.openmbean.OpenMBeanParameterInfoSupport) OpenDataException(javax.management.openmbean.OpenDataException) AttributeNotFoundException(javax.management.AttributeNotFoundException) ReflectionException(javax.management.ReflectionException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) RuntimeOperationsException(javax.management.RuntimeOperationsException) ArrayType(javax.management.openmbean.ArrayType) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) OpenMBeanConstructorInfoSupport(javax.management.openmbean.OpenMBeanConstructorInfoSupport) OpenMBeanAttributeInfoSupport(javax.management.openmbean.OpenMBeanAttributeInfoSupport) OpenMBeanOperationInfoSupport(javax.management.openmbean.OpenMBeanOperationInfoSupport)

Example 4 with OpenMBeanParameterInfoSupport

use of javax.management.openmbean.OpenMBeanParameterInfoSupport in project jdk8u_jdk by JetBrains.

the class OpenMBeanInfoEqualsNPETest method main.

public static void main(String[] args) throws Exception {
    System.out.println("---OpenMBeanInfoEqualsNPETest-main ...");
    // ----
    System.out.println("\n---Testing on OpenMBeanAttributeInfoSupport...");
    OpenMBeanAttributeInfo openMBeanAttributeInfo0 = new OpenMBeanAttributeInfoSupport("name", "description", SimpleType.INTEGER, true, true, false, 1, new Integer[] { 1, 2, 3 });
    OpenMBeanAttributeInfo openMBeanAttributeInfo = new OpenMBeanAttributeInfoSupport("name", "description", SimpleType.INTEGER, true, true, false, null, new Integer[] { 1, 2, 3 });
    test(openMBeanAttributeInfo0, openMBeanAttributeInfo, "defaultValue");
    openMBeanAttributeInfo = new OpenMBeanAttributeInfoSupport("name", "description", SimpleType.INTEGER, true, true, false, 1, null);
    test(openMBeanAttributeInfo0, openMBeanAttributeInfo, "legalValues");
    // ----
    System.out.println("\n---Testing on OpenMBeanConstructorInfoSupport...");
    OpenMBeanConstructorInfo openMBeanConstructorInfo0 = new OpenMBeanConstructorInfoSupport("name", "description", new OpenMBeanParameterInfo[] {}, new DescriptorSupport());
    OpenMBeanConstructorInfo openMBeanConstructorInfo;
    openMBeanConstructorInfo = new OpenMBeanConstructorInfoSupport("name", "description", null, new DescriptorSupport());
    test(openMBeanConstructorInfo0, openMBeanConstructorInfo, "sigs");
    openMBeanConstructorInfo = new OpenMBeanConstructorInfoSupport("name", "description", new OpenMBeanParameterInfo[] {}, null);
    test(openMBeanConstructorInfo0, openMBeanConstructorInfo, "Descriptor");
    // ----
    System.out.println("\n---Testing on OpenMBeanOperationInfoSupport...");
    OpenMBeanOperationInfo openMBeanOperationInfo0 = new OpenMBeanOperationInfoSupport("name", "description", new OpenMBeanParameterInfo[] {}, SimpleType.INTEGER, 1, new DescriptorSupport());
    OpenMBeanOperationInfo openMBeanOperationInfo;
    openMBeanOperationInfo = new OpenMBeanOperationInfoSupport("name", "description", null, SimpleType.INTEGER, 1, new DescriptorSupport());
    test(openMBeanOperationInfo0, openMBeanOperationInfo, "sigs");
    openMBeanOperationInfo = new OpenMBeanOperationInfoSupport("name", "description", new OpenMBeanParameterInfo[] {}, SimpleType.INTEGER, MBeanOperationInfo.UNKNOWN, null);
    test(openMBeanOperationInfo0, openMBeanOperationInfo, "Descriptor");
    // ----
    System.out.println("\n---Testing on OpenMBeanParameterInfoSupport 1...");
    OpenMBeanParameterInfo openMBeanParameterInfo0 = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, 0, -1, 1);
    OpenMBeanParameterInfo openMBeanParameterInfo;
    openMBeanParameterInfo = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, null, -1, 1);
    test(openMBeanParameterInfo0, openMBeanParameterInfo, "default value");
    openMBeanParameterInfo = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, 0, null, 1);
    test(openMBeanParameterInfo0, openMBeanParameterInfo, "min value");
    openMBeanParameterInfo = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, 0, -1, null);
    test(openMBeanParameterInfo0, openMBeanParameterInfo, "max value");
    // ----
    System.out.println("\n---Testing on OpenMBeanParameterInfoSupport 2...");
    openMBeanParameterInfo0 = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, 1, new Integer[] { -1, 1, 2 });
    openMBeanParameterInfo = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, null, new Integer[] { -1, 1, 2 });
    test(openMBeanParameterInfo0, openMBeanParameterInfo, "default value");
    openMBeanParameterInfo = new OpenMBeanParameterInfoSupport("name", "description", SimpleType.INTEGER, 1, null);
    test(openMBeanParameterInfo0, openMBeanParameterInfo, "legal values");
    // ----
    System.out.println("\n---Testing on OpenMBeanInfoSupport...");
    String className = "toto";
    String description = "titi";
    OpenMBeanAttributeInfo[] attrInfos = new OpenMBeanAttributeInfo[] {};
    OpenMBeanConstructorInfo[] constrInfos = new OpenMBeanConstructorInfo[] {};
    OpenMBeanOperationInfo[] operaInfos = new OpenMBeanOperationInfo[] {};
    MBeanNotificationInfo[] notifInfos = new MBeanNotificationInfo[] {};
    OpenMBeanInfo ominfo0 = new OpenMBeanInfoSupport("toto", description, attrInfos, constrInfos, operaInfos, notifInfos);
    OpenMBeanInfo ominfo = new OpenMBeanInfoSupport(null, description, attrInfos, constrInfos, operaInfos, notifInfos);
    test(ominfo0, ominfo, "class name");
    ominfo = new OpenMBeanInfoSupport(className, null, attrInfos, constrInfos, operaInfos, notifInfos);
    test(ominfo0, ominfo, "description");
    ominfo = new OpenMBeanInfoSupport(className, description, null, constrInfos, operaInfos, notifInfos);
    test(ominfo0, ominfo, "attrInfos");
    ominfo = new OpenMBeanInfoSupport(className, description, attrInfos, null, operaInfos, notifInfos);
    test(ominfo0, ominfo, "constructor infos");
    ominfo = new OpenMBeanInfoSupport(className, description, attrInfos, constrInfos, null, notifInfos);
    test(ominfo0, ominfo, "operation infos");
    ominfo = new OpenMBeanInfoSupport(className, description, attrInfos, constrInfos, operaInfos, null);
    test(ominfo0, ominfo, "notif infos");
    if (failed > 0) {
        throw new RuntimeException("Test failed: " + failed);
    } else {
        System.out.println("---Test: PASSED");
    }
}
Also used : OpenMBeanParameterInfo(javax.management.openmbean.OpenMBeanParameterInfo) OpenMBeanInfoSupport(javax.management.openmbean.OpenMBeanInfoSupport) DescriptorSupport(javax.management.modelmbean.DescriptorSupport) OpenMBeanParameterInfoSupport(javax.management.openmbean.OpenMBeanParameterInfoSupport) OpenMBeanConstructorInfo(javax.management.openmbean.OpenMBeanConstructorInfo) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) OpenMBeanAttributeInfo(javax.management.openmbean.OpenMBeanAttributeInfo) OpenMBeanConstructorInfoSupport(javax.management.openmbean.OpenMBeanConstructorInfoSupport) OpenMBeanAttributeInfoSupport(javax.management.openmbean.OpenMBeanAttributeInfoSupport) OpenMBeanOperationInfo(javax.management.openmbean.OpenMBeanOperationInfo) OpenMBeanOperationInfoSupport(javax.management.openmbean.OpenMBeanOperationInfoSupport) OpenMBeanInfo(javax.management.openmbean.OpenMBeanInfo)

Example 5 with OpenMBeanParameterInfoSupport

use of javax.management.openmbean.OpenMBeanParameterInfoSupport in project jdk8u_jdk by JetBrains.

the class MXBeanIntrospector method getMBeanOperationInfo.

@Override
MBeanOperationInfo getMBeanOperationInfo(String operationName, ConvertingMethod operation) {
    final Method method = operation.getMethod();
    final String description = operationName;
    /* Ideally this would be an empty string, but
           OMBOperationInfo constructor forbids that.  Also, we
           could consult an annotation to get a useful
           description.  */
    final int impact = MBeanOperationInfo.UNKNOWN;
    final OpenType<?> returnType = operation.getOpenReturnType();
    final Type originalReturnType = operation.getGenericReturnType();
    final OpenType<?>[] paramTypes = operation.getOpenParameterTypes();
    final Type[] originalParamTypes = operation.getGenericParameterTypes();
    final MBeanParameterInfo[] params = new MBeanParameterInfo[paramTypes.length];
    boolean openReturnType = canUseOpenInfo(originalReturnType);
    boolean openParameterTypes = true;
    Annotation[][] annots = method.getParameterAnnotations();
    for (int i = 0; i < paramTypes.length; i++) {
        final String paramName = "p" + i;
        final String paramDescription = paramName;
        final OpenType<?> openType = paramTypes[i];
        final Type originalType = originalParamTypes[i];
        Descriptor descriptor = typeDescriptor(openType, originalType);
        descriptor = ImmutableDescriptor.union(descriptor, Introspector.descriptorForAnnotations(annots[i]));
        final MBeanParameterInfo pi;
        if (canUseOpenInfo(originalType)) {
            pi = new OpenMBeanParameterInfoSupport(paramName, paramDescription, openType, descriptor);
        } else {
            openParameterTypes = false;
            pi = new MBeanParameterInfo(paramName, originalTypeString(originalType), paramDescription, descriptor);
        }
        params[i] = pi;
    }
    Descriptor descriptor = typeDescriptor(returnType, originalReturnType);
    descriptor = ImmutableDescriptor.union(descriptor, Introspector.descriptorForElement(method));
    final MBeanOperationInfo oi;
    if (openReturnType && openParameterTypes) {
        /* If the return value and all the parameters can be faithfully
             * represented as OpenType then we return an OpenMBeanOperationInfo.
             * If any of them is a primitive type, we can't.  Compatibility
             * with JSR 174 means that we must return an MBean*Info where
             * the getType() is the primitive type, not its wrapped type as
             * we would get with an OpenMBean*Info.  The OpenType is available
             * in the Descriptor in either case.
             */
        final OpenMBeanParameterInfo[] oparams = new OpenMBeanParameterInfo[params.length];
        System.arraycopy(params, 0, oparams, 0, params.length);
        oi = new OpenMBeanOperationInfoSupport(operationName, description, oparams, returnType, impact, descriptor);
    } else {
        oi = new MBeanOperationInfo(operationName, description, params, openReturnType ? returnType.getClassName() : originalTypeString(originalReturnType), impact, descriptor);
    }
    return oi;
}
Also used : OpenMBeanParameterInfo(javax.management.openmbean.OpenMBeanParameterInfo) OpenType(javax.management.openmbean.OpenType) MBeanOperationInfo(javax.management.MBeanOperationInfo) OpenMBeanParameterInfoSupport(javax.management.openmbean.OpenMBeanParameterInfoSupport) Method(java.lang.reflect.Method) GenericArrayType(java.lang.reflect.GenericArrayType) OpenType(javax.management.openmbean.OpenType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) Descriptor(javax.management.Descriptor) ImmutableDescriptor(javax.management.ImmutableDescriptor) OpenMBeanOperationInfoSupport(javax.management.openmbean.OpenMBeanOperationInfoSupport) MBeanParameterInfo(javax.management.MBeanParameterInfo) OpenMBeanParameterInfo(javax.management.openmbean.OpenMBeanParameterInfo)

Aggregations

OpenMBeanOperationInfoSupport (javax.management.openmbean.OpenMBeanOperationInfoSupport)5 OpenMBeanParameterInfo (javax.management.openmbean.OpenMBeanParameterInfo)5 OpenMBeanParameterInfoSupport (javax.management.openmbean.OpenMBeanParameterInfoSupport)5 MBeanNotificationInfo (javax.management.MBeanNotificationInfo)4 OpenMBeanAttributeInfoSupport (javax.management.openmbean.OpenMBeanAttributeInfoSupport)4 OpenMBeanConstructorInfoSupport (javax.management.openmbean.OpenMBeanConstructorInfoSupport)4 OpenMBeanInfoSupport (javax.management.openmbean.OpenMBeanInfoSupport)4 DescriptorSupport (javax.management.modelmbean.DescriptorSupport)3 OpenMBeanAttributeInfo (javax.management.openmbean.OpenMBeanAttributeInfo)3 OpenMBeanConstructorInfo (javax.management.openmbean.OpenMBeanConstructorInfo)3 OpenMBeanOperationInfo (javax.management.openmbean.OpenMBeanOperationInfo)3 Descriptor (javax.management.Descriptor)2 MBeanOperationInfo (javax.management.MBeanOperationInfo)2 MBeanParameterInfo (javax.management.MBeanParameterInfo)2 OpenMBeanInfo (javax.management.openmbean.OpenMBeanInfo)2 GenericArrayType (java.lang.reflect.GenericArrayType)1 Method (java.lang.reflect.Method)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 AttributeNotFoundException (javax.management.AttributeNotFoundException)1