本文整理汇总了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);
}
示例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;
}
示例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;
}