当前位置: 首页>>代码示例>>Java>>正文


Java Notification.getSequenceNumber方法代码示例

本文整理汇总了Java中javax.management.Notification.getSequenceNumber方法的典型用法代码示例。如果您正苦于以下问题:Java Notification.getSequenceNumber方法的具体用法?Java Notification.getSequenceNumber怎么用?Java Notification.getSequenceNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.Notification的用法示例。


在下文中一共展示了Notification.getSequenceNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkNotifs

import javax.management.Notification; //导入方法依赖的package包/类
/**
 * Check received notifications
 */
public int checkNotifs(int size,
                       List<Notification> received,
                       List<ObjectName> expected) {
    if (received.size() != size) {
        echo("Error: expecting " + size + " notifications, got " +
                received.size());
        return 1;
    } else {
        for (Notification n : received) {
            echo("Received notification: " + n);
            if (!n.getType().equals("nb")) {
                echo("Notification type must be \"nb\"");
                return 1;
            }
            ObjectName o = (ObjectName) n.getSource();
            int index = (int) n.getSequenceNumber();
            ObjectName nb = expected.get(index);
            if (!o.equals(nb)) {
                echo("Notification source must be " + nb);
                return 1;
            }
        }
    }
    return 0;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:NotificationAccessControllerTest.java

示例2: checkNotifs

import javax.management.Notification; //导入方法依赖的package包/类
public int checkNotifs(int size,
                       List<Notification> received,
                       List<ObjectName> expected) {
    if (received.size() != size) {
        echo("Error: expecting " + size + " notifications, got " +
                received.size());
        return 1;
    } else {
        for (Notification n : received) {
            echo("Received notification: " + n);
            if (!n.getType().equals("nb")) {
                echo("Notification type must be \"nb\"");
                return 1;
            }
            ObjectName o = (ObjectName) n.getSource();
            int index = (int) n.getSequenceNumber();
            ObjectName nb = expected.get(index);
            if (!o.equals(nb)) {
                echo("Notification source must be " + nb);
                return 1;
            }
        }
    }
    return 0;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:NotificationEmissionTest.java

示例3: main

import javax.management.Notification; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    ObjectName relSvcName = new ObjectName("a:type=relationService");
    RelationServiceMBean relSvc =
            JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class);
    mbs.createMBean("javax.management.relation.RelationService",
                    relSvcName,
                    new Object[] {Boolean.TRUE},
                    new String[] {"boolean"});

    final BlockingQueue<Notification> q =
            new ArrayBlockingQueue<Notification>(100);
    NotificationListener qListener = new NotificationListener() {
        public void handleNotification(Notification notification,
                                       Object handback) {
            q.add(notification);
        }
    };
    mbs.addNotificationListener(relSvcName, qListener, null, null);

    RoleInfo leftInfo =
        new RoleInfo("left", "javax.management.timer.TimerMBean");
    RoleInfo rightInfo =
        new RoleInfo("right", "javax.management.timer.Timer");
    relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo});
    ObjectName timer1 = new ObjectName("a:type=timer,number=1");
    ObjectName timer2 = new ObjectName("a:type=timer,number=2");
    mbs.createMBean("javax.management.timer.Timer", timer1);
    mbs.createMBean("javax.management.timer.Timer", timer2);

    Role leftRole =
        new Role("left", Arrays.asList(new ObjectName[] {timer1}));
    Role rightRole =
        new Role("right", Arrays.asList(new ObjectName[] {timer2}));
    RoleList roles =
        new RoleList(Arrays.asList(new Role[] {leftRole, rightRole}));

    final int NREPEAT = 10;

    for (int i = 0; i < NREPEAT; i++) {
        relSvc.createRelation("relationName", "typeName", roles);
        relSvc.removeRelation("relationName");
    }

    Notification firstNotif = q.remove();
    long seqNo = firstNotif.getSequenceNumber();
    for (int i = 0; i < NREPEAT * 2 - 1; i++) {
        Notification n = q.remove();
        long nSeqNo = n.getSequenceNumber();
        if (nSeqNo != seqNo + 1) {
            throw new Exception(
                    "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " +
                    nSeqNo);
        }
        seqNo++;
    }
    System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " +
            "with contiguous sequence numbers");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:60,代码来源:RelationNotificationSeqNoTest.java


注:本文中的javax.management.Notification.getSequenceNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。