本文整理汇总了Java中javax.management.monitor.StringMonitor.setNotifyMatch方法的典型用法代码示例。如果您正苦于以下问题:Java StringMonitor.setNotifyMatch方法的具体用法?Java StringMonitor.setNotifyMatch怎么用?Java StringMonitor.setNotifyMatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.monitor.StringMonitor
的用法示例。
在下文中一共展示了StringMonitor.setNotifyMatch方法的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);
}
示例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: 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();
}
示例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;
}