Search in sources :

Example 21 with MBeanNotificationInfo

use of javax.management.MBeanNotificationInfo in project spring-framework by spring-projects.

the class AbstractJmxAssemblerTests method testNotificationMetadata.

@Test
public void testNotificationMetadata() throws Exception {
    ModelMBeanInfo info = (ModelMBeanInfo) getMBeanInfo();
    MBeanNotificationInfo[] notifications = info.getNotifications();
    assertEquals("Incorrect number of notifications", 1, notifications.length);
    assertEquals("Incorrect notification name", "My Notification", notifications[0].getName());
    String[] notifTypes = notifications[0].getNotifTypes();
    assertEquals("Incorrect number of notification types", 2, notifTypes.length);
    assertEquals("Notification type.foo not found", "type.foo", notifTypes[0]);
    assertEquals("Notification type.bar not found", "type.bar", notifTypes[1]);
}
Also used : MBeanNotificationInfo(javax.management.MBeanNotificationInfo) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) Test(org.junit.Test)

Example 22 with MBeanNotificationInfo

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

the class RelationService method getNotificationInfo.

//
// NotificationBroadcaster interface
//
/**
     * Returns a NotificationInfo object containing the name of the Java class
     * of the notification and the notification types sent.
     */
public MBeanNotificationInfo[] getNotificationInfo() {
    RELATION_LOGGER.entering(RelationService.class.getName(), "getNotificationInfo");
    String ntfClass = "javax.management.relation.RelationNotification";
    String[] ntfTypes = new String[] { RelationNotification.RELATION_BASIC_CREATION, RelationNotification.RELATION_MBEAN_CREATION, RelationNotification.RELATION_BASIC_UPDATE, RelationNotification.RELATION_MBEAN_UPDATE, RelationNotification.RELATION_BASIC_REMOVAL, RelationNotification.RELATION_MBEAN_REMOVAL };
    String ntfDesc = "Sent when a relation is created, updated or deleted.";
    MBeanNotificationInfo ntfInfo = new MBeanNotificationInfo(ntfTypes, ntfClass, ntfDesc);
    RELATION_LOGGER.exiting(RelationService.class.getName(), "getNotificationInfo");
    return new MBeanNotificationInfo[] { ntfInfo };
}
Also used : MBeanNotificationInfo(javax.management.MBeanNotificationInfo)

Example 23 with MBeanNotificationInfo

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

the class MBeanIntrospector method findNotifications.

static MBeanNotificationInfo[] findNotifications(Object moi) {
    if (!(moi instanceof NotificationBroadcaster))
        return null;
    MBeanNotificationInfo[] mbn = ((NotificationBroadcaster) moi).getNotificationInfo();
    if (mbn == null)
        return null;
    MBeanNotificationInfo[] result = new MBeanNotificationInfo[mbn.length];
    for (int i = 0; i < mbn.length; i++) {
        MBeanNotificationInfo ni = mbn[i];
        if (ni.getClass() != MBeanNotificationInfo.class)
            ni = (MBeanNotificationInfo) ni.clone();
        result[i] = ni;
    }
    return result;
}
Also used : MBeanNotificationInfo(javax.management.MBeanNotificationInfo) NotificationBroadcaster(javax.management.NotificationBroadcaster)

Example 24 with MBeanNotificationInfo

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

the class CommunicatorServer method getNotificationInfo.

/**
     * Returns an array of MBeanNotificationInfo objects describing
     * the notification types sent by this CommunicatorServer.
     * There is only one type of notifications sent by the CommunicatorServer:
     * it is <tt>{@link javax.management.AttributeChangeNotification}</tt>,
     * sent when the <tt>State</tt> attribute of this CommunicatorServer
     * changes.
     */
@Override
public MBeanNotificationInfo[] getNotificationInfo() {
    //
    if (notifInfos == null) {
        notifInfos = new MBeanNotificationInfo[1];
        String[] notifTypes = { AttributeChangeNotification.ATTRIBUTE_CHANGE };
        notifInfos[0] = new MBeanNotificationInfo(notifTypes, AttributeChangeNotification.class.getName(), "Sent to notify that the value of the State attribute " + "of this CommunicatorServer instance has changed.");
    }
    return notifInfos.clone();
}
Also used : MBeanNotificationInfo(javax.management.MBeanNotificationInfo)

Example 25 with MBeanNotificationInfo

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

the class MBeanInfoEqualsNPETest method main.

