jdk/src/share/classes/javax/management/remote/JMXConnectorServerMBean.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 1004 5ba8217eb504
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2007 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
package javax.management.remote;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>MBean interface for connector servers.  A JMX API connector server
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * is attached to an MBean server, and establishes connections to that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * MBean server for remote clients.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <p>A newly-created connector server is <em>inactive</em>, and does
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * not yet listen for connections.  Only when its {@link #start start}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * method has been called does it start listening for connections.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
public interface JMXConnectorServerMBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * <p>Activates the connector server, that is, starts listening for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * client connections.  Calling this method when the connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * server is already active has no effect.  Calling this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * when the connector server has been stopped will generate an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * {@link IOException}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * @exception IOException if it is not possible to start listening
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * or if the connector server has been stopped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * @exception IllegalStateException if the connector server has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * not been attached to an MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    public void start() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * <p>Deactivates the connector server, that is, stops listening for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * client connections.  Calling this method will also close all
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * client connections that were made by this server.  After this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * method returns, whether normally or with an exception, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * connector server will not create any new client
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * connections.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * <p>Once a connector server has been stopped, it cannot be started
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * again.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * <p>Calling this method when the connector server has already
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * been stopped has no effect.  Calling this method when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * connector server has not yet been started will disable the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * connector server object permanently.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * <p>If closing a client connection produces an exception, that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * exception is not thrown from this method.  A {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * JMXConnectionNotification} with type {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * JMXConnectionNotification#FAILED} is emitted from this MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * with the connection ID of the connection that could not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * closed.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * <p>Closing a connector server is a potentially slow operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * For example, if a client machine with an open connection has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * crashed, the close operation might have to wait for a network
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * protocol timeout.  Callers that do not want to block in a close
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * operation should do it in a separate thread.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @exception IOException if the server cannot be closed cleanly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * When this exception is thrown, the server has already attempted
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * to close all client connections.  All client connections are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * closed except possibly those that generated exceptions when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * server attempted to close them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public void stop() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * <p>Determines whether the connector server is active.  A connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * server starts being active when its {@link #start start} method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * returns successfully and remains active until either its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * {@link #stop stop} method is called or the connector server
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * fails.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @return true if the connector server is active.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public boolean isActive();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * <p>Adds an object that intercepts requests for the MBean server
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * that arrive through this connector server.  This object will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * supplied as the <code>MBeanServer</code> for any new connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * created by this connector server.  Existing connections are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * unaffected.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * <p>If this connector server is already associated with an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * <code>MBeanServer</code> object, then that object is given to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * {@link MBeanServerForwarder#setMBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * mbsf.setMBeanServer}.  If doing so produces an exception, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * method throws the same exception without any other effect.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * <p>If this connector is not already associated with an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * <code>MBeanServer</code> object, or if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * <code>mbsf.setMBeanServer</code> call just mentioned succeeds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * then <code>mbsf</code> becomes this connector server's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * <code>MBeanServer</code>.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param mbsf the new <code>MBeanServerForwarder</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @exception IllegalArgumentException if the call to {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * MBeanServerForwarder#setMBeanServer mbsf.setMBeanServer} fails
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * with <code>IllegalArgumentException</code>.  This includes the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * case where <code>mbsf</code> is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    public void setMBeanServerForwarder(MBeanServerForwarder mbsf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * <p>The list of IDs for currently-open connections to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * connector server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @return a new string array containing the list of IDs.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * there are no currently-open connections, this array will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public String[] getConnectionIds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * <p>The address of this connector server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * The address returned may not be the exact original {@link JMXServiceURL}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * that was supplied when creating the connector server, since the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * address may not always be complete. For example the port number may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * dynamically allocated when starting the connector server. Instead the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * address returned is the actual {@link JMXServiceURL} of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * {@link JMXConnectorServer}. This is the address that clients supply
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * to {@link JMXConnectorFactory#connect(JMXServiceURL)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * <p>Note that the address returned may be {@code null} if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *    the {@code JMXConnectorServer} is not yet {@link #isActive active}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @return the address of this connector server, or null if it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * does not have one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public JMXServiceURL getAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * <p>The attributes for this connector server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @return a read-only map containing the attributes for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * connector server.  Attributes whose values are not serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * are omitted from this map.  If there are no serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * attributes, the returned map is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public Map<String,?> getAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * <p>Returns a client stub for this connector server.  A client
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * stub is a serializable object whose {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * JMXConnector#connect(Map) connect} method can be used to make
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * one new connection to this connector server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * <p>A given connector need not support the generation of client
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * stubs.  However, the connectors specified by the JMX Remote API do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * (JMXMP Connector and RMI Connector).</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @param env client connection parameters of the same sort that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * can be provided to {@link JMXConnector#connect(Map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * JMXConnector.connect(Map)}.  Can be null, which is equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * to an empty map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @return a client stub that can be used to make a new connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * to this connector server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @exception UnsupportedOperationException if this connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * server does not support the generation of client stubs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @exception IllegalStateException if the JMXConnectorServer is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * not started (see {@link JMXConnectorServerMBean#isActive()}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * @exception IOException if a communications problem means that a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * stub cannot be created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public JMXConnector toJMXConnector(Map<String,?> env)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
}