AttributeChangeNotification.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* AttributeChangeNotification.java -- Notification for attribute changes
  2. Copyright (C) 2007 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package javax.management;
  32. /**
  33. * Defines the notification used to let listeners know of
  34. * an attribute change. The bean itself is responsible
  35. * for creating and transmitting the notification when the
  36. * attribute changes, by implementing
  37. * {@link NotificationBroadcaster}. For example, if a
  38. * bean increments the integer, <code>count</code>, it
  39. * should send a notification with the
  40. * <code>attributeName</code>, <code>"count"</code>,
  41. * the <code>attributeType</code>, <code>"Integer"</code>
  42. * and the old and new values of the attribute.
  43. *
  44. * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
  45. * @since 1.5
  46. */
  47. public class AttributeChangeNotification
  48. extends Notification
  49. {
  50. /**
  51. * Compatible with JDK 1.5
  52. */
  53. private static final long serialVersionUID = 535176054565814134L;
  54. /**
  55. * The attribute type for attribute change
  56. * notifications.
  57. */
  58. public static final String ATTRIBUTE_CHANGE = "jmx.attribute.change";
  59. /**
  60. * The name of the attribute that changed.
  61. */
  62. private String attributeName;
  63. /**
  64. * The type of the attribute that changed.
  65. */
  66. private String attributeType;
  67. /**
  68. * The old value of the attribute.
  69. */
  70. private Object oldValue;
  71. /**
  72. * The new value of the attribute.
  73. */
  74. private Object newValue;
  75. /**
  76. * Constructs a new {@link AttributeChangeNotification}
  77. * with the specified source, sequence number, timestamp,
  78. * message, and the attribute name, type, old value and
  79. * new value.
  80. *
  81. * @param source the producer of the notification, which
  82. * is usually the bean that changed the
  83. * attribute.
  84. * @param sequenceNumber the sequence number of the
  85. * notification.
  86. * @param timeStamp the date and time of the notification.
  87. * @param msg the message content of the notification.
  88. * @param name the name of the attribute.
  89. * @param type the type of the attribute.
  90. * @param oldVal the old value of the attribute.
  91. * @param newVal the new value of the attribute.
  92. */
  93. public AttributeChangeNotification(Object source,
  94. long sequenceNumber,
  95. long timeStamp,
  96. String msg, String name,
  97. String type, Object oldVal,
  98. Object newVal)
  99. {
  100. super(ATTRIBUTE_CHANGE, source, sequenceNumber,
  101. timeStamp, msg);
  102. attributeName = name;
  103. attributeType = type;
  104. oldValue = oldVal;
  105. newValue = newVal;
  106. }
  107. /**
  108. * Returns the name of the attribute that changed.
  109. *
  110. * @return the name of the attribute.
  111. */
  112. public String getAttributeName()
  113. {
  114. return attributeName;
  115. }
  116. /**
  117. * Returns the type of the attribute that changed.
  118. *
  119. * @return the type of the attribute.
  120. */
  121. public String getAttributeType()
  122. {
  123. return attributeType;
  124. }
  125. /**
  126. * Returns the old value of the attribute.
  127. *
  128. * @return the old value.
  129. */
  130. public Object getOldValue()
  131. {
  132. return oldValue;
  133. }
  134. /**
  135. * Returns the new value of the attribute.
  136. *
  137. * @return the new value.
  138. */
  139. public Object getNewValue()
  140. {
  141. return newValue;
  142. }
  143. }