public static void main(String[] args) throws Exception {
    System.out.println("---MBeanInfoEqualsNPETest-main ...");
    // ----
    System.out.println("\n---Testing on MBeanAttributeInfo...");
    MBeanAttributeInfo mbeanAttributeInfo0 = new MBeanAttributeInfo("name", SimpleType.INTEGER.getClassName(), "description", true, true, false);
    MBeanAttributeInfo mbeanAttributeInfo = new MBeanAttributeInfo(null, SimpleType.INTEGER.getClassName(), "description", true, true, false);
    test(mbeanAttributeInfo0, mbeanAttributeInfo, "class name");
    mbeanAttributeInfo = new MBeanAttributeInfo("name", null, "description", true, true, false);
    test(mbeanAttributeInfo0, mbeanAttributeInfo, "type");
    mbeanAttributeInfo = new MBeanAttributeInfo("name", SimpleType.INTEGER.getClassName(), null, true, true, false);
    test(mbeanAttributeInfo0, mbeanAttributeInfo, "description");
    // ----
    System.out.println("\n---Testing on MBeanConstructorInfo...");
    MBeanConstructorInfo mbeanConstructorInfo0 = new MBeanConstructorInfo("", "", new MBeanParameterInfo[] {}, new DescriptorSupport());
    MBeanConstructorInfo mbeanConstructorInfo = new MBeanConstructorInfo(null, "", new MBeanParameterInfo[] {}, new DescriptorSupport());
    test(mbeanConstructorInfo0, mbeanConstructorInfo, "name");
    mbeanConstructorInfo = new MBeanConstructorInfo("", null, new MBeanParameterInfo[] {}, new DescriptorSupport());
    test(mbeanConstructorInfo0, mbeanConstructorInfo, "description");
    mbeanConstructorInfo = new MBeanConstructorInfo("", "", null, new DescriptorSupport());
    test(mbeanConstructorInfo0, mbeanConstructorInfo, "MBeanParameterInfo");
    mbeanConstructorInfo = new MBeanConstructorInfo("", "", new MBeanParameterInfo[] {}, null);
    test(mbeanConstructorInfo0, mbeanConstructorInfo, "descriptor");
    // ----
    System.out.println("\n---Testing on MBeanOperationInfo...");
    MBeanOperationInfo mbeanOperationInfo0 = new MBeanOperationInfo("name", "description", new MBeanParameterInfo[] {}, "type", MBeanOperationInfo.UNKNOWN, new DescriptorSupport());
    MBeanOperationInfo mbeanOperationInfo = new MBeanOperationInfo(null, "description", new MBeanParameterInfo[] {}, "type", MBeanOperationInfo.UNKNOWN, new DescriptorSupport());
    test(mbeanOperationInfo0, mbeanOperationInfo, "name");
    mbeanOperationInfo = new MBeanOperationInfo("name", null, new MBeanParameterInfo[] {}, "type", MBeanOperationInfo.UNKNOWN, new DescriptorSupport());
    test(mbeanOperationInfo0, mbeanOperationInfo, "description");
    mbeanOperationInfo = new MBeanOperationInfo("name", "description", null, "type", 1, new DescriptorSupport());
    test(mbeanOperationInfo0, mbeanOperationInfo, "MBeanParameterInfo");
    mbeanOperationInfo = new MBeanOperationInfo("name", "description", new MBeanParameterInfo[] {}, null, MBeanOperationInfo.UNKNOWN, new DescriptorSupport());
    test(mbeanOperationInfo0, mbeanOperationInfo, "type");
    mbeanOperationInfo = new MBeanOperationInfo("name", "description", new MBeanParameterInfo[] {}, null, MBeanOperationInfo.UNKNOWN, null);
    test(mbeanOperationInfo0, mbeanOperationInfo, "Descriptor");
    // ----
    System.out.println("\n---Testing on MBeanParameterInfo...");
    MBeanParameterInfo mbeanParameterInfo0 = new MBeanParameterInfo("name", "type", "description", new DescriptorSupport());
    MBeanParameterInfo mbeanParameterInfo = new MBeanParameterInfo(null, "type", "description", new DescriptorSupport());
    test(mbeanParameterInfo0, mbeanParameterInfo, "name");
    mbeanParameterInfo = new MBeanParameterInfo("name", null, "description", new DescriptorSupport());
    test(mbeanParameterInfo0, mbeanParameterInfo, "type");
    mbeanParameterInfo = new MBeanParameterInfo("name", "type", null, new DescriptorSupport());
    test(mbeanParameterInfo0, mbeanParameterInfo, "description");
    mbeanParameterInfo = new MBeanParameterInfo("name", "type", "description", null);
    test(mbeanParameterInfo0, mbeanParameterInfo, "Descriptor");
    // ----
    System.out.println("\n---Testing on MBeanFeatureInfo ...");
    MBeanFeatureInfo mbeanFeatureInfo0 = new MBeanFeatureInfo("name", "description", new DescriptorSupport());
    MBeanFeatureInfo mbeanFeatureInfo = new MBeanFeatureInfo(null, "description", new DescriptorSupport());
    test(mbeanFeatureInfo0, mbeanFeatureInfo, "name");
    mbeanFeatureInfo = new MBeanFeatureInfo("name", null, new DescriptorSupport());
    test(mbeanParameterInfo0, mbeanParameterInfo, "description");
    mbeanFeatureInfo = new MBeanFeatureInfo("name", "description", null);
    test(mbeanParameterInfo0, 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 minfo0 = new MBeanInfo("toto", description, attrInfos, constrInfos, operaInfos, notifInfos);
    MBeanInfo minfo = new MBeanInfo(null, description, attrInfos, constrInfos, operaInfos, notifInfos);
    test(minfo0, minfo, "class name");
    minfo = new MBeanInfo(className, null, attrInfos, constrInfos, operaInfos, notifInfos);
    test(minfo0, minfo, "description");
    minfo = new MBeanInfo(className, description, null, constrInfos, operaInfos, notifInfos);
    test(minfo0, minfo, "attrInfos");
    minfo = new MBeanInfo(className, description, attrInfos, null, operaInfos, notifInfos);
    test(minfo0, minfo, "constrInfos");
    minfo = new MBeanInfo(className, description, attrInfos, constrInfos, null, notifInfos);
    test(minfo0, minfo, "operaInfos");
    minfo = new MBeanInfo(className, description, attrInfos, constrInfos, operaInfos, null);
    test(minfo0, minfo, "notifInfos");
    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) MBeanFeatureInfo(javax.management.MBeanFeatureInfo)

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