jdk/src/share/classes/javax/management/remote/JMXConnectorServerMBean.java
author emcmanus
Wed, 21 Oct 2009 17:33:18 +0200
changeset 4156 acaa49a2768a
parent 1570 4165709c91e3
child 5506 202f599c92aa
permissions -rw-r--r--
6851617: Remove JSR 255 (JMX API 2.0) from JDK 7 Summary: See http://weblogs.java.net/blog/2009/06/16/jsr-255-jmx-api-20-postponed Reviewed-by: dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1247
b4c26443dee5 6754988: Update copyright year
xdono
parents: 1004
diff changeset
     2
 * Copyright 2002-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
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
    /**
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   108
     * <p>Inserts an object that intercepts requests for the MBean server
2
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
     *
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   114
     * <p>This method can be called more than once with different
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   115
     * {@link MBeanServerForwarder} objects.  The result is a chain
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   116
     * of forwarders.  The last forwarder added is the first in the chain.
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   117
     * In more detail:</p>
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   118
     *
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   119
     * <ul>
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   120
     * <li><p>If this connector server is already associated with an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * <code>MBeanServer</code> object, then that object is given to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * {@link MBeanServerForwarder#setMBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * mbsf.setMBeanServer}.  If doing so produces an exception, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * method throws the same exception without any other effect.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   126
     * <li><p>If this connector is not already associated with an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * <code>MBeanServer</code> object, or if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * <code>mbsf.setMBeanServer</code> call just mentioned succeeds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * then <code>mbsf</code> becomes this connector server's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * <code>MBeanServer</code>.</p>
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   131
     * </ul>
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   132
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @param mbsf the new <code>MBeanServerForwarder</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @exception IllegalArgumentException if the call to {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * MBeanServerForwarder#setMBeanServer mbsf.setMBeanServer} fails
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * with <code>IllegalArgumentException</code>.  This includes the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * case where <code>mbsf</code> is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public void setMBeanServerForwarder(MBeanServerForwarder mbsf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * <p>The list of IDs for currently-open connections to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * connector server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @return a new string array containing the list of IDs.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * there are no currently-open connections, this array will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public String[] getConnectionIds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * <p>The address of this connector server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * The address returned may not be the exact original {@link JMXServiceURL}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * that was supplied when creating the connector server, since the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * address may not always be complete. For example the port number may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * dynamically allocated when starting the connector server. Instead the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * address returned is the actual {@link JMXServiceURL} of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * {@link JMXConnectorServer}. This is the address that clients supply
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * to {@link JMXConnectorFactory#connect(JMXServiceURL)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * <p>Note that the address returned may be {@code null} if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *    the {@code JMXConnectorServer} is not yet {@link #isActive active}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @return the address of this connector server, or null if it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * does not have one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public JMXServiceURL getAddress();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * <p>The attributes for this connector server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @return a read-only map containing the attributes for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * connector server.  Attributes whose values are not serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * are omitted from this map.  If there are no serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * attributes, the returned map is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public Map<String,?> getAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * <p>Returns a client stub for this connector server.  A client
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * stub is a serializable object whose {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * JMXConnector#connect(Map) connect} method can be used to make
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * one new connection to this connector server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * <p>A given connector need not support the generation of client
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * stubs.  However, the connectors specified by the JMX Remote API do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * (JMXMP Connector and RMI Connector).</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @param env client connection parameters of the same sort that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * can be provided to {@link JMXConnector#connect(Map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * JMXConnector.connect(Map)}.  Can be null, which is equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * to an empty map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @return a client stub that can be used to make a new connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * to this connector server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @exception UnsupportedOperationException if this connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * server does not support the generation of client stubs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @exception IllegalStateException if the JMXConnectorServer is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * not started (see {@link JMXConnectorServerMBean#isActive()}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @exception IOException if a communications problem means that a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * stub cannot be created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    public JMXConnector toJMXConnector(Map<String,?> env)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
}