import javax.management.Attribute;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.monitor.StringMonitor;
public class TriggerThresholdNotification {
public static void main(String[] args) throws Exception {
MBeanServerConnection connection = ...;
ObjectName objectName = ...;
StringMonitor monitor = new StringMonitor();
monitor.addObservedObject(objectName);
monitor.setAttributeFilter(new Attribute("Foo"));
monitor.setObservedAttribute("Foo");
monitor.setStringsToCompare(new String[] {"GREEN", "RED"});
connection.addNotificationListener(objectName, monitor, null, null);
connection.setAttribute(objectName, new Attribute("Foo", "RED"));
}
}