1. /*
  2. * @(#)file ModelMBeanInfo.java
  3. * @(#)author IBM Corp.
  4. * @(#)version 1.24
  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.Descriptor;
  27. import javax.management.DescriptorAccess;
  28. import javax.management.*;
  29. import javax.management.RuntimeOperationsException;
  30. import javax.management.MBeanException;
  31. /**
  32. * This interface is implemented by the ModelMBeanInfo for every ModelMBean. An implementation of this interface
  33. * must be shipped with every JMX Agent.
  34. * <P>
  35. * Java resources wishing to be manageable instantiate the ModelMBean using the MBeanServer's
  36. * createMBean method. The resource then sets the ModelMBeanInfo and Descriptors for the ModelMBean
  37. * instance. The attributes, operations, and notifications exposed via the ModelMBeanInfo for the
  38. * ModelMBean comprise the management interface and are accessible
  39. * from MBeans, connectors/adaptors like other MBeans. Through the Descriptors, values and methods in
  40. * the managed application can be defined and mapped to attributes and operations of the ModelMBean.
  41. * This mapping can be defined during development in a file or dynamically and
  42. * programmatically at runtime.
  43. * <P>
  44. * Every ModelMBean which is instantiated in the MBeanServer becomes manageable:
  45. * its attributes, operations, and notifications
  46. * become remotely accessible through the connectors/adaptors connected to that MBeanServer.
  47. * A Java object cannot be registered in the MBeanServer unless it is a JMX compliant MBean.
  48. * By instantiating a ModelMBean, resources are guaranteed that the MBean is valid.
  49. *
  50. * MBeanException and RuntimeOperationsException must be thrown on every public method. This allows
  51. * for wrapping exceptions from distributed communications (RMI, EJB, etc.)
  52. *
  53. * @since 1.5
  54. */
  55. public interface ModelMBeanInfo
  56. {
  57. /**
  58. * Returns a Descriptor array consisting of all
  59. * Descriptors for the ModelMBeanInfo of type inDescriptorType.
  60. *
  61. * @param inDescriptorType value of descriptorType field that must be set for the descriptor
  62. * to be returned. Must be "mbean", "attribute", "operation", "constructor" or "notification".
  63. * If it is null or empty then all types will be returned.
  64. *
  65. * @return Descriptor array containing all descriptors for the ModelMBean if type inDescriptorType.
  66. *
  67. * @exception MBeanException Wraps a distributed communication Exception.
  68. * @exception RuntimeOperationsException Wraps an IllegalArgumentException when the descriptorType in parameter is
  69. * not one of: "mbean", "attribute", "operation", "constructor", "notification", empty or null.
  70. *
  71. * @see #setDescriptors
  72. */
  73. public Descriptor[] getDescriptors(String inDescriptorType)
  74. throws MBeanException, RuntimeOperationsException;
  75. /**
  76. * Adds or replaces descriptors in the ModelMBeanInfo.
  77. *
  78. * @param inDescriptors The descriptors to be set in the ModelMBeanInfo. Null
  79. * elements of the list will be ignored. All descriptors must have name and descriptorType fields.
  80. *
  81. * @exception RuntimeOperationsException Wraps an IllegalArgumentException for a null or invalid descriptor.
  82. * @exception MBeanException Wraps a distributed communication Exception.
  83. *
  84. * @see #getDescriptors
  85. */
  86. public void setDescriptors(Descriptor[] inDescriptors)
  87. throws MBeanException, RuntimeOperationsException;
  88. /**
  89. * Returns a Descriptor requested by name and descriptorType.
  90. *
  91. * @param inDescriptorName The name of the descriptor.
  92. * @param inDescriptorType The type of the descriptor being
  93. * requested. If this is null or empty then all types are
  94. * searched. Valid types are 'mbean', 'attribute', 'constructor'
  95. * 'operation', and 'notification'. This value will be equal to
  96. * the 'descriptorType' field in the descriptor that is returned.
  97. *
  98. * @return Descriptor containing the descriptor for the ModelMBean
  99. * with the same name and descriptorType. If no descriptor is
  100. * found, null is returned.
  101. *
  102. * @exception MBeanException Wraps a distributed communication Exception.
  103. * @exception RuntimeOperationsException Wraps an IllegalArgumentException for a null descriptor name or null or invalid type.
  104. * The type must be "mbean","attribute", "constructor", "operation", or "notification".
  105. *
  106. * @see #setDescriptor
  107. */
  108. public Descriptor getDescriptor(String inDescriptorName, String inDescriptorType)
  109. throws MBeanException, RuntimeOperationsException;
  110. /**
  111. * Sets descriptors in the info array of type inDescriptorType
  112. * for the ModelMBean. The setDescriptor method of the
  113. * corresponding ModelMBean*Info will be called to set the
  114. * specified descriptor.
  115. *
  116. * @param inDescriptor The descriptor to be set in the
  117. * ModelMBean. It must NOT be null. All descriptors must have
  118. * name and descriptorType fields.
  119. * @param inDescriptorType The type of the descriptor being
  120. * set. If this is null then the descriptorType field in the
  121. * descriptor is used. If specified this value must be set in
  122. * the descriptorType field in the descriptor. Must be
  123. * "mbean","attribute", "constructor", "operation", or
  124. * "notification".
  125. *
  126. * @exception RuntimeOperationsException Wraps an
  127. * IllegalArgumentException for illegal or null arguments or
  128. * if the name field of the descriptor is not found in the
  129. * corresponding MBeanAttributeInfo or MBeanConstructorInfo or
  130. * MBeanNotificationInfo or MBeanOperationInfo.
  131. * @exception MBeanException Wraps a distributed communication
  132. * Exception.
  133. *
  134. * @see #getDescriptor
  135. */
  136. public void setDescriptor(Descriptor inDescriptor, String inDescriptorType)
  137. throws MBeanException, RuntimeOperationsException;
  138. /**
  139. * Returns the ModelMBean's descriptor which contains MBean wide policies. This descriptor contains
  140. * metadata about the MBean and default policies for persistence and caching.
  141. * <P>
  142. * The fields in the descriptor are defined, but not limited to, the following:
  143. * <PRE>
  144. * name : MBean name
  145. * descriptorType : must be "mbean"
  146. * displayName : name of attribute to be used in displays
  147. * persistPolicy : OnUpdate|OnTimer|NoMoreOftenThan|Always|Never
  148. * persistLocation : The fully qualified directory name where the MBean should be persisted (if appropriate)
  149. * persistFile : File name into which the MBean should be persisted
  150. * persistPeriod : seconds - frequency of persist cycle for OnTime and NoMoreOftenThan PersistPolicy
  151. * currencyTimeLimit : how long value is valid, <0 never, =0 always, >0 seconds
  152. * log : where t: log all notifications f: log no notifications
  153. * logfile : fully qualified filename to log events to
  154. * visibility : 1-4 where 1: always visible 4: rarely visible
  155. * export : name to be used to export/expose this MBean so that it is findable by
  156. * other JMX Agents.
  157. * presentationString : xml formatted string to allow presentation of data to be associated with the MBean.
  158. * </PRE>
  159. * <P>
  160. * The default descriptor is: name=mbeanName,descriptorType=mbean, displayName=this.getClassName(),
  161. * persistPolicy=never,log=F,export=F,visibility=1
  162. * If the descriptor does not contain all these fields, they will be added with these default values.
  163. *
  164. * <p><b>Note:</b> because of inconsistencies in previous versions of
  165. * this specification, it is recommended not to use negative or zero
  166. * values for <code>currencyTimeLimit</code>. To indicate that a
  167. * cached value is never valid, omit the
  168. * <code>currencyTimeLimit</code> field. To indicate that it is
  169. * always valid, use a very large number for this field.</p>
  170. *
  171. * @return the MBean descriptor.
  172. *
  173. * @exception MBeanException Wraps a distributed communication
  174. * Exception.
  175. *
  176. * @exception RuntimeOperationsException a {@link
  177. * RuntimeException} occurred while getting the descriptor.
  178. *
  179. * @see #setMBeanDescriptor
  180. */
  181. public Descriptor getMBeanDescriptor()
  182. throws MBeanException, RuntimeOperationsException;
  183. /**
  184. * Sets the ModelMBean's descriptor. This descriptor contains default, MBean wide
  185. * metadata about the MBean and default policies for persistence and caching. This operation
  186. * does a complete replacement of the descriptor, no merging is done. If the descriptor to
  187. * set to is null then the default descriptor will be created.
  188. * The default descriptor is: name=mbeanName,descriptorType=mbean, displayName=this.getClassName(),
  189. * persistPolicy=never,log=F,export=F,visibility=1
  190. * If the descriptor does not contain all these fields, they will be added with these default values.
  191. *
  192. * See {@link #getMBeanDescriptor getMBeanDescriptor} method javadoc for description of valid field names.
  193. *
  194. * @param inDescriptor the descriptor to set.
  195. *
  196. * @exception MBeanException Wraps a distributed communication Exception.
  197. * @exception RuntimeOperationsException Wraps an IllegalArgumentException for invalid descriptor.
  198. *
  199. *
  200. * @see #getMBeanDescriptor
  201. */
  202. public void setMBeanDescriptor(Descriptor inDescriptor)
  203. throws MBeanException, RuntimeOperationsException;
  204. /**
  205. * Returns a ModelMBeanAttributeInfo requested by name.
  206. *
  207. * @param inName The name of the ModelMBeanAttributeInfo to get.
  208. * If no ModelMBeanAttributeInfo exists for this name null is returned.
  209. *
  210. * @return the attribute info for the named attribute, or null
  211. * if there is none.
  212. *
  213. * @exception MBeanException Wraps a distributed communication
  214. * Exception.
  215. * @exception RuntimeOperationsException Wraps an
  216. * IllegalArgumentException for a null attribute name.
  217. *
  218. */
  219. public ModelMBeanAttributeInfo getAttribute(String inName)
  220. throws MBeanException, RuntimeOperationsException;
  221. /**
  222. * Returns a ModelMBeanOperationInfo requested by name.
  223. *
  224. * @param inName The name of the ModelMBeanOperationInfo to get.
  225. * If no ModelMBeanOperationInfo exists for this name null is returned.
  226. *
  227. * @return the operation info for the named operation, or null
  228. * if there is none.
  229. *
  230. * @exception MBeanException Wraps a distributed communication Exception.
  231. * @exception RuntimeOperationsException Wraps an IllegalArgumentException for a null operation name.
  232. *
  233. */
  234. public ModelMBeanOperationInfo getOperation(String inName)
  235. throws MBeanException, RuntimeOperationsException;
  236. /**
  237. * Returns a ModelMBeanNotificationInfo requested by name.
  238. *
  239. * @param inName The name of the ModelMBeanNotificationInfo to get.
  240. * If no ModelMBeanNotificationInfo exists for this name null is returned.
  241. *
  242. * @return the info for the named notification, or null if there
  243. * is none.
  244. *
  245. * @exception MBeanException Wraps a distributed communication Exception.
  246. * @exception RuntimeOperationsException Wraps an IllegalArgumentException for a null notification name.
  247. *
  248. */
  249. public ModelMBeanNotificationInfo getNotification(String inName)
  250. throws MBeanException, RuntimeOperationsException;
  251. /**
  252. * Creates and returns a copy of this object.
  253. */
  254. public java.lang.Object clone();
  255. /**
  256. * Returns the list of attributes exposed for management.
  257. * Each attribute is described by an <CODE>MBeanAttributeInfo</CODE> object.
  258. *
  259. * @return An array of <CODE>MBeanAttributeInfo</CODE> objects.
  260. */
  261. public MBeanAttributeInfo[] getAttributes();
  262. /**
  263. * Returns the name of the Java class of the MBean described by
  264. * this <CODE>MBeanInfo</CODE>.
  265. *
  266. * @return the Java class name.
  267. */
  268. public java.lang.String getClassName();
  269. /**
  270. * Returns the list of the public constructors of the MBean.
  271. * Each constructor is described by an <CODE>MBeanConstructorInfo</CODE> object.
  272. *
  273. * @return An array of <CODE>MBeanConstructorInfo</CODE> objects.
  274. */
  275. public MBeanConstructorInfo[] getConstructors();
  276. /**
  277. * Returns a human readable description of the MBean.
  278. *
  279. * @return the description.
  280. */
  281. public java.lang.String getDescription();
  282. /**
  283. * Returns the list of the notifications emitted by the MBean.
  284. * Each notification is described by an <CODE>MBeanNotificationInfo</CODE> object.
  285. * <P>
  286. * In addition to any notification specified by the application,
  287. * a ModelMBean may always send also two additional notifications:
  288. * <UL>
  289. * <LI> One with descriptor name "GENERIC" and displayName "jmx.modelmbean.generic"
  290. * <LI> Second is a standard attribute change notification
  291. * with descriptor name "ATTRIBUTE_CHANGE" and displayName "jmx.attribute.change"
  292. * </UL>
  293. * Thus any implementation of ModelMBeanInfo should always add those two notifications
  294. * in addition to those specified by the application.
  295. *
  296. * @return An array of <CODE>MBeanNotificationInfo</CODE> objects.
  297. */
  298. public MBeanNotificationInfo[] getNotifications();
  299. /**
  300. * Returns the list of operations of the MBean.
  301. * Each operation is described by an <CODE>MBeanOperationInfo</CODE> object.
  302. *
  303. * @return An array of <CODE>MBeanOperationInfo</CODE> objects.
  304. */
  305. public MBeanOperationInfo[] getOperations();
  306. }