001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package javax.management;
023:
024: /**
025: * This is the mandated object for sending notifications of attribute
026: * changes. The MBean may also send other types of notifications.
027: * The MBean must implement the
028: * {@link javax.management.NotificationBroadcaster} interface to send
029: * this notification.<p>
030: *
031: * The following information is provided in addition to the that provided by
032: * {@link javax.management.Notification Notification}.
033: * The attribute's {@link #getAttributeName() name},
034: * {@link #getAttributeType() type},
035: * {@link #getOldValue() old value} and
036: * {@link #getNewValue() new value}. <p>
037: *
038: * The notification type is "jmx.attribute.change", defined in the
039: * static string {@link #ATTRIBUTE_CHANGE}.
040: *
041: * @see javax.management.AttributeChangeNotificationFilter
042: *
043: * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
044: * @version $Revision: 57200 $
045: *
046: * <p><b>Revisions:</b>
047: * <p><b>20020710 Adrian Brock:</b>
048: * <ul>
049: * <li> Serialization </li>
050: * </ul>
051: *
052: */
053: public class AttributeChangeNotification extends Notification {
054: // Constants -----------------------------------------------------
055:
056: private static final long serialVersionUID = 535176054565814134L;
057: /**
058: * The AttributeChangeNotification notification type. It is
059: * "jmx.attribute.change".
060: */
061: public static final String ATTRIBUTE_CHANGE = "jmx.attribute.change";
062:
063: // Attributes --------------------------------------------------------
064:
065: /**
066: * The name of the attribute.
067: */
068: private String attributeName = null;
069:
070: /**
071: * The type of the attribute.
072: */
073: private String attributeType = null;
074:
075: /**
076: * The old value of the attribute.
077: */
078: private Object oldValue = null;
079:
080: /**
081: * The new value of the attribute.
082: */
083: private Object newValue = null;
084:
085: // Static --------------------------------------------------------
086:
087: // Constructors --------------------------------------------------
088:
089: /**
090: * Contruct a new attribute change notification.
091: *
092: * @param source the source of the notification.
093: * @param sequenceNumber the instance of this notification.
094: * @param timeStamp the time the notification was generated.
095: * @param msg a human readable form of the change.
096: * @param attributeName the name of the attribute.
097: * @param attributeType the type of the attribute.
098: * @param oldValue the old value of the attribute.
099: * @param newValue the new value of the attribute.
100: */
101: public AttributeChangeNotification(Object source,
102: long sequenceNumber, long timeStamp, String msg,
103: String attributeName, String attributeType,
104: Object oldValue, Object newValue) {
105: super (ATTRIBUTE_CHANGE, source, sequenceNumber, timeStamp, msg);
106:
107: this .attributeName = attributeName;
108: this .attributeType = attributeType;
109: this .oldValue = oldValue;
110: this .newValue = newValue;
111: }
112:
113: // Public --------------------------------------------------------
114:
115: /**
116: * Retrieves the name of the attribute.
117: *
118: * @return the name of the attribute.
119: */
120: public String getAttributeName() {
121: return attributeName;
122: }
123:
124: /**
125: * Retrieves the type of the attribute.
126: *
127: * @return the type of the attribute.
128: */
129: public String getAttributeType() {
130: return attributeType;
131: }
132:
133: /**
134: * Retrieves the old value of the attribute.
135: *
136: * @return the old value of the attribute.
137: */
138: public Object getOldValue() {
139: return oldValue;
140: }
141:
142: /**
143: * Retrieves the new value of the attribute.
144: *
145: * @return the new value of the attribute.
146: */
147: public Object getNewValue() {
148: return newValue;
149: }
150:
151: /**
152: * @return human readable string.
153: */
154: public String toString() {
155: StringBuffer buffer = new StringBuffer(50);
156: buffer.append(getClass().getName()).append(":");
157: buffer.append(" source=").append(getSource());
158: buffer.append(" seq-no=").append(getSequenceNumber());
159: buffer.append(" time=").append(getTimeStamp());
160: buffer.append(" message=").append(getMessage());
161: buffer.append(" attributeName=").append(getAttributeName());
162: buffer.append(" attributeType=").append(getAttributeType());
163: buffer.append(" oldValue=").append(getOldValue());
164: buffer.append(" newValue=").append(getNewValue());
165: buffer.append(" notificationType=").append(getType());
166: buffer.append(" userData=").append(getUserData());
167: return buffer.toString();
168: }
169:
170: // Overrides -----------------------------------------------------
171:
172: // Implementation ------------------------------------------------
173:
174: // Package protected ---------------------------------------------
175:
176: // Protected -----------------------------------------------------
177:
178: // Private -------------------------------------------------------
179:
180: // Inner classes -------------------------------------------------
181: }
|