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


Java StringMonitor.setGranularityPeriod方法代码示例

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


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

示例1: setUp

import javax.management.monitor.StringMonitor; //导入方法依赖的package包/类
/** Actions before every test case (common) */
protected void setUp() {

    res = true;
    mySb.setString("match");

    server = MBeanServerFactory.createMBeanServer();
    monitor = new StringMonitor();

    try {
        monitorName = new ObjectName(
                "org.apache.harmony.test.func.api.javax.management.monitor."
                        + "stringMonitor:type=StringMonitor,id=1");
        mySbName = new ObjectName(MyStringBuffer.MSB_NAME_TEMPLATE + "1");

        server.registerMBean(monitor, monitorName);
        server.registerMBean(mySb, mySbName);

    } catch (Throwable e) {
        e.printStackTrace();
        log.add("Test: ERROR: Internal error!");
        System.exit(106);
    }

    monitor.addNotificationListener(nListener, null, "handback");

    monitor.addObservedObject(mySbName);
    monitor.setObservedAttribute("String");
    monitor.setNotifyMatch(true);
    monitor.setNotifyDiffer(true);
    monitor.setGranularityPeriod(100);

}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:34,代码来源:FunctionsTest.java

示例2: stringMonitorNotification

import javax.management.monitor.StringMonitor; //导入方法依赖的package包/类
/**
 * Update the string and check for notifications
 */
public int stringMonitorNotification() throws Exception {

    StringMonitor stringMonitor = new StringMonitor();
    try {
        // Create a new StringMonitor MBean and add it to the MBeanServer.
        //
        echo(">>> CREATE a new StringMonitor MBean");
        ObjectName stringMonitorName = new ObjectName(
                        domain + ":type=" + StringMonitor.class.getName());
        server.registerMBean(stringMonitor, stringMonitorName);

        echo(">>> ADD a listener to the StringMonitor");
        stringMonitor.addNotificationListener(this, null, null);

        //
        // MANAGEMENT OF A STANDARD MBEAN
        //

        echo(">>> SET the attributes of the StringMonitor:");

        stringMonitor.addObservedObject(obsObjName);
        echo("\tATTRIBUTE \"ObservedObject\"    = " + obsObjName);

        stringMonitor.setObservedAttribute("StringAttribute");
        echo("\tATTRIBUTE \"ObservedAttribute\" = StringAttribute");

        stringMonitor.setNotifyMatch(false);
        echo("\tATTRIBUTE \"NotifyMatch\"       = false");

        stringMonitor.setNotifyDiffer(false);
        echo("\tATTRIBUTE \"NotifyDiffer\"      = false");

        stringMonitor.setStringToCompare("dummy");
        echo("\tATTRIBUTE \"StringToCompare\"   = \"dummy\"");

        int granularityperiod = 500;
        stringMonitor.setGranularityPeriod(granularityperiod);
        echo("\tATTRIBUTE \"GranularityPeriod\" = " + granularityperiod);

        echo(">>> START the StringMonitor");
        stringMonitor.start();

        // Check if notification was received
        //
        doWait();
        if (messageReceived) {
            echo("\tOK: StringMonitor got RUNTIME_ERROR notification!");
        } else {
            echo("\tKO: StringMonitor did not get " +
                 "RUNTIME_ERROR notification!");
            return 1;
        }
    } finally {
        messageReceived = false;
        if (stringMonitor != null)
            stringMonitor.stop();
    }

    return 0;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:64,代码来源:RuntimeExceptionTest.java

示例3: stringMonitorNotification

import javax.management.monitor.StringMonitor; //导入方法依赖的package包/类
/**
 * Update the string and check for notifications
 */
public int stringMonitorNotification() throws Exception {

    StringMonitor stringMonitor = new StringMonitor();
    try {
        // Create a new StringMonitor MBean and add it to the MBeanServer.
        //
        echo(">>> CREATE a new StringMonitor MBean");
        ObjectName stringMonitorName = new ObjectName(
                        domain + ":type=" + StringMonitor.class.getName());
        server.registerMBean(stringMonitor, stringMonitorName);

        echo(">>> ADD a listener to the StringMonitor");
        stringMonitor.addNotificationListener(this, null, null);

        //
        // MANAGEMENT OF A STANDARD MBEAN
        //

        echo(">>> SET the attributes of the StringMonitor:");

        stringMonitor.addObservedObject(obsObjName);
        echo("\tATTRIBUTE \"ObservedObject\"    = " + obsObjName);

        stringMonitor.setObservedAttribute("StringAttribute");
        echo("\tATTRIBUTE \"ObservedAttribute\" = StringAttribute");

        stringMonitor.setNotifyMatch(false);
        echo("\tATTRIBUTE \"NotifyMatch\"       = false");

        stringMonitor.setNotifyDiffer(false);
        echo("\tATTRIBUTE \"NotifyDiffer\"      = false");

        stringMonitor.setStringToCompare("dummy");
        echo("\tATTRIBUTE \"StringToCompare\"   = \"dummy\"");

        int granularityperiod = 500;
        stringMonitor.setGranularityPeriod(granularityperiod);
        echo("\tATTRIBUTE \"GranularityPeriod\" = " + granularityperiod);

        echo(">>> START the StringMonitor");
        stringMonitor.start();

        // Wait for granularity period (multiplied by 2 for sure)
        //
        Thread.sleep(granularityperiod * 2);

        // Check if notification was received
        //
        if (messageReceived) {
            echo("\tOK: StringMonitor got RUNTIME_ERROR notification!");
        } else {
            echo("\tKO: StringMonitor did not get " +
                 "RUNTIME_ERROR notification!");
            return 1;
        }
    } finally {
        messageReceived = false;
        if (stringMonitor != null)
            stringMonitor.stop();
    }

    return 0;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:67,代码来源:RuntimeExceptionTest.java


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