Search in sources :

Example 26 with MBeanNotificationInfo

use of javax.management.MBeanNotificationInfo in project jdk8u_jdk by JetBrains.

the class MBeanInfoHashCodeNPETest method main.

public static void main(String[] args) throws Exception {
    System.out.println("---MBeanInfoHashCodeNPETest-main ...");
    // ----
    System.out.println("\n---Testing on MBeanAttributeInfo...");
    MBeanAttributeInfo mbeanAttributeInfo = new MBeanAttributeInfo(null, SimpleType.INTEGER.getClassName(), "description", true, true, false);
    test(mbeanAttributeInfo, "class name");
    mbeanAttributeInfo = new MBeanAttributeInfo("name", null, "description", true, true, false);
    test(mbeanAttributeInfo, "type");
    mbeanAttributeInfo = new MBeanAttributeInfo("name", SimpleType.INTEGER.getClassName(), null, true, true, false);
    test(mbeanAttributeInfo, "description");
    // ----
    System.out.println("\n---Testing on MBeanConstructorInfo...");
    MBeanConstructorInfo mbeanConstructorInfo = new MBeanConstructorInfo(null, "", new MBeanParameterInfo[] {}, new DescriptorSupport());
    test(mbeanConstructorInfo, "name");
    mbeanConstructorInfo = new MBeanConstructorInfo("", null, new MBeanParameterInfo[] {}, new DescriptorSupport());
    test(mbeanConstructorInfo, "description");
    mbeanConstructorInfo = new MBeanConstructorInfo("", "", null, new DescriptorSupport());
    test(mbeanConstructorInfo, "MBeanParameterInfo");
    mbeanConstructorInfo = new MBeanConstructorInfo("", "", new MBeanParameterInfo[] {}, null);
    test(mbeanConstructorInfo, "descriptor");
    // ----
    System.out.println("\n---Testing on MBeanOperationInfo...");
    MBeanOperationInfo mbeanOperationInfo = new MBeanOperationInfo(null, "description", new MBeanParameterInfo[] {}, "type", 1, new DescriptorSupport());
    test(mbeanOperationInfo, "name");
    mbeanOperationInfo = new MBeanOperationInfo("name", null, new MBeanParameterInfo[] {}, "type", 1, new DescriptorSupport());
    test(mbeanOperationInfo, "description");
    mbeanOperationInfo = new MBeanOperationInfo("name", "description", null, "type", 1, new DescriptorSupport());
    test(mbeanOperationInfo, "MBeanParameterInfo");
    mbeanOperationInfo = new MBeanOperationInfo("name", "description", new MBeanParameterInfo[] {}, null, 1, new DescriptorSupport());
    test(mbeanOperationInfo, "type");
    mbeanOperationInfo = new MBeanOperationInfo("name", "description", new MBeanParameterInfo[] {}, "type", -1, new DescriptorSupport());
    test(mbeanOperationInfo, "native impact");
    mbeanOperationInfo = new MBeanOperationInfo("name", "description", new MBeanParameterInfo[] {}, "type", 1, null);
    test(mbeanOperationInfo, "Descriptor");
    // ----
    System.out.println("\n---Testing on MBeanParameterInfo...");
    MBeanParameterInfo mbeanParameterInfo = new MBeanParameterInfo(null, "type", "description", new DescriptorSupport());
    test(mbeanParameterInfo, "name");
    mbeanParameterInfo = new MBeanParameterInfo("name", null, "description", new DescriptorSupport());
    test(mbeanParameterInfo, "description");
    mbeanParameterInfo = new MBeanParameterInfo("name", "type", null, new DescriptorSupport());
    test(mbeanParameterInfo, "description");
    mbeanParameterInfo = new MBeanParameterInfo("name", "type", "description", null);
    test(mbeanParameterInfo, "Descriptor");
    // ----
    System.out.println("\n---Testing on MBeanInfo...");
    String className = "toto";
    String description = "titi";
    MBeanAttributeInfo[] attrInfos = new MBeanAttributeInfo[] {};
    MBeanConstructorInfo[] constrInfos = new MBeanConstructorInfo[] {};
    MBeanOperationInfo[] operaInfos = new MBeanOperationInfo[] {};
    MBeanNotificationInfo[] notifInfos = new MBeanNotificationInfo[] {};
    MBeanInfo minfo = new MBeanInfo(null, description, attrInfos, constrInfos, operaInfos, notifInfos);
    test(minfo, "class name");
    minfo = new MBeanInfo(className, description, attrInfos, constrInfos, operaInfos, notifInfos);
    test(minfo, "name");
    minfo = new MBeanInfo(className, null, attrInfos, constrInfos, operaInfos, notifInfos);
    test(minfo, "description");
    minfo = new MBeanInfo(className, description, null, constrInfos, operaInfos, notifInfos);
    test(minfo, "attrInfos");
    minfo = new MBeanInfo(className, description, attrInfos, constrInfos, null, notifInfos);
    test(minfo, "operaInfos");
    minfo = new MBeanInfo(className, description, attrInfos, constrInfos, operaInfos, null);
    test(minfo, "notifInfos");
    Thread.sleep(100);
    if (failed > 0) {
        throw new RuntimeException("Test failed: " + failed);
    } else {
        System.out.println("---Test: PASSED");
    }
}
Also used : MBeanInfo(javax.management.MBeanInfo) MBeanOperationInfo(javax.management.MBeanOperationInfo) DescriptorSupport(javax.management.modelmbean.DescriptorSupport) MBeanAttributeInfo(javax.management.MBeanAttributeInfo) MBeanConstructorInfo(javax.management.MBeanConstructorInfo) MBeanNotificationInfo(javax.management.MBeanNotificationInfo) MBeanParameterInfo(javax.management.MBeanParameterInfo)

