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;
009:
010: /**
011: * Provides definitions of the attribute change notifications sent by MBeans.
012: * <P>
013: * It's up to the MBean owning the attribute of interest to doCreate and send
014: * attribute change notifications when the attribute change occurs.
015: * So the <CODE>NotificationBroadcaster</CODE> interface has to be implemented
016: * by any MBean for which an attribute change is of interest.
017: * <P>
018: * Example:
019: * If an MBean called <CODE>myMbean</CODE> needs to notify registered listeners
020: * when its attribute:
021: * <BLOCKQUOTE><CODE>
022: * String myString
023: * </CODE></BLOCKQUOTE>
024: * is modified, <CODE>myMbean</CODE> creates and emits the following notification:
025: * <BLOCKQUOTE><CODE>
026: * new AttributeChangeNotification(myMbean, sequenceNumber, timeStamp, msg,
027: * "myString", "String", oldValue, newValue);
028: * </CODE></BLOCKQUOTE>
029: *
030: * @author <a href="mailto:young_yy@hotmail.org">Young Yang</a>
031: */
032:
033: public class AttributeChangeNotification extends
034: javax.management.Notification {
035:
036: /**
037: * Notification type which indicates that the observed MBean attribute value has changed.
038: * <BR>The value of this type string is <CODE>jmx.attribute.change</CODE>.
039: */
040: public static final String ATTRIBUTE_CHANGE = "jmx.attribute.change";
041:
042: /**
043: * The MBean attribute name.
044: */
045: private String attributeName = null;
046:
047: /**
048: * The MBean attribute type.
049: */
050: private String attributeType = null;
051:
052: /**
053: * The MBean attribute old value.
054: */
055: private Object oldValue = null;
056:
057: /**
058: * The MBean attribute new value.
059: */
060: private Object newValue = null;
061:
062: /**
063: * Constructs an attribute change notification object.
064: * In addition to the information common to all notification, the caller must supply the name and type
065: * of the attribute, as well as its old and new values.
066: *
067: * @param source The notification producer, that is, the MBean the attribute belongs to.
068: * @param sequenceNumber The notification sequence number within the source object.
069: * @param timeStamp The date at which the notification is being sent.
070: * @param msg A String containing the message of the notification.
071: * @param attributeName A String giving the name of the attribute.
072: * @param attributeType A String containing the type of the attribute.
073: * @param oldValue An object representing value of the attribute before the change.
074: * @param newValue An object representing value of the attribute after the change.
075: */
076: public AttributeChangeNotification(Object source,
077: long sequenceNumber, long timeStamp, String msg,
078: String attributeName, String attributeType,
079: Object oldValue, Object newValue) {
080:
081: super (AttributeChangeNotification.ATTRIBUTE_CHANGE, source,
082: sequenceNumber, timeStamp, msg);
083: this .attributeName = attributeName;
084: this .attributeType = attributeType;
085: this .oldValue = oldValue;
086: this .newValue = newValue;
087: }
088:
089: /**
090: * Gets the name of the attribute which has changed.
091: *
092: * @return A String containing the name of the attribute.
093: */
094: public String getAttributeName() {
095: return attributeName;
096: }
097:
098: /**
099: * Gets the type of the attribute which has changed.
100: *
101: * @return A String containing the type of the attribute.
102: */
103: public String getAttributeType() {
104: return attributeType;
105: }
106:
107: /**
108: * Gets the old value of the attribute which has changed.
109: *
110: * @return An Object containing the old value of the attribute.
111: */
112: public Object getOldValue() {
113: return oldValue;
114: }
115:
116: /**
117: * Gets the new value of the attribute which has changed.
118: *
119: * @return An Object containing the new value of the attribute.
120: */
121: public Object getNewValue() {
122: return newValue;
123: }
124:
125: }
|