/**
* Update the counter and check for notifications
*/
public int counterMonitorNotification() throws Exception {
CounterMonitor counterMonitor = new CounterMonitor();
try {
// Create a new CounterMonitor MBean and add it to the MBeanServer.
//
echo(">>> CREATE a new CounterMonitor MBean");
ObjectName counterMonitorName = new ObjectName(
domain + ":type=" + CounterMonitor.class.getName());
server.registerMBean(counterMonitor, counterMonitorName);
echo(">>> ADD a listener to the CounterMonitor");
counterMonitor.addNotificationListener(this, null, null);
//
// MANAGEMENT OF A STANDARD MBEAN
//
echo(">>> SET the attributes of the CounterMonitor:");
counterMonitor.addObservedObject(obsObjName);
echo("\tATTRIBUTE \"ObservedObject\" = " + obsObjName);
counterMonitor.setObservedAttribute("IntegerAttribute");
echo("\tATTRIBUTE \"ObservedAttribute\" = IntegerAttribute");
counterMonitor.setNotify(false);
echo("\tATTRIBUTE \"NotifyFlag\" = false");
Integer threshold = 2;
counterMonitor.setInitThreshold(threshold);
echo("\tATTRIBUTE \"Threshold\" = " + threshold);
int granularityperiod = 500;
counterMonitor.setGranularityPeriod(granularityperiod);
echo("\tATTRIBUTE \"GranularityPeriod\" = " + granularityperiod);
echo(">>> START the CounterMonitor");
counterMonitor.start();
// Check if notification was received
//
doWait();
if (messageReceived) {
echo("\tOK: CounterMonitor got RUNTIME_ERROR notification!");
} else {
echo("\tKO: CounterMonitor did not get " +
"RUNTIME_ERROR notification!");
return 1;
}
} finally {
messageReceived = false;
if (counterMonitor != null)
counterMonitor.stop();
}
return 0;
}
ReflectionExceptionTest.java 文件源码
java
阅读 52
收藏 0
点赞 0
评论 0
项目:openjdk9
作者:
评论列表
文章目录