1. /*
  2. * @(#)JMXConnectorServerMBean.java 1.25 04/05/05
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.management.remote;
  8. import java.io.IOException;
  9. import java.util.Map;
  10. import javax.management.MBeanServer;
  11. /**
  12. * <p>MBean interface for connector servers. A JMX API connector server
  13. * is attached to an MBean server, and establishes connections to that
  14. * MBean server for remote clients.</p>
  15. *
  16. * <p>A newly-created connector server is <em>inactive</em>, and does
  17. * not yet listen for connections. Only when its {@link #start start}
  18. * method has been called does it start listening for connections.</p>
  19. *
  20. * @since 1.5
  21. * @since.unbundled 1.0
  22. */
  23. public interface JMXConnectorServerMBean {
  24. /**
  25. * <p>Activates the connector server, that is, starts listening for
  26. * client connections. Calling this method when the connector
  27. * server is already active has no effect. Calling this method
  28. * when the connector server has been stopped will generate an
  29. * {@link IOException}.</p>
  30. *
  31. * @exception IOException if it is not possible to start listening
  32. * or if the connector server has been stopped.
  33. *
  34. * @exception IllegalStateException if the connector server has
  35. * not been attached to an MBean server.
  36. */
  37. public void start() throws IOException;
  38. /**
  39. * <p>Deactivates the connector server, that is, stops listening for
  40. * client connections. Calling this method will also close all
  41. * client connections that were made by this server. After this
  42. * method returns, whether normally or with an exception, the
  43. * connector server will not create any new client
  44. * connections.</p>
  45. *
  46. * <p>Once a connector server has been stopped, it cannot be started
  47. * again.</p>
  48. *
  49. * <p>Calling this method when the connector server has already
  50. * been stopped has no effect. Calling this method when the
  51. * connector server has not yet been started will disable the
  52. * connector server object permanently.</p>
  53. *
  54. * <p>If closing a client connection produces an exception, that
  55. * exception is not thrown from this method. A {@link
  56. * JMXConnectionNotification} with type {@link
  57. * JMXConnectionNotification#FAILED} is emitted from this MBean
  58. * with the connection ID of the connection that could not be
  59. * closed.</p>
  60. *
  61. * <p>Closing a connector server is a potentially slow operation.
  62. * For example, if a client machine with an open connection has
  63. * crashed, the close operation might have to wait for a network
  64. * protocol timeout. Callers that do not want to block in a close
  65. * operation should do it in a separate thread.</p>
  66. *
  67. * @exception IOException if the server cannot be closed cleanly.
  68. * When this exception is thrown, the server has already attempted
  69. * to close all client connections. All client connections are
  70. * closed except possibly those that generated exceptions when the
  71. * server attempted to close them.
  72. */
  73. public void stop() throws IOException;
  74. /**
  75. * <p>Determines whether the connector server is active. A connector
  76. * server starts being active when its {@link #start start} method
  77. * returns successfully and remains active until either its
  78. * {@link #stop stop} method is called or the connector server
  79. * fails.</p>
  80. *
  81. * @return true if the connector server is active.
  82. */
  83. public boolean isActive();
  84. /**
  85. * <p>Adds an object that intercepts requests for the MBean server
  86. * that arrive through this connector server. This object will be
  87. * supplied as the <code>MBeanServer</code> for any new connection
  88. * created by this connector server. Existing connections are
  89. * unaffected.</p>
  90. *
  91. * <p>If this connector server is already associated with an
  92. * <code>MBeanServer</code> object, then that object is given to
  93. * {@link MBeanServerForwarder#setMBeanServer
  94. * mbsf.setMBeanServer}. If doing so produces an exception, this
  95. * method throws the same exception without any other effect.</p>
  96. *
  97. * <p>If this connector is not already associated with an
  98. * <code>MBeanServer</code> object, or if the
  99. * <code>mbsf.setMBeanServer</code> call just mentioned succeeds,
  100. * then <code>mbsf</code> becomes this connector server's
  101. * <code>MBeanServer</code>.</p>
  102. *
  103. * @param mbsf the new <code>MBeanServerForwarder</code>.
  104. *
  105. * @exception IllegalArgumentException if the call to {@link
  106. * MBeanServerForwarder#setMBeanServer mbsf.setMBeanServer} fails
  107. * with <code>IllegalArgumentException</code>. This includes the
  108. * case where <code>mbsf</code> is null.
  109. */
  110. public void setMBeanServerForwarder(MBeanServerForwarder mbsf);
  111. /**
  112. * <p>The list of IDs for currently-open connections to this
  113. * connector server.</p>
  114. *
  115. * @return a new string array containing the list of IDs. If
  116. * there are no currently-open connections, this array will be
  117. * empty.
  118. */
  119. public String[] getConnectionIds();
  120. /**
  121. * <p>The address of this connector server.</p>
  122. *
  123. * @return the address of this connector server, or null if it
  124. * does not have one.
  125. */
  126. public JMXServiceURL getAddress();
  127. /**
  128. * <p>The attributes for this connector server.</p>
  129. *
  130. * @return a read-only map containing the attributes for this
  131. * connector server. Attributes whose values are not serializable
  132. * are omitted from this map. If there are no serializable
  133. * attributes, the returned map is empty.
  134. */
  135. public Map<String,?> getAttributes();
  136. /**
  137. * <p>Returns a client stub for this connector server. A client
  138. * stub is a serializable object whose {@link
  139. * JMXConnector#connect(Map) connect} method can be used to make
  140. * one new connection to this connector server.</p>
  141. *
  142. * <p>A given connector need not support the generation of client
  143. * stubs. However, the connectors specified by the JMX Remote API do
  144. * (JMXMP Connector and RMI Connector).</p>
  145. *
  146. * @param env client connection parameters of the same sort that
  147. * can be provided to {@link JMXConnector#connect(Map)
  148. * JMXConnector.connect(Map)}. Can be null, which is equivalent
  149. * to an empty map.
  150. *
  151. * @return a client stub that can be used to make a new connection
  152. * to this connector server.
  153. *
  154. * @exception UnsupportedOperationException if this connector
  155. * server does not support the generation of client stubs.
  156. *
  157. * @exception IllegalStateException if the JMXConnectorServer is
  158. * not started (see {@link JMXConnectorServerMBean#isActive()}).
  159. *
  160. * @exception IOException if a communications problem means that a
  161. * stub cannot be created.
  162. *
  163. */
  164. public JMXConnector toJMXConnector(Map<String,?> env)
  165. throws IOException;
  166. }