src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnectorServer.java
author jwilhelm
Thu, 14 Sep 2017 22:57:36 +0200
changeset 47425 96179f26139e
parent 47216 71c04702a3d5
child 47872 49e605998d2b
permissions -rw-r--r--
8187556: Backout of a fix reintroduced a dependency that had since been removed Reviewed-by: duke
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
37584
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 32639
diff changeset
     2
 * Copyright (c) 2002, 2016, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4167
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4167
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4167
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4167
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4167
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.management.remote.rmi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import com.sun.jmx.remote.security.MBeanServerFileAccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import com.sun.jmx.remote.util.ClassLogger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import com.sun.jmx.remote.util.EnvHelp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.ByteArrayOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.io.IOException;
47425
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
    35
import java.io.ObjectInputFilter;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.net.MalformedURLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.rmi.server.RMIClientSocketFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.rmi.server.RMIServerSocketFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.util.HashSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import javax.management.InstanceNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import javax.management.MBeanServer;
37584
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 32639
diff changeset
    49
import javax.management.remote.JMXAuthenticator;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import javax.management.remote.JMXConnectionNotification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import javax.management.remote.JMXConnector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import javax.management.remote.JMXConnectorServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import javax.management.remote.JMXServiceURL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import javax.management.remote.MBeanServerForwarder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import javax.naming.InitialContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import javax.naming.NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <p>A JMX API connector server that creates RMI-based connections
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * from remote clients.  Usually, such connector servers are made
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * using {@link javax.management.remote.JMXConnectorServerFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * JMXConnectorServerFactory}.  However, specialized applications can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * use this class directly, for example with an {@link RMIServerImpl}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * object.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
public class RMIConnectorServer extends JMXConnectorServer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * <p>Name of the attribute that specifies whether the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * RMIServer} stub that represents an RMI connector server should
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * override an existing stub at the same address.  The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * associated with this attribute, if any, should be a string that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * is equal, ignoring case, to <code>"true"</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * <code>"false"</code>.  The default value is false.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public static final String JNDI_REBIND_ATTRIBUTE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        "jmx.remote.jndi.rebind";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * <p>Name of the attribute that specifies the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * RMIClientSocketFactory} for the RMI objects created in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * conjunction with this connector. The value associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * attribute must be of type <code>RMIClientSocketFactory</code> and can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * only be specified in the <code>Map</code> argument supplied when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * creating a connector server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public static final String RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        "jmx.remote.rmi.client.socket.factory";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * <p>Name of the attribute that specifies the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * RMIServerSocketFactory} for the RMI objects created in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * conjunction with this connector. The value associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * attribute must be of type <code>RMIServerSocketFactory</code> and can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * only be specified in the <code>Map</code> argument supplied when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * creating a connector server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public static final String RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        "jmx.remote.rmi.server.socket.factory";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
47425
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   105
    * Name of the attribute that specifies an
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   106
    * {@link ObjectInputFilter} pattern string to filter classes acceptable
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   107
    * for {@link RMIServer#newClient(java.lang.Object) RMIServer.newClient()}
37584
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 32639
diff changeset
   108
    * remote method call.
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 32639
diff changeset
   109
    * <p>
47425
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   110
    * The filter pattern must be in same format as used in
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   111
    * {@link java.io.ObjectInputFilter.Config#createFilter}
37584
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 32639
diff changeset
   112
    * <p>
47425
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   113
    * This list of classes allowed by filter should correspond to the
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   114
    * transitive closure of the credentials class (or classes) used by the
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   115
    * installed {@linkplain JMXAuthenticator} associated with the
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   116
    * {@linkplain RMIServer} implementation.
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   117
    * If the attribute is not set then any class is deemed acceptable.
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   118
    * @see ObjectInputFilter
37584
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 32639
diff changeset
   119
    */
47425
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   120
    public static final String CREDENTIALS_FILTER_PATTERN =
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   121
        "jmx.remote.rmi.server.credentials.filter.pattern";
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   122
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   123
    /**
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   124
     * This attribute defines a pattern from which to create a
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   125
     * {@link java.io.ObjectInputFilter} that will be used when deserializing
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   126
     * objects sent to the {@code JMXConnectorServer} by any client.
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   127
     * <p>
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   128
     * The filter will be called for any class found in the serialized
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   129
     * stream sent to server by client, including all JMX defined classes
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   130
     * (such as {@link javax.management.ObjectName}), all method parameters,
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   131
     * and, if present in the stream, all classes transitively referred by
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   132
     * the serial form of any deserialized object.
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   133
     * The pattern must be in same format as used in
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   134
     * {@link java.io.ObjectInputFilter.Config#createFilter}.
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   135
     * It may define a white list of permitted classes, a black list of
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   136
     * rejected classes, a maximum depth for the deserialized objects,
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   137
     * etc.
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   138
     * <p>
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   139
     * To be functional, the filter should allow at least all the
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   140
     * concrete types in the transitive closure of all objects that
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   141
     * might get serialized when serializing all JMX classes referred
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   142
     * as parameters in the {@link
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   143
     * javax.management.remote.rmi.RMIConnection} interface,
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   144
     * plus all classes that a {@link javax.management.remote.rmi.RMIConnector client}
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   145
     * might need to transmit wrapped in {@linkplain java.rmi.MarshalledObject
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   146
     * marshalled objects} in order to interoperate with the MBeans registered
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   147
     * in the {@code MBeanServer}. That would potentially include all the
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   148
     * concrete {@linkplain javax.management.openmbean  JMX OpenTypes} and the
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   149
     * classes they use in their serial form.
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   150
     * <p>
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   151
     * Care must be taken when defining such a filter, as defining
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   152
     * a white list too restrictive or a too wide a black list may
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   153
     * prevent legitimate clients from interoperating with the
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   154
     * {@code JMXConnectorServer}.
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   155
     */
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   156
    public static final String SERIAL_FILTER_PATTERN =
96179f26139e 8187556: Backout of a fix reintroduced a dependency that had since been removed
jwilhelm
parents: 47216
diff changeset
   157
       "jmx.remote.rmi.server.serial.filter.pattern";
37584
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 32639
diff changeset
   158
0cc00d7a0755 8144430: Improve JMX connections
sjiang
parents: 32639
diff changeset
   159
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * <p>Makes an <code>RMIConnectorServer</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * This is equivalent to calling {@link #RMIConnectorServer(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * JMXServiceURL,Map,RMIServerImpl,MBeanServer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * RMIConnectorServer(directoryURL,environment,null,null)}</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @param url the URL defining how to create the connector server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * Cannot be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @param environment attributes governing the creation and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * storing of the RMI object.  Can be null, which is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * an empty Map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @exception IllegalArgumentException if <code>url</code> is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @exception MalformedURLException if <code>url</code> does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * conform to the syntax for an RMI connector, or if its protocol
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   176
     * is not recognized by this implementation. Only "rmi" is valid when
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   177
     * this constructor is used.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @exception IOException if the connector server cannot be created
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * for some reason or if it is inevitable that its {@link #start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * start} method will fail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    public RMIConnectorServer(JMXServiceURL url, Map<String,?> environment)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        this(url, environment, (MBeanServer) null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * <p>Makes an <code>RMIConnectorServer</code> for the given MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * This is equivalent to calling {@link #RMIConnectorServer(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * JMXServiceURL,Map,RMIServerImpl,MBeanServer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * RMIConnectorServer(directoryURL,environment,null,mbeanServer)}</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @param url the URL defining how to create the connector server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Cannot be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @param environment attributes governing the creation and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * storing of the RMI object.  Can be null, which is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * an empty Map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @param mbeanServer the MBean server to which the new connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * server is attached, or null if it will be attached by being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * registered as an MBean in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @exception IllegalArgumentException if <code>url</code> is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @exception MalformedURLException if <code>url</code> does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * conform to the syntax for an RMI connector, or if its protocol
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   210
     * is not recognized by this implementation. Only "rmi" is valid
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   211
     * when this constructor is used.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @exception IOException if the connector server cannot be created
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * for some reason or if it is inevitable that its {@link #start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * start} method will fail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public RMIConnectorServer(JMXServiceURL url, Map<String,?> environment,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                              MBeanServer mbeanServer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        this(url, environment, (RMIServerImpl) null, mbeanServer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * <p>Makes an <code>RMIConnectorServer</code> for the given MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @param url the URL defining how to create the connector server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * Cannot be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @param environment attributes governing the creation and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * storing of the RMI object.  Can be null, which is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * an empty Map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @param rmiServerImpl An implementation of the RMIServer interface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *  consistent with the protocol type specified in <var>url</var>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *  If this parameter is non null, the protocol type specified by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *  <var>url</var> is not constrained, and is assumed to be valid.
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   238
     *  Otherwise, only "rmi" will be recognized.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @param mbeanServer the MBean server to which the new connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * server is attached, or null if it will be attached by being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * registered as an MBean in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @exception IllegalArgumentException if <code>url</code> is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @exception MalformedURLException if <code>url</code> does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * conform to the syntax for an RMI connector, or if its protocol
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   248
     * is not recognized by this implementation. Only "rmi" is recognized
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   249
     * when <var>rmiServerImpl</var> is null.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @exception IOException if the connector server cannot be created
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * for some reason or if it is inevitable that its {@link #start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * start} method will fail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @see #start
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    public RMIConnectorServer(JMXServiceURL url, Map<String,?> environment,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                              RMIServerImpl rmiServerImpl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                              MBeanServer mbeanServer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        super(mbeanServer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        if (url == null) throw new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            IllegalArgumentException("Null JMXServiceURL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        if (rmiServerImpl == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            final String prt = url.getProtocol();
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   267
            if (prt == null || !(prt.equals("rmi"))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                final String msg = "Invalid protocol type: " + prt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                throw new MalformedURLException(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            final String urlPath = url.getURLPath();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            if (!urlPath.equals("")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                && !urlPath.equals("/")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                && !urlPath.startsWith("/jndi/")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                final String msg = "URL path must be empty or start with " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                    "/jndi/";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                throw new MalformedURLException(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        if (environment == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            this.attributes = Collections.emptyMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            EnvHelp.checkAttributes(environment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            this.attributes = Collections.unmodifiableMap(environment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        this.address = url;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        this.rmiServerImpl = rmiServerImpl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * <p>Returns a client stub for this connector server.  A client
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * stub is a serializable object whose {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * JMXConnector#connect(Map) connect} method can be used to make
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * one new connection to this connector server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @param env client connection parameters of the same sort that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * could be provided to {@link JMXConnector#connect(Map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * JMXConnector.connect(Map)}.  Can be null, which is equivalent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * to an empty map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @return a client stub that can be used to make a new connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * to this connector server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @exception UnsupportedOperationException if this connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * server does not support the generation of client stubs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @exception IllegalStateException if the JMXConnectorServer is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * not started (see {@link #isActive()}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * @exception IOException if a communications problem means that a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * stub cannot be created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    public JMXConnector toJMXConnector(Map<String,?> env) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        // The serialized for of rmiServerImpl is automatically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        // a RMI server stub.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        if (!isActive()) throw new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            IllegalStateException("Connector is not active");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        // Merge maps
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        Map<String, Object> usemap = new HashMap<String, Object>(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                (this.attributes==null)?Collections.<String, Object>emptyMap():
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                    this.attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        if (env != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            EnvHelp.checkAttributes(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            usemap.putAll(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        usemap = EnvHelp.filterAttributes(usemap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        final RMIServer stub=(RMIServer)rmiServerImpl.toStub();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        return new RMIConnector(stub, usemap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * <p>Activates the connector server, that is starts listening for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * client connections.  Calling this method when the connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * server is already active has no effect.  Calling this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * when the connector server has been stopped will generate an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * <code>IOException</code>.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * <p>The behavior of this method when called for the first time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * depends on the parameters that were supplied at construction,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * as described below.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * <p>First, an object of a subclass of {@link RMIServerImpl} is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * required, to export the connector server through RMI:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * <li>If an <code>RMIServerImpl</code> was supplied to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * constructor, it is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * <li>Otherwise, if the <code>JMXServiceURL</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * was null, or its protocol part was <code>rmi</code>, an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * of type {@link RMIJRMPServerImpl} is created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * <li>Otherwise, the implementation can create an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * implementation-specific {@link RMIServerImpl} or it can throw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * {@link MalformedURLException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * <p>If the given address includes a JNDI directory URL as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * specified in the package documentation for {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * javax.management.remote.rmi}, then this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * <code>RMIConnectorServer</code> will bootstrap by binding the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * <code>RMIServerImpl</code> to the given address.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * <p>If the URL path part of the <code>JMXServiceURL</code> was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * empty or a single slash (<code>/</code>), then the RMI object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * will not be bound to a directory.  Instead, a reference to it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * will be encoded in the URL path of the RMIConnectorServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * address (returned by {@link #getAddress()}).  The encodings for
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   378
     * <code>rmi</code> are described in the package documentation for
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   379
     * {@link javax.management.remote.rmi}.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * <p>The behavior when the URL path is neither empty nor a JNDI
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   382
     * directory URL, or when the protocol is not <code>rmi</code>,
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   383
     * is implementation defined, and may include throwing
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   384
     * {@link MalformedURLException} when the connector server is created
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   385
     * or when it is started.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @exception IllegalStateException if the connector server has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * not been attached to an MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @exception IOException if the connector server cannot be
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   390
     * started.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    public synchronized void start() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        final boolean tracing = logger.traceOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        if (state == STARTED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            if (tracing) logger.trace("start", "already started");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        } else if (state == STOPPED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            if (tracing) logger.trace("start", "already stopped");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            throw new IOException("The server has been stopped.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        if (getMBeanServer() == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            throw new IllegalStateException("This connector server is not " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                                            "attached to an MBean server");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        // Check the internal access file property to see
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        // if an MBeanServerForwarder is to be provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        if (attributes != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            // Check if access file property is specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            String accessFile =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                (String) attributes.get("jmx.remote.x.access.file");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            if (accessFile != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                // Access file property specified, create an instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                // of the MBeanServerFileAccessController class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                //
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
   419
                MBeanServerForwarder mbsf;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                    mbsf = new MBeanServerFileAccessController(accessFile);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                    throw EnvHelp.initCause(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                        new IllegalArgumentException(e.getMessage()), e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                // Set the MBeanServerForwarder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                setMBeanServerForwarder(mbsf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            if (tracing) logger.trace("start", "setting default class loader");
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
   434
            defaultClassLoader = EnvHelp.resolveServerClassLoader(
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1708
diff changeset
   435
                    attributes, getMBeanServer());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        } catch (InstanceNotFoundException infc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            IllegalArgumentException x = new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                IllegalArgumentException("ClassLoader not found: "+infc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            throw EnvHelp.initCause(x,infc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        if (tracing) logger.trace("start", "setting RMIServer object");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        final RMIServerImpl rmiServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        if (rmiServerImpl != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            rmiServer = rmiServerImpl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            rmiServer = newServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1708
diff changeset
   450
        rmiServer.setMBeanServer(getMBeanServer());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        rmiServer.setDefaultClassLoader(defaultClassLoader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        rmiServer.setRMIConnectorServer(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        rmiServer.export();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            if (tracing) logger.trace("start", "getting RMIServer object to export");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            final RMIServer objref = objectToBind(rmiServer, attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            if (address != null && address.getURLPath().startsWith("/jndi/")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                final String jndiUrl = address.getURLPath().substring(6);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                if (tracing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                    logger.trace("start", "Using external directory: " + jndiUrl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
14210
042f1a001234 7158796: Tighten properties checking in EnvHelp
dsamersoff
parents: 5506
diff changeset
   465
                String stringBoolean = (String) attributes.get(JNDI_REBIND_ATTRIBUTE);
042f1a001234 7158796: Tighten properties checking in EnvHelp
dsamersoff
parents: 5506
diff changeset
   466
                final boolean rebind = EnvHelp.computeBooleanFromString( stringBoolean );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                if (tracing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                    logger.trace("start", JNDI_REBIND_ATTRIBUTE + "=" + rebind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                    if (tracing) logger.trace("start", "binding to " + jndiUrl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1004
diff changeset
   474
                    final Hashtable<?, ?> usemap = EnvHelp.mapToHashtable(attributes);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                    bind(jndiUrl, usemap, objref, rebind);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                    boundJndiUrl = jndiUrl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                    // fit e in the nested exception if we are on 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                    throw newIOException("Cannot bind to URL ["+jndiUrl+"]: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                                         + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                // if jndiURL is null, we must encode the stub into the URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                if (tracing) logger.trace("start", "Encoding URL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                encodeStubInAddress(objref, attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                if (tracing) logger.trace("start", "Encoded URL: " + this.address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                rmiServer.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            } catch (Exception x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                // OK: we are already throwing another exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            if (e instanceof RuntimeException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                throw (RuntimeException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            else if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                throw newIOException("Got unexpected exception while " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                                     "starting the connector server: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                                     + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        rmiServerImpl = rmiServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        synchronized(openedServers) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            openedServers.add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        state = STARTED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        if (tracing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            logger.trace("start", "Connector Server Address = " + address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            logger.trace("start", "started.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * <p>Deactivates the connector server, that is, stops listening for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * client connections.  Calling this method will also close all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * client connections that were made by this server.  After this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * method returns, whether normally or with an exception, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * connector server will not create any new client
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * connections.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * <p>Once a connector server has been stopped, it cannot be started
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * again.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * <p>Calling this method when the connector server has already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * been stopped has no effect.  Calling this method when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * connector server has not yet been started will disable the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * connector server object permanently.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * <p>If closing a client connection produces an exception, that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * exception is not thrown from this method.  A {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * JMXConnectionNotification} is emitted from this MBean with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * connection ID of the connection that could not be closed.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * <p>Closing a connector server is a potentially slow operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * For example, if a client machine with an open connection has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * crashed, the close operation might have to wait for a network
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * protocol timeout.  Callers that do not want to block in a close
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * operation should do it in a separate thread.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * <p>This method calls the method {@link RMIServerImpl#close()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * close} on the connector server's <code>RMIServerImpl</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * object.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * <p>If the <code>RMIServerImpl</code> was bound to a JNDI
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * directory by the {@link #start() start} method, it is unbound
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * from the directory by this method.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @exception IOException if the server cannot be closed cleanly,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * or if the <code>RMIServerImpl</code> cannot be unbound from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * directory.  When this exception is thrown, the server has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * already attempted to close all client connections, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * appropriate; to call {@link RMIServerImpl#close()}; and to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * unbind the <code>RMIServerImpl</code> from its directory, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * appropriate.  All client connections are closed except possibly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * those that generated exceptions when the server attempted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * close them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    public void stop() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        final boolean tracing = logger.traceOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            if (state == STOPPED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                if (tracing) logger.trace("stop","already stopped.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            } else if (state == CREATED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                if (tracing) logger.trace("stop","not started yet.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
            if (tracing) logger.trace("stop", "stopping.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            state = STOPPED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        synchronized(openedServers) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            openedServers.remove(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        IOException exception = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        // rmiServerImpl can be null if stop() called without start()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        if (rmiServerImpl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                if (tracing) logger.trace("stop", "closing RMI server.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                rmiServerImpl.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                if (tracing) logger.trace("stop", "failed to close RMI server: " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                if (logger.debugOn()) logger.debug("stop",e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                exception = e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        if (boundJndiUrl != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                if (tracing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                    logger.trace("stop",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                          "unbind from external directory: " + boundJndiUrl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1004
diff changeset
   606
                final Hashtable<?, ?> usemap = EnvHelp.mapToHashtable(attributes);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                InitialContext ctx =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                    new InitialContext(usemap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                ctx.unbind(boundJndiUrl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                ctx.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                if (tracing) logger.trace("stop", "failed to unbind RMI server: "+e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                if (logger.debugOn()) logger.debug("stop",e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                // fit e in as the nested exception if we are on 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                if (exception == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                    exception = newIOException("Cannot bind to URL: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        if (exception != null) throw exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        if (tracing) logger.trace("stop", "stopped");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    public synchronized boolean isActive() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        return (state == STARTED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    public JMXServiceURL getAddress() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        if (!isActive())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        return address;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    public Map<String,?> getAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        Map<String, ?> map = EnvHelp.filterAttributes(attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        return Collections.unmodifiableMap(map);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
   643
    @Override
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1708
diff changeset
   644
    public synchronized
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1708
diff changeset
   645
        void setMBeanServerForwarder(MBeanServerForwarder mbsf) {
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1708
diff changeset
   646
        super.setMBeanServerForwarder(mbsf);
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1708
diff changeset
   647
        if (rmiServerImpl != null)
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1708
diff changeset
   648
            rmiServerImpl.setMBeanServer(getMBeanServer());
1708
4e1939e6e6b5 6332907: Add ability for connector server to close individual connections
sjiang
parents: 1570
diff changeset
   649
    }
4e1939e6e6b5 6332907: Add ability for connector server to close individual connections
sjiang
parents: 1570
diff changeset
   650
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    /* We repeat the definitions of connection{Opened,Closed,Failed}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
       here so that they are accessible to other classes in this package
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
       even though they have protected access.  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   655
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    protected void connectionOpened(String connectionId, String message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                                    Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        super.connectionOpened(connectionId, message, userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   661
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    protected void connectionClosed(String connectionId, String message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                                    Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        super.connectionClosed(connectionId, message, userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   667
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    protected void connectionFailed(String connectionId, String message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                                    Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        super.connectionFailed(connectionId, message, userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * Bind a stub to a registry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * @param jndiUrl URL of the stub in the registry, extracted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     *        from the <code>JMXServiceURL</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * @param attributes A Hashtable containing environment parameters,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     *        built from the Map specified at this object creation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * @param rmiServer The object to bind in the registry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * @param rebind true if the object must be rebound.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     **/
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1004
diff changeset
   682
    void bind(String jndiUrl, Hashtable<?, ?> attributes,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
              RMIServer rmiServer, boolean rebind)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        throws NamingException, MalformedURLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
        // if jndiURL is not null, we nust bind the stub to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        // directory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        InitialContext ctx =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            new InitialContext(attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        if (rebind)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
            ctx.rebind(jndiUrl, rmiServer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
            ctx.bind(jndiUrl, rmiServer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        ctx.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * Creates a new RMIServerImpl.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    RMIServerImpl newServer() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        final int port;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        if (address == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
            port = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
            port = address.getPort();
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   706
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   707
        return newJRMPServer(attributes, port);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * Encode a stub into the JMXServiceURL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * @param rmiServer The stub object to encode in the URL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * @param attributes A Map containing environment parameters,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     *        built from the Map specified at this object creation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     **/
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1004
diff changeset
   716
    private void encodeStubInAddress(
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1004
diff changeset
   717
            RMIServer rmiServer, Map<String, ?> attributes)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        final String protocol, host;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        final int port;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        if (address == null) {
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   724
            protocol = "rmi";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
            host = null; // will default to local host name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
            port = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            protocol = address.getProtocol();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
            host = (address.getHost().equals("")) ? null : address.getHost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
            port = address.getPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        final String urlPath = encodeStub(rmiServer, attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        address = new JMXServiceURL(protocol, host, port, urlPath);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * Returns the IOR of the given rmiServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     **/
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1004
diff changeset
   741
    static String encodeStub(
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1004
diff changeset
   742
            RMIServer rmiServer, Map<String, ?> env) throws IOException {
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   743
        return "/stub/" + encodeJRMPStub(rmiServer, env);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1004
diff changeset
   746
    static String encodeJRMPStub(
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1004
diff changeset
   747
            RMIServer rmiServer, Map<String, ?> env)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        ObjectOutputStream oout = new ObjectOutputStream(bout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        oout.writeObject(rmiServer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        oout.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        byte[] bytes = bout.toByteArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        return byteArrayToBase64(bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     * Object that we will bind to the registry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     * This object is a stub connected to our RMIServerImpl.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     **/
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1004
diff changeset
   761
    private static RMIServer objectToBind(
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1004
diff changeset
   762
            RMIServerImpl rmiServer, Map<String, ?> env)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        throws IOException {
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 25859
diff changeset
   764
        return (RMIServer)rmiServer.toStub();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    private static RMIServerImpl newJRMPServer(Map<String, ?> env, int port)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        RMIClientSocketFactory csf = (RMIClientSocketFactory)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
            env.get(RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        RMIServerSocketFactory ssf = (RMIServerSocketFactory)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
            env.get(RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        return new RMIJRMPServerImpl(port, csf, ssf, env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    private static String byteArrayToBase64(byte[] a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        int aLen = a.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        int numFullGroups = aLen/3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        int numBytesInPartialGroup = aLen - 3*numFullGroups;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        int resultLen = 4*((aLen + 2)/3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        final StringBuilder result = new StringBuilder(resultLen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        // Translate all full groups from byte array elements to Base64
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
        int inCursor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        for (int i=0; i<numFullGroups; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
            int byte0 = a[inCursor++] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
            int byte1 = a[inCursor++] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
            int byte2 = a[inCursor++] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
            result.append(intToAlpha[byte0 >> 2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
            result.append(intToAlpha[(byte0 << 4)&0x3f | (byte1 >> 4)]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            result.append(intToAlpha[(byte1 << 2)&0x3f | (byte2 >> 6)]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            result.append(intToAlpha[byte2 & 0x3f]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        // Translate partial group if present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        if (numBytesInPartialGroup != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            int byte0 = a[inCursor++] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
            result.append(intToAlpha[byte0 >> 2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            if (numBytesInPartialGroup == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
                result.append(intToAlpha[(byte0 << 4) & 0x3f]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
                result.append("==");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                // assert numBytesInPartialGroup == 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                int byte1 = a[inCursor++] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                result.append(intToAlpha[(byte0 << 4)&0x3f | (byte1 >> 4)]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
                result.append(intToAlpha[(byte1 << 2)&0x3f]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                result.append('=');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        // assert inCursor == a.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        // assert result.length() == resultLen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        return result.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     * This array is a lookup table that translates 6-bit positive integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     * index values into their "Base64 Alphabet" equivalents as specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     * in Table 1 of RFC 2045.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    private static final char intToAlpha[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * Construct a new IOException with a nested exception.
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 14917
diff changeset
   830
     * The nested exception is set only if JDK {@literal >= 1.4}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
    private static IOException newIOException(String message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
                                              Throwable cause) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        final IOException x = new IOException(message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        return EnvHelp.initCause(x,cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    // Private variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    // -----------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
    private static ClassLogger logger =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        new ClassLogger("javax.management.remote.rmi", "RMIConnectorServer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
    private JMXServiceURL address;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    private RMIServerImpl rmiServerImpl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    private final Map<String, ?> attributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    private ClassLoader defaultClassLoader = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    private String boundJndiUrl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    // state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    private static final int CREATED = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    private static final int STARTED = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    private static final int STOPPED = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    private int state = CREATED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    private final static Set<RMIConnectorServer> openedServers =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
            new HashSet<RMIConnectorServer>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
}