1. /*
  2. * @(#)MetaData.java 1.54 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.jmx.mbeanserver;
  8. import javax.management.* ;
  9. /**
  10. * The MetaData interface provides local to the metadata service in
  11. * an agent.
  12. *
  13. * @since 1.5
  14. * @since.unbundled JMX RI 1.2
  15. */
  16. public interface MetaData {
  17. /**
  18. * This methods tests if the MBean is JMX compliant
  19. */
  20. public void testCompliance(Class c) throws NotCompliantMBeanException;
  21. /**
  22. * Invokes the preRegister method of an MBean that implements
  23. * MBeanRegistration
  24. */
  25. public ObjectName preRegisterInvoker(Object moi, ObjectName name,
  26. MBeanServer mbs)
  27. throws InstanceAlreadyExistsException, MBeanRegistrationException;
  28. /**
  29. * Invokes the postRegister method of an MBean that implements
  30. * MBeanRegistration
  31. */
  32. public void postRegisterInvoker(Object moi, boolean registrationDone);
  33. /**
  34. * Invokes the preDeregister method of an MBean that implements
  35. * MBeanRegistration
  36. */
  37. public void preDeregisterInvoker(Object moi)
  38. throws MBeanRegistrationException;
  39. /**
  40. * Invokes the postDeregister method of an MBean that implements
  41. * MBeanRegistration
  42. */
  43. public void postDeregisterInvoker(Object moi);
  44. /**
  45. * This method discovers the attributes and operations that an MBean
  46. * exposes for management.
  47. *
  48. * @param instance The MBean whose class is to be analyzed.
  49. *
  50. * @return An instance of MBeanInfo allowing to retrieve all methods
  51. * and operations of this MBean.
  52. *
  53. * @exception IntrospectionException if an exception occurs during
  54. * introspection.
  55. *
  56. */
  57. public MBeanInfo getMBeanInfo(Object instance)
  58. throws IntrospectionException ;
  59. /**
  60. * This method returns the class name of an MBean.
  61. *
  62. * @param instance The MBean whose class is to be analyzed.
  63. *
  64. * @return The class name of the MBean, as registered in its MBeanInfo.
  65. *
  66. * @exception IntrospectionException if an exception occurs during
  67. * introspection.
  68. *
  69. */
  70. public String getMBeanClassName(Object instance)
  71. throws IntrospectionException, NotCompliantMBeanException ;
  72. /**
  73. * Gets the value of a specific attribute of an MBean.
  74. *
  75. * @param instance The MBean from which the attribute is to be retrieved.
  76. * @param attribute An String specifying the name of the attribute to be
  77. * retrieved.
  78. *
  79. * @return The value of the retrieved attribute.
  80. *
  81. * @exception AttributeNotFoundException The specified attribute is
  82. * not accessible in the MBean.
  83. * @exception MBeanException Wraps an exception thrown by the MBean's
  84. * getter.
  85. * @exception ReflectionException Wraps a java.lang.Exception thrown
  86. * while trying to invoke the getter.
  87. */
  88. public Object getAttribute(Object instance, String attribute)
  89. throws MBeanException, AttributeNotFoundException, ReflectionException;
  90. /**
  91. * Enables the values of several attributes of an MBean.
  92. *
  93. * @param instance The MBean from which the attributes are to be retrieved.
  94. * @param attributes A list of the attributes to be retrieved.
  95. *
  96. * @return The list of the retrieved attributes.
  97. *
  98. * @exception ReflectionException An exception occurred when trying to invoke the getAttributes method of a Dynamic MBean.
  99. *
  100. */
  101. public AttributeList getAttributes(Object instance, String[] attributes)
  102. throws ReflectionException ;
  103. /**
  104. * Sets the value of a specific attribute of an MBean.
  105. *
  106. * @param instance The MBean within which the attribute is to be set.
  107. * @param attribute The identification of the attribute to be set and
  108. * the value it is to be set to.
  109. *
  110. * @return The value of the attribute that has been set.
  111. *
  112. * @exception AttributeNotFoundException The specified attribute is
  113. * not accessible in the MBean.
  114. * @exception InvalidAttributeValueException The specified value for
  115. * the attribute is not valid.
  116. * @exception MBeanException Wraps an exception thrown by the MBean's
  117. * setter.
  118. * @exception ReflectionException Wraps a java.lang.Exception thrown
  119. * while trying to invoke the setter.
  120. */
  121. public Object setAttribute(Object instance, Attribute attribute)
  122. throws AttributeNotFoundException, InvalidAttributeValueException,
  123. MBeanException, ReflectionException;
  124. /**
  125. * Sets the values of several attributes of an MBean.
  126. *
  127. * @param instance The MBean within which the attributes are to be set.
  128. * @param attributes A list of attributes: The identification of the
  129. * attributes to be set and the values they are to be set to.
  130. *
  131. * @return The list of attributes that were set, with their new values.
  132. *
  133. * @exception ReflectionException An exception occurred when trying to
  134. * invoke the getAttributes method of a Dynamic MBean.
  135. *
  136. */
  137. public AttributeList setAttributes(Object instance,
  138. AttributeList attributes)
  139. throws ReflectionException;
  140. /**
  141. * Invokes an operation on an MBean.
  142. *
  143. * @param instance The MBean on which the method is to be invoked.
  144. * @param operationName The name of the operation to be invoked.
  145. * @param params An array containing the parameters to be set when the operation is
  146. * invoked
  147. * @param signature An array containing the signature of the operation. The class objects will
  148. * be loaded using the same class loader as the one used for loading the
  149. * MBean on which the operation was invoked.
  150. *
  151. * @return The object returned by the operation, which represents the result of
  152. * invoking the operation on the MBean specified.
  153. *
  154. * @exception MBeanException Wraps an exception thrown by the MBean's invoked method.
  155. * @exception ReflectionException Wraps a java.lang.Exception thrown while trying to invoke the method.
  156. */
  157. public Object invoke(Object instance, String operationName,
  158. Object params[],String signature[])
  159. throws MBeanException, ReflectionException;
  160. /**
  161. * Determine whether the given MBean is an instance of a given
  162. * class/interface.
  163. *
  164. * @param instance The MBean concerned.
  165. * @param className The name of the class or interface.
  166. * @return <code>true</code> if the MBean is an instance of the
  167. * given <code>class</code>, <code>false</code> otherwise.
  168. * @exception ReflectionException if
  169. **/
  170. public boolean isInstanceOf(Object instance, String className)
  171. throws ReflectionException;
  172. }