Example 27 with MBeanNotificationInfo

use of javax.management.MBeanNotificationInfo 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 28 with MBeanNotificationInfo

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

the class MBeanNotification method isSupported.

/*
     * @see IMBeanNotification#isSupported(javax.management.ObjectName)
     */
@Override
public boolean isSupported(ObjectName objectName) {
    MBeanInfo info = null;
    try {
        info = activeJvm.getMBeanServer().getMBeanInfo(objectName);
    } catch (JvmCoreException e) {
        return false;
    }
    if (info == null) {
        return false;
    }
    MBeanNotificationInfo[] notificationInfoArray = info.getNotifications();
    if (notificationInfoArray == null || notificationInfoArray.length == 0) {
        return false;
    }
    return true;
}
Also used : MBeanNotificationInfo(javax.management.MBeanNotificationInfo) MBeanInfo(javax.management.MBeanInfo) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Aggregations

MBeanNotificationInfo (javax.management.MBeanNotificationInfo)28 MBeanInfo (javax.management.MBeanInfo)10 MBeanOperationInfo (javax.management.MBeanOperationInfo)7 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)6 MBeanConstructorInfo (javax.management.MBeanConstructorInfo)6 DescriptorSupport (javax.management.modelmbean.DescriptorSupport)5 MBeanParameterInfo (javax.management.MBeanParameterInfo)3 OpenMBeanAttributeInfo (javax.management.openmbean.OpenMBeanAttributeInfo)3 OpenMBeanAttributeInfoSupport (javax.management.openmbean.OpenMBeanAttributeInfoSupport)3 OpenMBeanConstructorInfo (javax.management.openmbean.OpenMBeanConstructorInfo)3 OpenMBeanConstructorInfoSupport (javax.management.openmbean.OpenMBeanConstructorInfoSupport)3 OpenMBeanInfoSupport (javax.management.openmbean.OpenMBeanInfoSupport)3 OpenMBeanOperationInfo (javax.management.openmbean.OpenMBeanOperationInfo)3 OpenMBeanOperationInfoSupport (javax.management.openmbean.OpenMBeanOperationInfoSupport)3 OpenMBeanParameterInfo (javax.management.openmbean.OpenMBeanParameterInfo)3 OpenMBeanParameterInfoSupport (javax.management.openmbean.OpenMBeanParameterInfoSupport)3 ArrayList (java.util.ArrayList)2 AttributeChangeNotification (javax.management.AttributeChangeNotification)2 Descriptor (javax.management.Descriptor)2 Notification (javax.management.Notification)2