package org.jboss.monitor;
import org.jboss.system.ServiceMBeanSupport;
import org.jboss.logging.Logger;
import javax.management.ObjectName;
import javax.management.MBeanException;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
import javax.management.ReflectionException;
public class StringThresholdMonitor extends JBossMonitor implements StringThresholdMonitorMBean
{
protected String thresholdString;
protected boolean equalityTriggersAlert;
protected void testThreshold()
{
if (alertSent) return;
String value = null;
try
{
value = (String)getServer().getAttribute(observedObject, attribute);
if (equalityTriggersAlert) {
if (!thresholdString.equals(value))
{
return;
}
}
else {
if (thresholdString.equals(value))
{
return;
}
}
}
catch (Exception e)
{
throw new RuntimeException("Failed to compare threshold, mbean failure");
}
alertSent = true;
triggerTime = System.currentTimeMillis();
triggeredAttributeValue = value;
StringThresholdNotification notification = new StringThresholdNotification(monitorName, getServiceName(), observedObject,
attribute, value, thresholdString, equalityTriggersAlert,
getNextNotificationSequenceNumber());
this.sendNotification(notification);
}
public String getThreshold()
{
return thresholdString;
}
public void setThreshold(String val)
{
thresholdString = val;
}
public boolean getEqualityTriggersAlert()
{
return equalityTriggersAlert;
}
public void setEqualityTriggersAlert(boolean compareEqual)
{
this.equalityTriggersAlert = compareEqual;
}
}