1. /*
  2. * @(#)file ModelMBeanNotificationBroadcaster.java
  3. * @(#)author IBM Corp.
  4. * @(#)version 1.21
  5. * @(#)lastedit 04/02/10
  6. */
  7. /*
  8. * Copyright IBM Corp. 1999-2000. All rights reserved.
  9. *
  10. * The program is provided "as is" without any warranty express or implied,
  11. * including the warranty of non-infringement and the implied warranties of
  12. * merchantibility and fitness for a particular purpose. IBM will not be
  13. * liable for any damages suffered by you or any third party claim against
  14. * you regarding the Program.
  15. *
  16. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  17. * This software is the proprietary information of Sun Microsystems, Inc.
  18. * Use is subject to license terms.
  19. *
  20. * Copyright 2004 Sun Microsystems, Inc. Tous droits reserves.
  21. * Ce logiciel est propriete de Sun Microsystems, Inc.
  22. * Distribue par des licences qui en restreignent l'utilisation.
  23. *
  24. */
  25. package javax.management.modelmbean;
  26. import javax.management.*;
  27. import javax.management.InstanceNotFoundException;
  28. /**
  29. * This interface must be implemented by the ModelMBeans. An implementation of this interface
  30. * must be shipped with every JMX Agent.
  31. * <P>
  32. * Java resources wishing to be manageable instantiate the ModelMBean using the MBeanServer's
  33. * createMBean method. The resource then sets the ModelMBeanInfo (with Descriptors) for the ModelMBean
  34. * instance. The attributes and operations exposed via the ModelMBeanInfo for the ModelMBean are accessible
  35. * from MBeans, connectors/adaptors like other MBeans. Through the ModelMBeanInfo Descriptors, values and methods in
  36. * the managed application can be defined and mapped to attributes and operations of the ModelMBean.
  37. * This mapping can be defined during development in an XML formatted file or dynamically and
  38. * programmatically at runtime.
  39. * <P>
  40. * Every ModelMBean which is instantiated in the MBeanServer becomes manageable:
  41. * its attributes and operations
  42. * become remotely accessible through the connectors/adaptors connected to that MBeanServer.
  43. * A Java object cannot be registered in the MBeanServer unless it is a JMX compliant MBean.
  44. * By instantiating a ModelMBean, resources are guaranteed that the MBean is valid.
  45. * <P>
  46. * MBeanException and RuntimeOperationsException must be thrown on every public method. This allows
  47. * for wrapping exceptions from distributed communications (RMI, EJB, etc.). These exceptions do
  48. * not have to be thrown by the implementation except in the scenarios described in the specification
  49. * and javadoc.
  50. *
  51. * @since 1.5
  52. */
  53. public interface ModelMBeanNotificationBroadcaster extends NotificationBroadcaster
  54. {
  55. /**
  56. * Sends a Notification which is passed in to the registered
  57. * Notification listeners on the ModelMBean as a
  58. * jmx.modelmbean.generic notification.
  59. *
  60. * @param ntfyObj The notification which is to be passed to
  61. * the 'handleNotification' method of the listener object.
  62. *
  63. * @exception MBeanException Wraps a distributed communication Exception.
  64. * @exception RuntimeOperationsException Wraps an IllegalArgumentException:
  65. * The Notification object passed in parameter is null.
  66. *
  67. */
  68. public void sendNotification(Notification ntfyObj)
  69. throws MBeanException, RuntimeOperationsException;
  70. /**
  71. * Sends a Notification which contains the text string that is passed in
  72. * to the registered Notification listeners on the ModelMBean.
  73. *
  74. * @param ntfyText The text which is to be passed in the Notification to the 'handleNotification'
  75. * method of the listener object.
  76. * the constructed Notification will be:
  77. * type "jmx.modelmbean.generic"
  78. * source this ModelMBean instance
  79. * sequence 1
  80. *
  81. *
  82. * @exception MBeanException Wraps a distributed communication Exception.
  83. * @exception RuntimeOperationsException Wraps an IllegalArgumentException:
  84. * The Notification text string passed in parameter is null.
  85. *
  86. */
  87. public void sendNotification(String ntfyText)
  88. throws MBeanException, RuntimeOperationsException;
  89. /**
  90. * Sends an attributeChangeNotification which is passed in to
  91. * the registered attributeChangeNotification listeners on the
  92. * ModelMBean.
  93. *
  94. * @param notification The notification which is to be passed
  95. * to the 'handleNotification' method of the listener object.
  96. *
  97. * @exception MBeanException Wraps a distributed communication Exception.
  98. * @exception RuntimeOperationsException Wraps an IllegalArgumentException: The AttributeChangeNotification object passed in parameter is null.
  99. *
  100. */
  101. public void sendAttributeChangeNotification(AttributeChangeNotification notification)
  102. throws MBeanException, RuntimeOperationsException;
  103. /**
  104. * Sends an attributeChangeNotification which contains the old value and new value for the
  105. * attribute to the registered AttributeChangeNotification listeners on the ModelMBean.
  106. * <P>
  107. * @param oldValue The original value for the Attribute
  108. * @param newValue The current value for the Attribute
  109. *<P>
  110. * <PRE>
  111. * The constructed attributeChangeNotification will be:
  112. * type "jmx.attribute.change"
  113. * source this ModelMBean instance
  114. * sequence 1
  115. * attributeName oldValue.getName()
  116. * attributeType oldValue's class
  117. * attributeOldValue oldValue.getValue()
  118. * attributeNewValue newValue.getValue()
  119. * </PRE>
  120. *
  121. * @exception MBeanException Wraps a distributed communication Exception.
  122. * @exception RuntimeOperationsException Wraps an IllegalArgumentException: An Attribute object passed in parameter is null
  123. * or the names of the two Attribute objects in parameter are not the same.
  124. */
  125. public void sendAttributeChangeNotification(Attribute oldValue, Attribute newValue)
  126. throws MBeanException, RuntimeOperationsException;
  127. /**
  128. * Registers an object which implements the NotificationListener interface as a listener. This
  129. * object's 'handleNotification()' method will be invoked when any attributeChangeNotification is issued through
  130. * or by the ModelMBean. This does not include other Notifications. They must be registered
  131. * for independently. An AttributeChangeNotification will be generated for this attributeName.
  132. *
  133. * @param listener The listener object which will handles notifications emitted by the registered MBean.
  134. * @param attributeName The name of the ModelMBean attribute for which to receive change notifications.
  135. * If null, then all attribute changes will cause an attributeChangeNotification to be issued.
  136. * @param handback The context to be sent to the listener with the notification when a notification is emitted.
  137. *
  138. * @exception IllegalArgumentException The listener cannot be null.
  139. * @exception MBeanException Wraps a distributed communication Exception.
  140. * @exception RuntimeOperationsException Wraps an IllegalArgumentException The attribute name passed in parameter does not exist.
  141. *
  142. * @see #removeAttributeChangeNotificationListener
  143. */
  144. public void addAttributeChangeNotificationListener(NotificationListener listener,
  145. String attributeName,
  146. Object handback)
  147. throws MBeanException, RuntimeOperationsException, IllegalArgumentException;
  148. /**
  149. * Removes a listener for attributeChangeNotifications from the RequiredModelMBean.
  150. *
  151. * @param listener The listener name which was handling notifications emitted by the registered MBean.
  152. * This method will remove all information related to this listener.
  153. * @param attributeName The attribute for which the listener no longer wants to receive attributeChangeNotifications.
  154. * If null the listener will be removed for all attributeChangeNotifications.
  155. *
  156. * @exception ListenerNotFoundException The listener is not registered in the MBean or is null.
  157. * @exception MBeanException Wraps a distributed communication Exception.
  158. * @exception RuntimeOperationsException Wraps an IllegalArgumentException If the inAttributeName parameter does not
  159. * correspond to an attribute name.
  160. *
  161. * @see #addAttributeChangeNotificationListener
  162. */
  163. public void removeAttributeChangeNotificationListener(NotificationListener listener,
  164. String attributeName)
  165. throws MBeanException, RuntimeOperationsException, ListenerNotFoundException;
  166. }