001: /* JFox, the OpenSource J2EE Application Server
002: *
003: * Copyright (C) 2002 huihoo.org
004: * Distributable under GNU LGPL license
005: * See the GNU Lesser General Public License for more details.
006: */
007:
008: package javax.management.monitor;
009:
010: import javax.management.ObjectName;
011: import javax.management.Notification;
012:
013: /**
014: * Provides definitions of the notifications sent by monitor MBeans.
015: * <P>
016: * The notification source and a set of parameters concerning the monitor MBean's state
017: * need to be specified when creating a new object of this class.
018: *
019: * The list of notifications fired by the monitor MBeans is the following:
020: *
021: * <UL>
022: * <LI>Common to all kind of monitors:
023: * <UL>
024: * <LI>The observed object is not registered in the MBean server.
025: * <LI>The observed attribute is not contained in the observed object.
026: * <LI>The type of the observed attribute is not correct.
027: * <LI>Any exception (except the cases described above) occurs when trying to get the value of the observed attribute.
028: * </UL>
029: * <LI>Common to the counter and the gauge monitors:
030: * <UL>
031: * <LI>The threshold high or threshold low are not of the same type as the gauge (gauge monitors).
032: * <LI>The threshold or the offset or the modulus are not of the same type as the counter (counter monitors).
033: * </UL>
034: * <LI>Counter monitors only:
035: * <UL>
036: * <LI>The observed attribute has reached the threshold value.
037: * </UL>
038: * <LI>Gauge monitors only:
039: * <UL>
040: * <LI>The observed attribute has exceeded the threshold high value.
041: * <LI>The observed attribute has exceeded the threshold low value.
042: * </UL>
043: * <LI>String monitors only:
044: * <UL>
045: * <LI>The observed attribute has matched the "string to compare" value.
046: * <LI>The observed attribute has differed from the "string to compare" value.
047: * </UL>
048: * </UL>
049: *
050: * @author <a href="mailto:young_yy@hotmail.org">Young Yang</a>
051: */
052:
053: public class MonitorNotification extends Notification {
054:
055: /**
056: * Notification type denoting that the observed object is not registered in the MBean server.
057: * This notification is fired by all kinds of monitors.
058: * <BR>The value of this notification type is <CODE>jmx.monitor.error.mbean</CODE>.
059: */
060: public static final String OBSERVED_OBJECT_ERROR = "jmx.monitor.error.mbean";
061:
062: /**
063: * Notification type denoting that the observed attribute is not contained in the observed object.
064: * This notification is fired by all kinds of monitors.
065: * <BR>The value of this notification type is <CODE>jmx.monitor.error.attribute</CODE>.
066: */
067: public static final String OBSERVED_ATTRIBUTE_ERROR = "jmx.monitor.error.attribute";
068:
069: /**
070: * Notification type denoting that the type of the observed attribute is not correct.
071: * This notification is fired by all kinds of monitors.
072: * <BR>The value of this notification type is <CODE>jmx.monitor.error.type</CODE>.
073: */
074: public static final String OBSERVED_ATTRIBUTE_TYPE_ERROR = "jmx.monitor.error.type";
075:
076: /**
077: * Notification type denoting that the type of the thresholds, offset or modulus is not correct.
078: * This notification is fired by counter and gauge monitors.
079: * <BR>The value of this notification type is <CODE>jmx.monitor.error.threshold</CODE>.
080: */
081: public static final String THRESHOLD_ERROR = "jmx.monitor.error.threshold";
082:
083: /**
084: * Notification type denoting that a non-predefined error type has occurred when trying to get the value of the observed attribute.
085: * This notification is fired by all kinds of monitors.
086: * <BR>The value of this notification type is <CODE>jmx.monitor.error.runtime</CODE>.
087: */
088: public static final String RUNTIME_ERROR = "jmx.monitor.error.runtime";
089:
090: /**
091: * Notification type denoting that the observed attribute has reached the threshold value.
092: * This notification is only fired by counter monitors.
093: * <BR>The value of this notification type is <CODE>jmx.monitor.counter.threshold</CODE>.
094: */
095: public static final String THRESHOLD_VALUE_EXCEEDED = "jmx.monitor.counter.threshold";
096:
097: /**
098: * Notification type denoting that the observed attribute has exceeded the threshold high value.
099: * This notification is only fired by gauge monitors.
100: * <BR>The value of this notification type is <CODE>jmx.monitor.gauge.high</CODE>.
101: */
102: public static final String THRESHOLD_HIGH_VALUE_EXCEEDED = "jmx.monitor.gauge.high";
103:
104: /**
105: * Notification type denoting that the observed attribute has exceeded the threshold low value.
106: * This notification is only fired by gauge monitors.
107: * <BR>The value of this notification type is <CODE>jmx.monitor.gauge.low</CODE>.
108: */
109: public static final String THRESHOLD_LOW_VALUE_EXCEEDED = "jmx.monitor.gauge.low";
110:
111: /**
112: * Notification type denoting that the observed attribute has matched the "string to compare" value.
113: * This notification is only fired by string monitors.
114: * <BR>The value of this notification type is <CODE>jmx.monitor.string.matches</CODE>.
115: */
116: public static final String STRING_TO_COMPARE_VALUE_MATCHED = "jmx.monitor.string.matches";
117:
118: /**
119: * Notification type denoting that the observed attribute has differed from the "string to compare" value.
120: * This notification is only fired by string monitors.
121: * <BR>The value of this notification type is <CODE>jmx.monitor.string.differs</CODE>.
122: */
123: public static final String STRING_TO_COMPARE_VALUE_DIFFERED = "jmx.monitor.string.differs";
124:
125: private ObjectName observedObject = null;
126: private String observedAttribute = null;
127: private Object derivedGauge = null;
128: private Object trigger = null;
129:
130: /**
131: * Creates a monitor notification object.
132: *
133: * @param type The notification type.
134: * @param source The notification producer.
135: * @param sequenceNumber The notification sequence number within the source object.
136: * @param timeStamp The notification emission date.
137: * @param message The notification message.
138: * @param observedObjectName The object observed by the producer of this notification.
139: * @param observedAttribute The attribute observed by the producer of this notification.
140: * @param derivedValue The derived gauge.
141: * @param trigger The threshold/string (depending on the monitor type) that triggered the notification.
142: */
143: MonitorNotification(String type, Object source,
144: long sequenceNumber, long timeStamp, String message,
145: ObjectName observedObjectName, String observedAttribute,
146: Object derivedValue, Object trigger) {
147: super (type, source, sequenceNumber, timeStamp, message);
148: observedObject = observedObjectName;
149: this .observedAttribute = observedAttribute;
150: derivedGauge = derivedValue;
151: this .trigger = trigger;
152: }
153:
154: /**
155: * Gets the observed object of this monitor notification.
156: *
157: * @return The observed object.
158: */
159: public ObjectName getObservedObject() {
160: return observedObject;
161: }
162:
163: /**
164: * Gets the observed attribute of this monitor notification.
165: *
166: * @return The observed attribute.
167: */
168: public String getObservedAttribute() {
169: return observedAttribute;
170: }
171:
172: /**
173: * Gets the derived gauge of this monitor notification.
174: *
175: * @return The derived gauge.
176: */
177: public Object getDerivedGauge() {
178: return derivedGauge;
179: }
180:
181: /**
182: * Gets the threshold/string (depending on the monitor type) that triggered off this monitor notification.
183: *
184: * @return The trigger.
185: */
186: public Object getTrigger() {
187: return trigger;
188: }
189:
190: }
|