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


Java StringMonitor.setNotifyDiffer方法代码示例

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


在下文中一共展示了StringMonitor.setNotifyDiffer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addNotificationListener

import javax.management.monitor.StringMonitor; //导入方法依赖的package包/类
@Override
protected void addNotificationListener() throws Exception {
    
    JMXEndpoint ep = (JMXEndpoint) getEndpoint();
    // create the monitor bean
    Monitor bean = null;
    if (ep.getMonitorType().equals("counter")) {
        CounterMonitor counter = new CounterMonitor();
        Number initThreshold = convertNumberToAttributeType(ep.getInitThreshold(), ep.getJMXObjectName(), ep.getObservedAttribute());
        Number offset = convertNumberToAttributeType(ep.getOffset(), ep.getJMXObjectName(), ep.getObservedAttribute());
        Number modulus = convertNumberToAttributeType(ep.getModulus(), ep.getJMXObjectName(), ep.getObservedAttribute());
        counter.setInitThreshold(initThreshold);
        counter.setOffset(offset);
        counter.setModulus(modulus);
        counter.setDifferenceMode(ep.isDifferenceMode());
        counter.setNotify(true);
        bean = counter;
    } else if (ep.getMonitorType().equals("gauge")) {
        GaugeMonitor gm = new GaugeMonitor();
        gm.setNotifyHigh(ep.isNotifyHigh());
        gm.setNotifyLow(ep.isNotifyLow());
        gm.setDifferenceMode(ep.isDifferenceMode());
        Number highValue = convertNumberToAttributeType(ep.getThresholdHigh(), ep.getJMXObjectName(), ep.getObservedAttribute());
        Number lowValue = convertNumberToAttributeType(ep.getThresholdLow(), ep.getJMXObjectName(), ep.getObservedAttribute());
        gm.setThresholds(highValue, lowValue);
        bean = gm;
    } else if (ep.getMonitorType().equals("string")) {
        StringMonitor sm = new StringMonitor();
        sm.setNotifyDiffer(ep.isNotifyDiffer());
        sm.setNotifyMatch(ep.isNotifyMatch());
        sm.setStringToCompare(ep.getStringToCompare());
        bean = sm;
    }
    
    bean.addObservedObject(ep.getJMXObjectName());
    bean.setObservedAttribute(ep.getObservedAttribute());
    bean.setGranularityPeriod(ep.getGranularityPeriod());

    // register the bean
    mMonitorObjectName = new ObjectName(ep.getObjectDomain(), "name", "camel-jmx-monitor-" + UUID.randomUUID());
    ManagementFactory.getPlatformMBeanServer().registerMBean(bean, mMonitorObjectName); 
    
    // add ourselves as a listener to it
    NotificationFilter nf = ep.getNotificationFilter();
    getServerConnection().addNotificationListener(mMonitorObjectName, this, nf, bean);
    bean.start();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:48,代码来源:JMXMonitorConsumer.java

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