author | darcy |
Wed, 23 Oct 2019 13:01:40 -0700 | |
changeset 58766 | 54ffb15c4839 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
58766
54ffb15c4839
8232442: Suppress warnings on non-serializable non-transient instance fields in java.management.*
darcy
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.management; |
|
27 |
||
28 |
||
29 |
||
30 |
/** |
|
31 |
* Provides definitions of the attribute change notifications sent by MBeans. |
|
32 |
* <P> |
|
33 |
* It's up to the MBean owning the attribute of interest to create and send |
|
34 |
* attribute change notifications when the attribute change occurs. |
|
35 |
* So the <CODE>NotificationBroadcaster</CODE> interface has to be implemented |
|
36 |
* by any MBean for which an attribute change is of interest. |
|
37 |
* <P> |
|
38 |
* Example: |
|
39 |
* If an MBean called <CODE>myMbean</CODE> needs to notify registered listeners |
|
40 |
* when its attribute: |
|
41 |
* <BLOCKQUOTE><CODE> |
|
42 |
* String myString |
|
43 |
* </CODE></BLOCKQUOTE> |
|
44 |
* is modified, <CODE>myMbean</CODE> creates and emits the following notification: |
|
45 |
* <BLOCKQUOTE><CODE> |
|
46 |
* new AttributeChangeNotification(myMbean, sequenceNumber, timeStamp, msg, |
|
47 |
* "myString", "String", oldValue, newValue); |
|
48 |
* </CODE></BLOCKQUOTE> |
|
49 |
* |
|
50 |
* @since 1.5 |
|
51 |
*/ |
|
52 |
public class AttributeChangeNotification extends javax.management.Notification { |
|
53 |
||
54 |
/* Serial version */ |
|
55 |
private static final long serialVersionUID = 535176054565814134L; |
|
56 |
||
57 |
/** |
|
58 |
* Notification type which indicates that the observed MBean attribute value has changed. |
|
59 |
* <BR>The value of this type string is <CODE>jmx.attribute.change</CODE>. |
|
60 |
*/ |
|
61 |
public static final String ATTRIBUTE_CHANGE = "jmx.attribute.change"; |
|
62 |
||
63 |
||
64 |
/** |
|
65 |
* @serial The MBean attribute name. |
|
66 |
*/ |
|
67 |
private String attributeName = null; |
|
68 |
||
69 |
/** |
|
70 |
* @serial The MBean attribute type. |
|
71 |
*/ |
|
72 |
private String attributeType = null; |
|
73 |
||
74 |
/** |
|
75 |
* @serial The MBean attribute old value. |
|
76 |
*/ |
|
58766
54ffb15c4839
8232442: Suppress warnings on non-serializable non-transient instance fields in java.management.*
darcy
parents:
47216
diff
changeset
|
77 |
@SuppressWarnings("serial") // Conditionally serializable |
2 | 78 |
private Object oldValue = null; |
79 |
||
80 |
/** |
|
81 |
* @serial The MBean attribute new value. |
|
82 |
*/ |
|
58766
54ffb15c4839
8232442: Suppress warnings on non-serializable non-transient instance fields in java.management.*
darcy
parents:
47216
diff
changeset
|
83 |
@SuppressWarnings("serial") // Conditionally serializable |
2 | 84 |
private Object newValue = null; |
85 |
||
86 |
||
87 |
/** |
|
88 |
* Constructs an attribute change notification object. |
|
89 |
* In addition to the information common to all notification, the caller must supply the name and type |
|
90 |
* of the attribute, as well as its old and new values. |
|
91 |
* |
|
92 |
* @param source The notification producer, that is, the MBean the attribute belongs to. |
|
93 |
* @param sequenceNumber The notification sequence number within the source object. |
|
94 |
* @param timeStamp The date at which the notification is being sent. |
|
95 |
* @param msg A String containing the message of the notification. |
|
96 |
* @param attributeName A String giving the name of the attribute. |
|
97 |
* @param attributeType A String containing the type of the attribute. |
|
98 |
* @param oldValue An object representing value of the attribute before the change. |
|
99 |
* @param newValue An object representing value of the attribute after the change. |
|
100 |
*/ |
|
101 |
public AttributeChangeNotification(Object source, long sequenceNumber, long timeStamp, String msg, |
|
102 |
String attributeName, String attributeType, Object oldValue, Object newValue) { |
|
103 |
||
104 |
super(AttributeChangeNotification.ATTRIBUTE_CHANGE, source, sequenceNumber, timeStamp, msg); |
|
105 |
this.attributeName = attributeName; |
|
106 |
this.attributeType = attributeType; |
|
107 |
this.oldValue = oldValue; |
|
108 |
this.newValue = newValue; |
|
109 |
} |
|
110 |
||
111 |
||
112 |
/** |
|
113 |
* Gets the name of the attribute which has changed. |
|
114 |
* |
|
115 |
* @return A String containing the name of the attribute. |
|
116 |
*/ |
|
117 |
public String getAttributeName() { |
|
118 |
return attributeName; |
|
119 |
} |
|
120 |
||
121 |
/** |
|
122 |
* Gets the type of the attribute which has changed. |
|
123 |
* |
|
124 |
* @return A String containing the type of the attribute. |
|
125 |
*/ |
|
126 |
public String getAttributeType() { |
|
127 |
return attributeType; |
|
128 |
} |
|
129 |
||
130 |
/** |
|
131 |
* Gets the old value of the attribute which has changed. |
|
132 |
* |
|
133 |
* @return An Object containing the old value of the attribute. |
|
134 |
*/ |
|
135 |
public Object getOldValue() { |
|
136 |
return oldValue; |
|
137 |
} |
|
138 |
||
139 |
/** |
|
140 |
* Gets the new value of the attribute which has changed. |
|
141 |
* |
|
142 |
* @return An Object containing the new value of the attribute. |
|
143 |
*/ |
|
144 |
public Object getNewValue() { |
|
145 |
return newValue; |
|
146 |
} |
|
147 |
||
148 |
} |