1. /*
  2. * @(#)file ModelMBean.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 ModelMBean extends
  54. DynamicMBean,
  55. PersistentMBean,
  56. ModelMBeanNotificationBroadcaster
  57. {
  58. /**
  59. * Initializes a ModelMBean object using ModelMBeanInfo passed in.
  60. * This method makes it possible to set a customized ModelMBeanInfo on
  61. * the ModelMBean as long as it is not registered with the MBeanServer.
  62. * <br>
  63. * Once the ModelMBean's ModelMBeanInfo (with Descriptors) are
  64. * customized and set on the ModelMBean, the ModelMBean can be
  65. * registered with the MBeanServer.
  66. * <P>
  67. * If the ModelMBean is currently registered, this method throws
  68. * a {@link javax.management.RuntimeOperationsException} wrapping an
  69. * {@link IllegalStateException}
  70. *
  71. * @param inModelMBeanInfo The ModelMBeanInfo object to be used
  72. * by the ModelMBean.
  73. *
  74. * @exception MBeanException Wraps a distributed communication
  75. * Exception.
  76. * @exception RuntimeOperationsException
  77. * <ul><li>Wraps an {@link IllegalArgumentException} if
  78. * the MBeanInfo passed in parameter is null.</li>
  79. * <li>Wraps an {@link IllegalStateException} if the ModelMBean
  80. * is currently registered in the MBeanServer.</li>
  81. * </ul>
  82. *
  83. **/
  84. public void setModelMBeanInfo(ModelMBeanInfo inModelMBeanInfo)
  85. throws MBeanException, RuntimeOperationsException;
  86. /**
  87. * Sets the instance handle of the object against which to
  88. * execute all methods in this ModelMBean management interface
  89. * (MBeanInfo and Descriptors).
  90. *
  91. * @param mr Object that is the managed resource
  92. * @param mr_type The type of reference for the managed resource. Can be: ObjectReference,
  93. * Handle, IOR, EJBHandle, RMIReference.
  94. * If the MBeanServer cannot process the mr_type passed in, an InvalidTargetTypeException
  95. * will be thrown.
  96. *
  97. *
  98. * @exception MBeanException The initializer of the object has thrown an exception.
  99. * @exception RuntimeOperationsException Wraps an IllegalArgumentException:
  100. * The managed resource type passed in parameter is null.
  101. * @exception InstanceNotFoundException The managed resource object could not be found
  102. * @exception InvalidTargetObjectTypeException The managed resource type cannot be processed by the
  103. * ModelMBean or JMX Agent.
  104. */
  105. public void setManagedResource(Object mr, String mr_type)
  106. throws MBeanException, RuntimeOperationsException,
  107. InstanceNotFoundException, InvalidTargetObjectTypeException ;
  108. }