Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/management/AttributeChangeNotification.java
38829 views
/*1* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.management;26272829/**30* Provides definitions of the attribute change notifications sent by MBeans.31* <P>32* It's up to the MBean owning the attribute of interest to create and send33* attribute change notifications when the attribute change occurs.34* So the <CODE>NotificationBroadcaster</CODE> interface has to be implemented35* by any MBean for which an attribute change is of interest.36* <P>37* Example:38* If an MBean called <CODE>myMbean</CODE> needs to notify registered listeners39* when its attribute:40* <BLOCKQUOTE><CODE>41* String myString42* </CODE></BLOCKQUOTE>43* is modified, <CODE>myMbean</CODE> creates and emits the following notification:44* <BLOCKQUOTE><CODE>45* new AttributeChangeNotification(myMbean, sequenceNumber, timeStamp, msg,46* "myString", "String", oldValue, newValue);47* </CODE></BLOCKQUOTE>48*49* @since 1.550*/51public class AttributeChangeNotification extends javax.management.Notification {5253/* Serial version */54private static final long serialVersionUID = 535176054565814134L;5556/**57* Notification type which indicates that the observed MBean attribute value has changed.58* <BR>The value of this type string is <CODE>jmx.attribute.change</CODE>.59*/60public static final String ATTRIBUTE_CHANGE = "jmx.attribute.change";616263/**64* @serial The MBean attribute name.65*/66private String attributeName = null;6768/**69* @serial The MBean attribute type.70*/71private String attributeType = null;7273/**74* @serial The MBean attribute old value.75*/76private Object oldValue = null;7778/**79* @serial The MBean attribute new value.80*/81private Object newValue = null;828384/**85* Constructs an attribute change notification object.86* In addition to the information common to all notification, the caller must supply the name and type87* of the attribute, as well as its old and new values.88*89* @param source The notification producer, that is, the MBean the attribute belongs to.90* @param sequenceNumber The notification sequence number within the source object.91* @param timeStamp The date at which the notification is being sent.92* @param msg A String containing the message of the notification.93* @param attributeName A String giving the name of the attribute.94* @param attributeType A String containing the type of the attribute.95* @param oldValue An object representing value of the attribute before the change.96* @param newValue An object representing value of the attribute after the change.97*/98public AttributeChangeNotification(Object source, long sequenceNumber, long timeStamp, String msg,99String attributeName, String attributeType, Object oldValue, Object newValue) {100101super(AttributeChangeNotification.ATTRIBUTE_CHANGE, source, sequenceNumber, timeStamp, msg);102this.attributeName = attributeName;103this.attributeType = attributeType;104this.oldValue = oldValue;105this.newValue = newValue;106}107108109/**110* Gets the name of the attribute which has changed.111*112* @return A String containing the name of the attribute.113*/114public String getAttributeName() {115return attributeName;116}117118/**119* Gets the type of the attribute which has changed.120*121* @return A String containing the type of the attribute.122*/123public String getAttributeType() {124return attributeType;125}126127/**128* Gets the old value of the attribute which has changed.129*130* @return An Object containing the old value of the attribute.131*/132public Object getOldValue() {133return oldValue;134}135136/**137* Gets the new value of the attribute which has changed.138*139* @return An Object containing the new value of the attribute.140*/141public Object getNewValue() {142return newValue;143}144145}146147148