DynamicMBean.java 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /* DynamicMBean.java -- A management bean with a dynamic interface.
  2. Copyright (C) 2006 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. * Represents a management bean that provides a
  34. * dynamic interface. Users of a {@link DynamicMBean}
  35. * may retrieve information about its attributes at
  36. * runtime and use this information to dynamically
  37. * obtain the corresponding values of these attributes.
  38. *
  39. * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
  40. * @since 1.5
  41. */
  42. public interface DynamicMBean
  43. {
  44. /**
  45. * Obtains the value of the specified attribute of the
  46. * management bean. The management bean should perform
  47. * a lookup for the named attribute, and return its value
  48. * by calling the appropriate getter method, if possible.
  49. *
  50. * @param name the name of the attribute to retrieve.
  51. * @return the value of the specified attribute.
  52. * @throws AttributeNotFoundException if the name does not
  53. * correspond to an attribute
  54. * of the bean.
  55. * @throws MBeanException if retrieving the attribute causes
  56. * the bean to throw an exception (which
  57. * becomes the cause of this exception).
  58. * @throws ReflectionException if an exception occurred in trying
  59. * to use the reflection interface
  60. * to lookup the attribute. The
  61. * thrown exception is the cause of
  62. * this exception.
  63. * @see #setAttribute(String)
  64. */
  65. Object getAttribute(String name)
  66. throws AttributeNotFoundException, MBeanException,
  67. ReflectionException;
  68. /**
  69. * Obtains the values of each of the specified attributes
  70. * of the management bean. The returned list includes
  71. * those attributes that were retrieved and their
  72. * corresponding values.
  73. *
  74. * @param names the names of the attributes to retrieve.
  75. * @return a list of the retrieved attributes.
  76. * @see #setAttributes(AttributeList)
  77. */
  78. AttributeList getAttributes(String[] names);
  79. /**
  80. * Returns an information object which lists the attributes
  81. * and actions associated with the management bean.
  82. *
  83. * @return a description of the management bean, including
  84. * all exposed attributes and actions.
  85. */
  86. MBeanInfo getMBeanInfo();
  87. /**
  88. * Invokes the specified action on the management bean using
  89. * the supplied parameters. The signature of the action is
  90. * specified by a {@link String} array, which lists the classes
  91. * corresponding to each parameter. The class loader used to
  92. * load these classes is the same as that used for loading the
  93. * management bean itself.
  94. *
  95. * @param name the name of the action to invoke.
  96. * @param params the parameters used to call the action.
  97. * @param signature the signature of the action.
  98. * @return the return value of the action.
  99. * @throws MBeanException if the action throws an exception. The
  100. * thrown exception is the cause of this
  101. * exception.
  102. * @throws ReflectionException if an exception occurred in trying
  103. * to use the reflection interface
  104. * to invoke the action. The
  105. * thrown exception is the cause of
  106. * this exception.
  107. */
  108. Object invoke(String name, Object[] params, String[] signature)
  109. throws MBeanException, ReflectionException;
  110. /**
  111. * Sets the value of the specified attribute of the
  112. * management bean. The management bean should perform
  113. * a lookup for the named attribute, and sets its value
  114. * using the associated setter method, if possible.
  115. *
  116. * @param attribute the attribute to set.
  117. * @throws AttributeNotFoundException if the attribute does not
  118. * correspond to an attribute
  119. * of the bean.
  120. * @throws InvalidAttributeValueException if the value is invalid
  121. * for this particular
  122. * attribute of the bean.
  123. * @throws MBeanException if setting the attribute causes
  124. * the bean to throw an exception (which
  125. * becomes the cause of this exception).
  126. * @throws ReflectionException if an exception occurred in trying
  127. * to use the reflection interface
  128. * to lookup the attribute. The
  129. * thrown exception is the cause of
  130. * this exception.
  131. * @see #getAttribute(String)
  132. */
  133. void setAttribute(Attribute attribute)
  134. throws AttributeNotFoundException, InvalidAttributeValueException,
  135. MBeanException, ReflectionException;
  136. /**
  137. * Sets the value of each of the specified attributes
  138. * to that supplied by the {@link Attribute} object.
  139. * The returned list contains the attributes that were
  140. * set and their new values.
  141. *
  142. * @param attributes the attributes to set.
  143. * @return a list of the changed attributes.
  144. * @see #getAttributes(AttributeList)
  145. */
  146. AttributeList setAttributes(AttributeList attributes);
  147. }