KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > management > AttributeChangeNotification


1 /*
2  * @(#)AttributeChangeNotification.java 4.20 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.management;
9
10
11
12 /**
13  * Provides definitions of the attribute change notifications sent by MBeans.
14  * <P>
15  * It's up to the MBean owning the attribute of interest to create and send
16  * attribute change notifications when the attribute change occurs.
17  * So the <CODE>NotificationBroadcaster</CODE> interface has to be implemented
18  * by any MBean for which an attribute change is of interest.
19  * <P>
20  * Example:
21  * If an MBean called <CODE>myMbean</CODE> needs to notify registered listeners
22  * when its attribute:
23  * <BLOCKQUOTE><CODE>
24  * String myString
25  * </CODE></BLOCKQUOTE>
26  * is modified, <CODE>myMbean</CODE> creates and emits the following notification:
27  * <BLOCKQUOTE><CODE>
28  * new AttributeChangeNotification(myMbean, sequenceNumber, timeStamp, msg,
29  * "myString", "String", oldValue, newValue);
30  * </CODE></BLOCKQUOTE>
31  *
32  * @since 1.5
33  */

34 public class AttributeChangeNotification extends javax.management.Notification JavaDoc {
35
36     /* Serial version */
37     private static final long serialVersionUID = 535176054565814134L;
38
39     /**
40      * Notification type which indicates that the observed MBean attribute value has changed.
41      * <BR>The value of this type string is <CODE>jmx.attribute.change</CODE>.
42      */

43     public static final String JavaDoc ATTRIBUTE_CHANGE = "jmx.attribute.change";
44       
45
46     /**
47      * @serial The MBean attribute name.
48      */

49     private String JavaDoc attributeName = null;
50
51     /**
52      * @serial The MBean attribute type.
53      */

54     private String JavaDoc attributeType = null;
55
56     /**
57      * @serial The MBean attribute old value.
58      */

59     private Object JavaDoc oldValue = null;
60     
61     /**
62      * @serial The MBean attribute new value.
63      */

64     private Object JavaDoc newValue = null;
65
66     
67     /**
68      * Constructs an attribute change notification object.
69      * In addition to the information common to all notification, the caller must supply the name and type
70      * of the attribute, as well as its old and new values.
71      *
72      * @param source The notification producer, that is, the MBean the attribute belongs to.
73      * @param sequenceNumber The notification sequence number within the source object.
74      * @param timeStamp The date at which the notification is being sent.
75      * @param msg A String containing the message of the notification.
76      * @param attributeName A String giving the name of the attribute.
77      * @param attributeType A String containing the type of the attribute.
78      * @param oldValue An object representing value of the attribute before the change.
79      * @param newValue An object representing value of the attribute after the change.
80      */

81     public AttributeChangeNotification(Object JavaDoc source, long sequenceNumber, long timeStamp, String JavaDoc msg,
82                                        String JavaDoc attributeName, String JavaDoc attributeType, Object JavaDoc oldValue, Object JavaDoc newValue) {
83         
84         super(AttributeChangeNotification.ATTRIBUTE_CHANGE, source, sequenceNumber, timeStamp, msg);
85         this.attributeName = attributeName;
86         this.attributeType = attributeType;
87         this.oldValue = oldValue;
88         this.newValue = newValue;
89     }
90       
91     
92     /**
93      * Gets the name of the attribute which has changed.
94      *
95      * @return A String containing the name of the attribute.
96      */

97     public String JavaDoc getAttributeName() {
98         return attributeName;
99     }
100
101     /**
102      * Gets the type of the attribute which has changed.
103      *
104      * @return A String containing the type of the attribute.
105      */

106     public String JavaDoc getAttributeType() {
107         return attributeType;
108     }
109
110     /**
111      * Gets the old value of the attribute which has changed.
112      *
113      * @return An Object containing the old value of the attribute.
114      */

115     public Object JavaDoc getOldValue() {
116         return oldValue;
117     }
118     
119     /**
120      * Gets the new value of the attribute which has changed.
121      *
122      * @return An Object containing the new value of the attribute.
123      */

124     public Object JavaDoc getNewValue() {
125         return newValue;
126     }
127       
128 }
129
130
131
Popular Tags