Defines a monitor MBean designed to observe the values of a string
attribute.
Method from javax.management.monitor.StringMonitor Detail: |
synchronized MonitorNotification buildAlarmNotification(ObjectName object,
String attribute,
Comparable<?> value) {
String type = null;
String msg = null;
Object trigger = null;
final StringMonitorObservedObject o =
(StringMonitorObservedObject) getObservedObject(object);
if (o == null)
return null;
// Send matching notification if notifyMatch is true.
// Send differing notification if notifyDiffer is true.
//
if (o.getStatus() == MATCHING_OR_DIFFERING) {
if (o.getDerivedGauge().equals(stringToCompare)) {
if (notifyMatch) {
type = STRING_TO_COMPARE_VALUE_MATCHED;
msg = "";
trigger = stringToCompare;
}
o.setStatus(DIFFERING);
} else {
if (notifyDiffer) {
type = STRING_TO_COMPARE_VALUE_DIFFERED;
msg = "";
trigger = stringToCompare;
}
o.setStatus(MATCHING);
}
} else {
if (o.getStatus() == MATCHING) {
if (o.getDerivedGauge().equals(stringToCompare)) {
if (notifyMatch) {
type = STRING_TO_COMPARE_VALUE_MATCHED;
msg = "";
trigger = stringToCompare;
}
o.setStatus(DIFFERING);
}
} else if (o.getStatus() == DIFFERING) {
if (!o.getDerivedGauge().equals(stringToCompare)) {
if (notifyDiffer) {
type = STRING_TO_COMPARE_VALUE_DIFFERED;
msg = "";
trigger = stringToCompare;
}
o.setStatus(MATCHING);
}
}
}
return new MonitorNotification(type,
this,
0,
0,
msg,
null,
null,
null,
trigger);
}
|
ObservedObject createObservedObject(ObjectName object) {
final StringMonitorObservedObject smo =
new StringMonitorObservedObject(object);
smo.setStatus(MATCHING_OR_DIFFERING);
return smo;
}
Factory method for ObservedObject creation. |
public synchronized String getDerivedGauge() {
if (observedObjects.isEmpty()) {
return null;
} else {
return (String) observedObjects.get(0).getDerivedGauge();
}
} Deprecated! As - of JMX 1.2, replaced by
#getDerivedGauge(ObjectName)
Returns the derived gauge of the first object in the set of
observed MBeans. |
public synchronized String getDerivedGauge(ObjectName object) {
return (String) super.getDerivedGauge(object);
}
Gets the derived gauge of the specified object, if this object is
contained in the set of observed MBeans, or null otherwise. |
public synchronized long getDerivedGaugeTimeStamp() {
if (observedObjects.isEmpty()) {
return 0;
} else {
return observedObjects.get(0).getDerivedGaugeTimeStamp();
}
} Deprecated! As - of JMX 1.2, replaced by
#getDerivedGaugeTimeStamp(ObjectName)
Gets the derived gauge timestamp of the first object in the set
of observed MBeans. |
public synchronized long getDerivedGaugeTimeStamp(ObjectName object) {
return super.getDerivedGaugeTimeStamp(object);
}
Gets the derived gauge timestamp of the specified object, if
this object is contained in the set of observed MBeans, or
0 otherwise. |
public MBeanNotificationInfo[] getNotificationInfo() {
return notifsInfo.clone();
}
Returns a NotificationInfo object containing the name of
the Java class of the notification and the notification types sent by
the string monitor. |
public synchronized boolean getNotifyDiffer() {
return notifyDiffer;
}
Gets the differing notification's on/off switch value common to
all observed MBeans. |
public synchronized boolean getNotifyMatch() {
return notifyMatch;
}
Gets the matching notification's on/off switch value common to
all observed MBeans. |
public synchronized String getStringToCompare() {
return stringToCompare;
}
Gets the string to compare with the observed attribute common
to all observed MBeans. |
synchronized boolean isComparableTypeValid(ObjectName object,
String attribute,
Comparable<?> value) {
// Check that the observed attribute is of type "String".
//
if (value instanceof String) {
return true;
}
return false;
}
Check that the type of the supplied observed attribute
value is one of the value types supported by this monitor. |
synchronized void onErrorNotification(MonitorNotification notification) {
final StringMonitorObservedObject o = (StringMonitorObservedObject)
getObservedObject(notification.getObservedObject());
if (o == null)
return;
// Reset values.
//
o.setStatus(MATCHING_OR_DIFFERING);
}
|
public synchronized void setNotifyDiffer(boolean value) {
if (notifyDiffer == value)
return;
notifyDiffer = value;
}
Sets the differing notification's on/off switch value common to
all observed MBeans. |
public synchronized void setNotifyMatch(boolean value) {
if (notifyMatch == value)
return;
notifyMatch = value;
}
Sets the matching notification's on/off switch value common to
all observed MBeans. |
public synchronized void setStringToCompare(String value) throws IllegalArgumentException {
if (value == null) {
throw new IllegalArgumentException("Null string to compare");
}
if (stringToCompare.equals(value))
return;
stringToCompare = value;
// Reset values.
//
for (ObservedObject o : observedObjects) {
final StringMonitorObservedObject smo =
(StringMonitorObservedObject) o;
smo.setStatus(MATCHING_OR_DIFFERING);
}
}
Sets the string to compare with the observed attribute common
to all observed MBeans. |
public synchronized void start() {
if (isActive()) {
MONITOR_LOGGER.logp(Level.FINER, StringMonitor.class.getName(),
"start", "the monitor is already active");
return;
}
// Reset values.
//
for (ObservedObject o : observedObjects) {
final StringMonitorObservedObject smo =
(StringMonitorObservedObject) o;
smo.setStatus(MATCHING_OR_DIFFERING);
}
doStart();
}
Starts the string monitor. |
public synchronized void stop() {
doStop();
}
Stops the string monitor. |