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