jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnector.java
author sgehwolf
Fri, 22 Jan 2016 17:43:21 +0000
changeset 35310 24e6bd6c0b75
parent 35282 cbcd2afb6070
child 36511 9d0388c6b336
permissions -rw-r--r--
8147857: RMIConnector logs attribute names incorrectly Summary: Fix order of arguments to Collectors.joining Reviewed-by: andrew, dfuchs, jbachorik
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 32034
diff changeset
     2
 * Copyright (c) 2002, 2015, 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
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
    28
import com.sun.jmx.mbeanserver.Util;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import com.sun.jmx.remote.internal.ClientCommunicatorAdmin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import com.sun.jmx.remote.internal.ClientListenerInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import com.sun.jmx.remote.internal.ClientNotifForwarder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import com.sun.jmx.remote.internal.ProxyRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import com.sun.jmx.remote.util.ClassLogger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import com.sun.jmx.remote.util.EnvHelp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.io.ByteArrayInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.io.InputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.io.InvalidObjectException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.io.ObjectStreamClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.lang.ref.WeakReference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.lang.reflect.Constructor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.lang.reflect.InvocationHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.lang.reflect.InvocationTargetException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.lang.reflect.Proxy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.net.MalformedURLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.rmi.MarshalledObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.rmi.NoSuchObjectException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.rmi.Remote;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import java.rmi.ServerException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import java.rmi.UnmarshalException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import java.rmi.server.RMIClientSocketFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import java.rmi.server.RemoteObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import java.rmi.server.RemoteObjectInvocationHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import java.rmi.server.RemoteRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import java.security.PrivilegedExceptionAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
import java.security.ProtectionDomain;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
import java.util.HashMap;
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 32034
diff changeset
    64
import java.util.Hashtable;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
import java.util.WeakHashMap;
35282
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
    68
import java.util.stream.Collectors;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
import javax.management.Attribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
import javax.management.AttributeList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
import javax.management.AttributeNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
import javax.management.InstanceAlreadyExistsException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
import javax.management.InstanceNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
import javax.management.IntrospectionException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
import javax.management.InvalidAttributeValueException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
import javax.management.ListenerNotFoundException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
import javax.management.MBeanException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
import javax.management.MBeanInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
import javax.management.MBeanRegistrationException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
import javax.management.MBeanServerConnection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
import javax.management.MBeanServerDelegate;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
import javax.management.MBeanServerNotification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
import javax.management.NotCompliantMBeanException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
import javax.management.Notification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
import javax.management.NotificationBroadcasterSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
import javax.management.NotificationFilter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
import javax.management.NotificationFilterSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
import javax.management.NotificationListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
import javax.management.ObjectInstance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
import javax.management.ObjectName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
import javax.management.QueryExp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
import javax.management.ReflectionException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
import javax.management.remote.JMXConnectionNotification;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
import javax.management.remote.JMXConnector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
import javax.management.remote.JMXConnectorFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
import javax.management.remote.JMXServiceURL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
import javax.management.remote.NotificationResult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
import javax.management.remote.JMXAddressable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
import javax.naming.InitialContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
import javax.naming.NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
import javax.rmi.ssl.SslRMIClientSocketFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
import javax.security.auth.Subject;
18206
136373d8d805 8008615: Improve robustness of JMX internal APIs
sjiang
parents: 14917
diff changeset
   103
import sun.reflect.misc.ReflectUtil;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
import sun.rmi.server.UnicastRef2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
import sun.rmi.transport.LiveRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * <p>A connection to a remote RMI connector.  Usually, such
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * connections are made using {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * javax.management.remote.JMXConnectorFactory JMXConnectorFactory}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * However, specialized applications can use this class directly, for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * example with an {@link RMIServer} stub obtained without going
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * through JNDI.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
public class RMIConnector implements JMXConnector, Serializable, JMXAddressable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    private static final ClassLogger logger =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   120
            new ClassLogger("javax.management.remote.rmi", "RMIConnector");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    private static final long serialVersionUID = 817323035842634473L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    private RMIConnector(RMIServer rmiServer, JMXServiceURL address,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   125
            Map<String, ?> environment) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        if (rmiServer == null && address == null) throw new
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   127
                IllegalArgumentException("rmiServer and jmxServiceURL both null");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        initTransients();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        this.rmiServer = rmiServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        this.jmxServiceURL = address;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (environment == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            this.env = Collections.emptyMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            EnvHelp.checkAttributes(environment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            this.env = Collections.unmodifiableMap(environment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 26594
diff changeset
   141
     * <p>Constructs an {@code RMIConnector} that will connect
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * the RMI connector server with the given address.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * <p>The address can refer directly to the connector server,
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 32034
diff changeset
   145
     * using the following syntax:</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * service:jmx:rmi://<em>[host[:port]]</em>/stub/<em>encoded-stub</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 26594
diff changeset
   151
     * <p>(Here, the square brackets {@code []} are not part of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * address but indicate that the host and port are optional.)</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * <p>The address can instead indicate where to find an RMI stub
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 32034
diff changeset
   155
     * through JNDI, using the following syntax:</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * service:jmx:rmi://<em>[host[:port]]</em>/jndi/<em>jndi-name</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * <p>An implementation may also recognize additional address
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * syntaxes, for example:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * service:jmx:iiop://<em>[host[:port]]</em>/stub/<em>encoded-stub</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @param url the address of the RMI connector server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @param environment additional attributes specifying how to make
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * the connection.  For JNDI-based addresses, these attributes can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * usefully include JNDI attributes recognized by {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * InitialContext#InitialContext(Hashtable) InitialContext}.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * parameter can be null, which is equivalent to an empty Map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 26594
diff changeset
   176
     * @exception IllegalArgumentException if {@code url}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public RMIConnector(JMXServiceURL url, Map<String,?> environment) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        this(null, url, environment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /**
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 26594
diff changeset
   184
     * <p>Constructs an {@code RMIConnector} using the given RMI stub.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @param rmiServer an RMI stub representing the RMI connector server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @param environment additional attributes specifying how to make
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * the connection.  This parameter can be null, which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * equivalent to an empty Map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 26594
diff changeset
   191
     * @exception IllegalArgumentException if {@code rmiServer}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    public RMIConnector(RMIServer rmiServer, Map<String,?> environment) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        this(rmiServer, null, environment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * <p>Returns a string representation of this object.  In general,
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 26594
diff changeset
   200
     * the {@code toString} method returns a string that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * "textually represents" this object. The result should be a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * concise but informative representation that is easy for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * person to read.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @return a String representation of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     **/
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1570
diff changeset
   207
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        final StringBuilder b = new StringBuilder(this.getClass().getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        b.append(":");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        if (rmiServer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            b.append(" rmiServer=").append(rmiServer.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        if (jmxServiceURL != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            if (rmiServer!=null) b.append(",");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            b.append(" jmxServiceURL=").append(jmxServiceURL.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        return b.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * <p>The address of this connector.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * @return the address of this connector, or null if it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * does not have one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    public JMXServiceURL getAddress() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return jmxServiceURL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    // implements JMXConnector interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    //--------------------------------------------------------------------
14917
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 14342
diff changeset
   236
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 14342
diff changeset
   237
    /**
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 14342
diff changeset
   238
     * @throws IOException if the connection could not be made because of a
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 32034
diff changeset
   239
     *   communication problem
14917
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 14342
diff changeset
   240
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public void connect() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        connect(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
14917
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 14342
diff changeset
   245
    /**
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 14342
diff changeset
   246
     * @throws IOException if the connection could not be made because of a
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 32034
diff changeset
   247
     *   communication problem
14917
bf08557604f8 8001048: JSR-160: Allow IIOP transport to be optional
alanb
parents: 14342
diff changeset
   248
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    public synchronized void connect(Map<String,?> environment)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   250
    throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        final boolean tracing = logger.traceOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        String        idstr   = (tracing?"["+this.toString()+"]":null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        if (terminated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            logger.trace("connect",idstr + " already closed.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            throw new IOException("Connector closed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        if (connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            logger.trace("connect",idstr + " already connected.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            if (tracing) logger.trace("connect",idstr + " connecting...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            final Map<String, Object> usemap =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   267
                    new HashMap<String, Object>((this.env==null) ?
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   268
                        Collections.<String, Object>emptyMap() : this.env);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            if (environment != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                EnvHelp.checkAttributes(environment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                usemap.putAll(environment);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            // Get RMIServer stub from directory or URL encoding if needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            if (tracing) logger.trace("connect",idstr + " finding stub...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            RMIServer stub = (rmiServer!=null)?rmiServer:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                findRMIServer(jmxServiceURL, usemap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            // Check for secure RMIServer stub if the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            // client-side environment property is set to "true".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            //
14210
042f1a001234 7158796: Tighten properties checking in EnvHelp
dsamersoff
parents: 7167
diff changeset
   284
            String stringBoolean =  (String) usemap.get("jmx.remote.x.check.stub");
042f1a001234 7158796: Tighten properties checking in EnvHelp
dsamersoff
parents: 7167
diff changeset
   285
            boolean checkStub = EnvHelp.computeBooleanFromString(stringBoolean);
042f1a001234 7158796: Tighten properties checking in EnvHelp
dsamersoff
parents: 7167
diff changeset
   286
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            if (checkStub) checkStub(stub, rmiServerImplStubClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            if (tracing) logger.trace("connect",idstr + " connecting stub...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            idstr = (tracing?"["+this.toString()+"]":null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            // Calling newClient on the RMIServer stub.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            if (tracing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                logger.trace("connect",idstr + " getting connection...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            Object credentials = usemap.get(CREDENTIALS);
7167
f5a0fca591f8 6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents: 5506
diff changeset
   296
f5a0fca591f8 6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents: 5506
diff changeset
   297
            try {
f5a0fca591f8 6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents: 5506
diff changeset
   298
                connection = getConnection(stub, credentials, checkStub);
f5a0fca591f8 6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents: 5506
diff changeset
   299
            } catch (java.rmi.RemoteException re) {
f5a0fca591f8 6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents: 5506
diff changeset
   300
                throw re;
f5a0fca591f8 6696028: JMXServiceURL like service:jmx:rmi:///jndi/iiop:// should be rejected by the RMI conn provider.
coffeys
parents: 5506
diff changeset
   301
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            // Always use one of:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            //   ClassLoader provided in Map at connect time,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            //   or contextClassLoader at connect time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            if (tracing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                logger.trace("connect",idstr + " getting class loader...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            defaultClassLoader = EnvHelp.resolveClientClassLoader(usemap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            usemap.put(JMXConnectorFactory.DEFAULT_CLASS_LOADER,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   311
                    defaultClassLoader);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            rmiNotifClient = new RMINotifClient(defaultClassLoader, usemap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            env = usemap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            final long checkPeriod = EnvHelp.getConnectionCheckPeriod(usemap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            communicatorAdmin = new RMIClientCommunicatorAdmin(checkPeriod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            connected = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            // The connectionId variable is used in doStart(), when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            // reconnecting, to identify the "old" connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            connectionId = getConnectionId();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            Notification connectedNotif =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   327
                    new JMXConnectionNotification(JMXConnectionNotification.OPENED,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   328
                    this,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   329
                    connectionId,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   330
                    clientNotifSeqNo++,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   331
                    "Successful connection",
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   332
                    null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            sendNotification(connectedNotif);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            if (tracing) logger.trace("connect",idstr + " done...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            if (tracing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                logger.trace("connect",idstr + " failed to connect: " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        } catch (RuntimeException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            if (tracing)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                logger.trace("connect",idstr + " failed to connect: " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        } catch (NamingException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            final String msg = "Failed to retrieve RMIServer stub: " + e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            if (tracing) logger.trace("connect",idstr + " " + msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            throw EnvHelp.initCause(new IOException(msg),e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    public synchronized String getConnectionId() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        if (terminated || !connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            if (logger.traceOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                logger.trace("getConnectionId","["+this.toString()+
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   355
                        "] not connected.");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            throw new IOException("Not connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        // we do a remote call to have an IOException if the connection is broken.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        // see the bug 4939578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        return connection.getConnectionId();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public synchronized MBeanServerConnection getMBeanServerConnection()
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   366
    throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        return getMBeanServerConnection(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    public synchronized MBeanServerConnection
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   371
            getMBeanServerConnection(Subject delegationSubject)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        if (terminated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            if (logger.traceOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                logger.trace("getMBeanServerConnection","[" + this.toString() +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   377
                        "] already closed.");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            throw new IOException("Connection closed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        } else if (!connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            if (logger.traceOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                logger.trace("getMBeanServerConnection","[" + this.toString() +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   382
                        "] is not connected.");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            throw new IOException("Not connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
19791
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
   386
        return getConnectionWithSubject(delegationSubject);
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
   387
    }
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
   388
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    public void
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   390
            addConnectionNotificationListener(NotificationListener listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   391
            NotificationFilter filter,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   392
            Object handback) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        if (listener == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            throw new NullPointerException("listener");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        connectionBroadcaster.addNotificationListener(listener, filter,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   396
                handback);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    public void
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   400
            removeConnectionNotificationListener(NotificationListener listener)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            throws ListenerNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        if (listener == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            throw new NullPointerException("listener");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        connectionBroadcaster.removeNotificationListener(listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    public void
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   408
            removeConnectionNotificationListener(NotificationListener listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   409
            NotificationFilter filter,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   410
            Object handback)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            throws ListenerNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        if (listener == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            throw new NullPointerException("listener");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        connectionBroadcaster.removeNotificationListener(listener, filter,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   415
                handback);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    private void sendNotification(Notification n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        connectionBroadcaster.sendNotification(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    public synchronized void close() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        close(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    // allows to do close after setting the flag "terminated" to true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    // It is necessary to avoid a deadlock, see 6296324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    private synchronized void close(boolean intern) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        final boolean tracing = logger.traceOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        final boolean debug   = logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        final String  idstr   = (tracing?"["+this.toString()+"]":null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        if (!intern) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            // Return if already cleanly closed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            if (terminated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                if (closeException == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                    if (tracing) logger.trace("close",idstr + " already closed.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                terminated = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        if (closeException != null && tracing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            // Already closed, but not cleanly. Attempt again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            if (tracing) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                logger.trace("close",idstr + " had failed: " + closeException);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                logger.trace("close",idstr + " attempting to close again.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        String savedConnectionId = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        if (connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            savedConnectionId = connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        closeException = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        if (tracing) logger.trace("close",idstr + " closing.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        if (communicatorAdmin != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            communicatorAdmin.terminate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        if (rmiNotifClient != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                rmiNotifClient.terminate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                if (tracing) logger.trace("close",idstr +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   472
                        " RMI Notification client terminated.");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            } catch (RuntimeException x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                closeException = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                if (tracing) logger.trace("close",idstr +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   476
                        " Failed to terminate RMI Notification client: " + x);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                if (debug) logger.debug("close",x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        if (connection != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                connection.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                if (tracing) logger.trace("close",idstr + " closed.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            } catch (NoSuchObjectException nse) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                // OK, the server maybe closed itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                closeException = e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                if (tracing) logger.trace("close",idstr +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   490
                        " Failed to close RMIServer: " + e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                if (debug) logger.debug("close",e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        // Clean up MBeanServerConnection table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        rmbscMap.clear();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        /* Send notification of closure.  We don't do this if the user
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
         * never called connect() on the connector, because there's no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
         * connection id in that case.  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        if (savedConnectionId != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            Notification closedNotif =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   505
                    new JMXConnectionNotification(JMXConnectionNotification.CLOSED,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   506
                    this,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   507
                    savedConnectionId,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   508
                    clientNotifSeqNo++,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   509
                    "Client has been closed",
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   510
                    null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            sendNotification(closedNotif);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        // throw exception if needed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        if (closeException != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            if (tracing) logger.trace("close",idstr + " failed to close: " +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   518
                    closeException);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            if (closeException instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                throw (IOException) closeException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            if (closeException instanceof RuntimeException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                throw (RuntimeException) closeException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            final IOException x =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   524
                    new IOException("Failed to close: " + closeException);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
            throw EnvHelp.initCause(x,closeException);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    // added for re-connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    private Integer addListenerWithSubject(ObjectName name,
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
   531
                                           MarshalledObject<NotificationFilter> filter,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                                           Subject delegationSubject,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                                           boolean reconnect)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        throws InstanceNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        final boolean debug = logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        if (debug)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            logger.debug("addListenerWithSubject",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   539
                    "(ObjectName,MarshalledObject,Subject)");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        final ObjectName[] names = new ObjectName[] {name};
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
   542
        final MarshalledObject<NotificationFilter>[] filters =
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
   543
                Util.cast(new MarshalledObject<?>[] {filter});
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        final Subject[] delegationSubjects = new Subject[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            delegationSubject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        final Integer[] listenerIDs =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   549
                addListenersWithSubjects(names,filters,delegationSubjects,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   550
                reconnect);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        if (debug) logger.debug("addListenerWithSubject","listenerID="
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   553
                + listenerIDs[0]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        return listenerIDs[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    // added for re-connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    private Integer[] addListenersWithSubjects(ObjectName[]       names,
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
   559
                             MarshalledObject<NotificationFilter>[] filters,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                             Subject[]          delegationSubjects,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                             boolean            reconnect)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        throws InstanceNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        final boolean debug = logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        if (debug)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   566
            logger.debug("addListenersWithSubjects",
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   567
                    "(ObjectName[],MarshalledObject[],Subject[])");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        Integer[] listenerIDs = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            listenerIDs = connection.addNotificationListeners(names,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   574
                    filters,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   575
                    delegationSubjects);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        } catch (NoSuchObjectException noe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            // maybe reconnect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
            if (reconnect) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                communicatorAdmin.gotIOException(noe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                listenerIDs = connection.addNotificationListeners(names,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   582
                        filters,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   583
                        delegationSubjects);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                throw noe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            // send a failed notif if necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        if (debug) logger.debug("addListenersWithSubjects","registered "
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
   595
                + ((listenerIDs==null)?0:listenerIDs.length)
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
   596
                + " listener(s)");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        return listenerIDs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    // Implementation of MBeanServerConnection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    //--------------------------------------------------------------------
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
   603
    private class RemoteMBeanServerConnection implements MBeanServerConnection {
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
   604
        private Subject delegationSubject;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        public RemoteMBeanServerConnection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
            this(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        public RemoteMBeanServerConnection(Subject delegationSubject) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            this.delegationSubject = delegationSubject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        public ObjectInstance createMBean(String className,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   615
                ObjectName name)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                throws ReflectionException,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   617
                InstanceAlreadyExistsException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   618
                MBeanRegistrationException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   619
                MBeanException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   620
                NotCompliantMBeanException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   621
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                logger.debug("createMBean(String,ObjectName)",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   624
                        "className=" + className + ", name=" +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   625
                        name);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                return connection.createMBean(className,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   630
                        name,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   631
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                return connection.createMBean(className,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   636
                        name,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   637
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                popDefaultClassLoader(old);
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
        public ObjectInstance createMBean(String className,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   644
                ObjectName name,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   645
                ObjectName loaderName)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   646
                throws ReflectionException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   647
                InstanceAlreadyExistsException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   648
                MBeanRegistrationException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   649
                MBeanException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   650
                NotCompliantMBeanException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   651
                InstanceNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   652
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                logger.debug("createMBean(String,ObjectName,ObjectName)",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   656
                        "className=" + className + ", name="
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   657
                        + name + ", loaderName="
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   658
                        + loaderName + ")");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                return connection.createMBean(className,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   663
                        name,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   664
                        loaderName,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   665
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                return connection.createMBean(className,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   671
                        name,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   672
                        loaderName,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   673
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        public ObjectInstance createMBean(String className,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   681
                ObjectName name,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   682
                Object params[],
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   683
                String signature[])
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                throws ReflectionException,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   685
                InstanceAlreadyExistsException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   686
                MBeanRegistrationException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   687
                MBeanException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   688
                NotCompliantMBeanException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   689
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
            if (logger.debugOn())
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   691
                logger.debug("createMBean(String,ObjectName,Object[],String[])",
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   692
                        "className=" + className + ", name="
35282
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
   693
                        + name + ", signature=" + strings(signature));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
            final MarshalledObject<Object[]> sParams =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
                    new MarshalledObject<Object[]>(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
                return connection.createMBean(className,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   700
                        name,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   701
                        sParams,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   702
                        signature,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   703
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                return connection.createMBean(className,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   708
                        name,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   709
                        sParams,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   710
                        signature,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   711
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        public ObjectInstance createMBean(String className,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   718
                ObjectName name,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   719
                ObjectName loaderName,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   720
                Object params[],
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   721
                String signature[])
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
                throws ReflectionException,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   723
                InstanceAlreadyExistsException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   724
                MBeanRegistrationException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   725
                MBeanException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   726
                NotCompliantMBeanException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   727
                InstanceNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   728
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
            if (logger.debugOn()) logger.debug(
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   730
                    "createMBean(String,ObjectName,ObjectName,Object[],String[])",
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   731
                    "className=" + className + ", name=" + name + ", loaderName="
35282
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
   732
                    + loaderName + ", signature=" + strings(signature));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
            final MarshalledObject<Object[]> sParams =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                    new MarshalledObject<Object[]>(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                return connection.createMBean(className,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   739
                        name,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   740
                        loaderName,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   741
                        sParams,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   742
                        signature,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   743
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                return connection.createMBean(className,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   748
                        name,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   749
                        loaderName,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   750
                        sParams,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   751
                        signature,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   752
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        public void unregisterMBean(ObjectName name)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   759
        throws InstanceNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   760
                MBeanRegistrationException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   761
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                logger.debug("unregisterMBean", "name=" + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                connection.unregisterMBean(name, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                connection.unregisterMBean(name, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        public ObjectInstance getObjectInstance(ObjectName name)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   778
        throws InstanceNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   779
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                logger.debug("getObjectInstance", "name=" + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                return connection.getObjectInstance(name, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                return connection.getObjectInstance(name, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        public Set<ObjectInstance> queryMBeans(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   796
                QueryExp query)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   797
                throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
            if (logger.debugOn()) logger.debug("queryMBeans",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   799
                    "name=" + name + ", query=" + query);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            final MarshalledObject<QueryExp> sQuery =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
                    new MarshalledObject<QueryExp>(query);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
                return connection.queryMBeans(name, sQuery, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                return connection.queryMBeans(name, sQuery, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        public Set<ObjectName> queryNames(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   816
                QueryExp query)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
            if (logger.debugOn()) logger.debug("queryNames",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   819
                    "name=" + name + ", query=" + query);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
            final MarshalledObject<QueryExp> sQuery =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
                    new MarshalledObject<QueryExp>(query);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
                return connection.queryNames(name, sQuery, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                return connection.queryNames(name, sQuery, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        public boolean isRegistered(ObjectName name)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   836
        throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                logger.debug("isRegistered", "name=" + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
                return connection.isRegistered(name, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                return connection.isRegistered(name, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        public Integer getMBeanCount()
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   853
        throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            if (logger.debugOn()) logger.debug("getMBeanCount", "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                return connection.getMBeanCount(delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                return connection.getMBeanCount(delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        public Object getAttribute(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   869
                String attribute)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
                throws MBeanException,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   871
                AttributeNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   872
                InstanceNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   873
                ReflectionException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   874
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
            if (logger.debugOn()) logger.debug("getAttribute",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   876
                    "name=" + name + ", attribute="
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   877
                    + attribute);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                return connection.getAttribute(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   882
                        attribute,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   883
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
                return connection.getAttribute(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   888
                        attribute,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   889
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        public AttributeList getAttributes(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   896
                String[] attributes)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
                throws InstanceNotFoundException,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   898
                ReflectionException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   899
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
            if (logger.debugOn()) logger.debug("getAttributes",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   901
                    "name=" + name + ", attributes="
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   902
                    + strings(attributes));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                return connection.getAttributes(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   907
                        attributes,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   908
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                return connection.getAttributes(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   914
                        attributes,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   915
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
        public void setAttribute(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   923
                Attribute attribute)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   924
                throws InstanceNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   925
                AttributeNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   926
                InvalidAttributeValueException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   927
                MBeanException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   928
                ReflectionException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   929
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
            if (logger.debugOn()) logger.debug("setAttribute",
35282
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
   932
                    "name=" + name + ", attribute name="
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
   933
                    + attribute.getName());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
            final MarshalledObject<Attribute> sAttribute =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   936
                    new MarshalledObject<Attribute>(attribute);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                connection.setAttribute(name, sAttribute, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                connection.setAttribute(name, sAttribute, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
        public AttributeList setAttributes(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   950
                AttributeList attributes)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   951
                throws InstanceNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   952
                ReflectionException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   953
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
35282
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
   955
            if (logger.debugOn()) {
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
   956
                logger.debug("setAttributes",
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
   957
                    "name=" + name + ", attribute names="
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
   958
                    + getAttributesNames(attributes));
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
   959
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
            final MarshalledObject<AttributeList> sAttributes =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   962
                    new MarshalledObject<AttributeList>(attributes);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
                return connection.setAttributes(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   966
                        sAttributes,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   967
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                return connection.setAttributes(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   972
                        sAttributes,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   973
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        public Object invoke(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   981
                String operationName,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   982
                Object params[],
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   983
                String signature[])
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
                throws InstanceNotFoundException,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   985
                MBeanException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   986
                ReflectionException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   987
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
            if (logger.debugOn()) logger.debug("invoke",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   990
                    "name=" + name
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   991
                    + ", operationName=" + operationName
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   992
                    + ", signature=" + strings(signature));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
            final MarshalledObject<Object[]> sParams =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
                    new MarshalledObject<Object[]>(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                return connection.invoke(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
   999
                        operationName,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1000
                        sParams,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1001
                        signature,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1002
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
                return connection.invoke(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1007
                        operationName,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1008
                        sParams,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1009
                        signature,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1010
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
        public String getDefaultDomain()
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1018
        throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
            if (logger.debugOn()) logger.debug("getDefaultDomain", "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
                return connection.getDefaultDomain(delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
                return connection.getDefaultDomain(delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
        public String[] getDomains() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
            if (logger.debugOn()) logger.debug("getDomains", "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
                return connection.getDomains(delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
                return connection.getDomains(delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
        public MBeanInfo getMBeanInfo(ObjectName name)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1049
        throws InstanceNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1050
                IntrospectionException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1051
                ReflectionException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1052
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
            if (logger.debugOn()) logger.debug("getMBeanInfo", "name=" + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                return connection.getMBeanInfo(name, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                return connection.getMBeanInfo(name, delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
        public boolean isInstanceOf(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1069
                String className)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
                throws InstanceNotFoundException,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1071
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                logger.debug("isInstanceOf", "name=" + name +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1074
                        ", className=" + className);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                return connection.isInstanceOf(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1079
                        className,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1080
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
                return connection.isInstanceOf(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1085
                        className,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1086
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
        public void addNotificationListener(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1093
                ObjectName listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1094
                NotificationFilter filter,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1095
                Object handback)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
                throws InstanceNotFoundException,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1097
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
                logger.debug("addNotificationListener" +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1101
                        "(ObjectName,ObjectName,NotificationFilter,Object)",
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1102
                        "name=" + name + ", listener=" + listener
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1103
                        + ", filter=" + filter + ", handback=" + handback);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
            final MarshalledObject<NotificationFilter> sFilter =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
                    new MarshalledObject<NotificationFilter>(filter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
            final MarshalledObject<Object> sHandback =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
                    new MarshalledObject<Object>(handback);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
                connection.addNotificationListener(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1112
                        listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1113
                        sFilter,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1114
                        sHandback,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1115
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
                connection.addNotificationListener(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1120
                        listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1121
                        sFilter,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1122
                        sHandback,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1123
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
        public void removeNotificationListener(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1130
                ObjectName listener)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
                throws InstanceNotFoundException,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1132
                ListenerNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1133
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
            if (logger.debugOn()) logger.debug("removeNotificationListener" +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1136
                    "(ObjectName,ObjectName)",
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1137
                    "name=" + name
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1138
                    + ", listener=" + listener);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
                connection.removeNotificationListener(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1143
                        listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1144
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
                connection.removeNotificationListener(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1149
                        listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1150
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
        public void removeNotificationListener(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1157
                ObjectName listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1158
                NotificationFilter filter,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1159
                Object handback)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
                throws InstanceNotFoundException,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1161
                ListenerNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1162
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
                logger.debug("removeNotificationListener" +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1165
                        "(ObjectName,ObjectName,NotificationFilter,Object)",
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1166
                        "name=" + name
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1167
                        + ", listener=" + listener
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1168
                        + ", filter=" + filter
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1169
                        + ", handback=" + handback);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
            final MarshalledObject<NotificationFilter> sFilter =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
                    new MarshalledObject<NotificationFilter>(filter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
            final MarshalledObject<Object> sHandback =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
                    new MarshalledObject<Object>(handback);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
                connection.removeNotificationListener(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1178
                        listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1179
                        sFilter,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1180
                        sHandback,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1181
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
                connection.removeNotificationListener(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1186
                        listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1187
                        sFilter,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1188
                        sHandback,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1189
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
        // Specific Notification Handle ----------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
        public void addNotificationListener(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1198
                NotificationListener listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1199
                NotificationFilter filter,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1200
                Object handback)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
                throws InstanceNotFoundException,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1202
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
            final boolean debug = logger.debugOn();
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
  1205
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
            if (debug)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
                logger.debug("addNotificationListener" +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1208
                        "(ObjectName,NotificationListener,"+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1209
                        "NotificationFilter,Object)",
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1210
                        "name=" + name
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1211
                        + ", listener=" + listener
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1212
                        + ", filter=" + filter
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1213
                        + ", handback=" + handback);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
            final Integer listenerID =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1216
                    addListenerWithSubject(name,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1217
                    new MarshalledObject<NotificationFilter>(filter),
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1218
                    delegationSubject,true);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
            rmiNotifClient.addNotificationListener(listenerID, name, listener,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1220
                    filter, handback,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1221
                    delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
        public void removeNotificationListener(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1225
                NotificationListener listener)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
                throws InstanceNotFoundException,
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
  1227
                ListenerNotFoundException,
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
  1228
                IOException {
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
  1229
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
            final boolean debug = logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
            if (debug) logger.debug("removeNotificationListener"+
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1233
                    "(ObjectName,NotificationListener)",
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1234
                    "name=" + name
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1235
                    + ", listener=" + listener);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
            final Integer[] ret =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1238
                    rmiNotifClient.removeNotificationListener(name, listener);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
            if (debug) logger.debug("removeNotificationListener",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1241
                    "listenerIDs=" + objects(ret));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
                connection.removeNotificationListeners(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1247
                        ret,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1248
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
                connection.removeNotificationListeners(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1253
                        ret,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1254
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
        public void removeNotificationListener(ObjectName name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1262
                NotificationListener listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1263
                NotificationFilter filter,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1264
                Object handback)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1265
                throws InstanceNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1266
                ListenerNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1267
                IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
            final boolean debug = logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
            if (debug)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
                logger.debug("removeNotificationListener"+
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1272
                        "(ObjectName,NotificationListener,"+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1273
                        "NotificationFilter,Object)",
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1274
                        "name=" + name
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1275
                        + ", listener=" + listener
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1276
                        + ", filter=" + filter
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1277
                        + ", handback=" + handback);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
            final Integer ret =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1280
                    rmiNotifClient.removeNotificationListener(name, listener,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1281
                    filter, handback);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
            if (debug) logger.debug("removeNotificationListener",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1284
                    "listenerID=" + ret);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
            final ClassLoader old = pushDefaultClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
                connection.removeNotificationListeners(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1289
                        new Integer[] {ret},
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1290
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
                connection.removeNotificationListeners(name,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1295
                        new Integer[] {ret},
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1296
                        delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
                popDefaultClassLoader(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
    private class RMINotifClient extends ClientNotifForwarder {
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  1306
        public RMINotifClient(ClassLoader cl, Map<String, ?> env) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
            super(cl, env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
        protected NotificationResult fetchNotifs(long clientSequenceNumber,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1311
                int maxNotifications,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1312
                long timeout)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
                throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
26594
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1315
            boolean retried = false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
            while (true) { // used for a successful re-connection
26594
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1317
                           // or a transient network problem
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
                    return connection.fetchNotifications(clientSequenceNumber,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1320
                            maxNotifications,
26594
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1321
                            timeout); // return normally
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
                } catch (IOException ioe) {
26594
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1323
                    // Examine the chain of exceptions to determine whether this
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1324
                    // is a deserialization issue. If so - we propagate the
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1325
                    // appropriate exception to the caller, who will then
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1326
                    // proceed with fetching notifications one by one
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1327
                    rethrowDeserializationException(ioe);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
                        communicatorAdmin.gotIOException(ioe);
26594
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1331
                        // reconnection OK, back to "while" to do again
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
                    } catch (IOException ee) {
26594
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1333
                        boolean toClose = false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
26594
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1335
                        synchronized (this) {
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1336
                            if (terminated) {
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1337
                                // the connection is closed.
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1338
                                throw ioe;
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1339
                            } else if (retried) {
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1340
                                toClose = true;
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1341
                            }
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1342
                        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
26594
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1344
                        if (toClose) {
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1345
                            // JDK-8049303
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1346
                            // We received an IOException - but the communicatorAdmin
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1347
                            // did not close the connection - possibly because
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1348
                            // the original exception was raised by a transient network
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1349
                            // problem?
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1350
                            // We already know that this exception is not due to a deserialization
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1351
                            // issue as we already took care of that before involving the
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1352
                            // communicatorAdmin. Moreover - we already made one retry attempt
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1353
                            // at fetching the same batch of notifications - and the
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1354
                            // problem persisted.
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1355
                            // Since trying again doesn't seem to solve the issue, we will now
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1356
                            // close the connection. Doing otherwise might cause the
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1357
                            // NotifFetcher thread to die silently.
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1358
                            final Notification failedNotif =
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1359
                                    new JMXConnectionNotification(
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1360
                                    JMXConnectionNotification.FAILED,
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1361
                                    this,
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1362
                                    connectionId,
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1363
                                    clientNotifSeqNo++,
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1364
                                    "Failed to communicate with the server: " + ioe.toString(),
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1365
                                    ioe);
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1366
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1367
                            sendNotification(failedNotif);
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1368
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1369
                            try {
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1370
                                close(true);
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1371
                            } catch (Exception e) {
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1372
                                // OK.
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1373
                                // We are closing
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1374
                            }
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1375
                            throw ioe; // the connection is closed here.
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1376
                        } else {
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1377
                            // JDK-8049303 possible transient network problem,
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1378
                            // let's try one more time
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1379
                            retried = true;
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1380
                        }
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1381
                    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
                }
26594
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1383
            }
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1384
        }
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1385
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1386
        private void rethrowDeserializationException(IOException ioe)
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1387
                throws ClassNotFoundException, IOException {
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1388
            // specially treating for an UnmarshalException
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1389
            if (ioe instanceof UnmarshalException) {
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1390
                throw ioe; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1391
                           // fetch one by one with UnmarshalException
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
26594
b561a19107c7 8049303: Transient network problems cause JMX thread to fail silenty
sjiang
parents: 25859
diff changeset
  1394
            // Not serialization problem, return.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
        protected Integer addListenerForMBeanRemovedNotif()
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1398
        throws IOException, InstanceNotFoundException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
            NotificationFilterSupport clientFilter =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1400
                    new NotificationFilterSupport();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
            clientFilter.enableType(
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1402
                    MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
  1403
            MarshalledObject<NotificationFilter> sFilter =
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
  1404
                new MarshalledObject<NotificationFilter>(clientFilter);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
            Integer[] listenerIDs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
            final ObjectName[] names =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
                new ObjectName[] {MBeanServerDelegate.DELEGATE_NAME};
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  1409
            final MarshalledObject<NotificationFilter>[] filters =
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  1410
                Util.cast(new MarshalledObject<?>[] {sFilter});
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
            final Subject[] subjects = new Subject[] {null};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
                listenerIDs =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1414
                        connection.addNotificationListeners(names,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1415
                        filters,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1416
                        subjects);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
                listenerIDs =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1422
                        connection.addNotificationListeners(names,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1423
                        filters,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1424
                        subjects);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
            return listenerIDs[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
        protected void removeListenerForMBeanRemovedNotif(Integer id)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1430
        throws IOException, InstanceNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1431
                ListenerNotFoundException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
                connection.removeNotificationListeners(
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1434
                        MBeanServerDelegate.DELEGATE_NAME,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1435
                        new Integer[] {id},
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1436
                        null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
                communicatorAdmin.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
                connection.removeNotificationListeners(
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1441
                        MBeanServerDelegate.DELEGATE_NAME,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1442
                        new Integer[] {id},
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1443
                        null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
        protected void lostNotifs(String message, long number) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
            final String notifType = JMXConnectionNotification.NOTIFS_LOST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
            final JMXConnectionNotification n =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
                new JMXConnectionNotification(notifType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
                                              RMIConnector.this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
                                              connectionId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
                                              clientNotifCounter++,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
                                              message,
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
  1457
                                              Long.valueOf(number));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
            sendNotification(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
    private class RMIClientCommunicatorAdmin extends ClientCommunicatorAdmin {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
        public RMIClientCommunicatorAdmin(long period) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
            super(period);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1570
diff changeset
  1467
        @Override
1446
605e30465515 6757225: MXBean: Incorrect type names for parametrized types, dealing with arrays
emcmanus
parents: 1229
diff changeset
  1468
        public void gotIOException(IOException ioe) throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
            if (ioe instanceof NoSuchObjectException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
                // need to restart
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
                super.gotIOException(ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
            // check if the connection is broken
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
                connection.getDefaultDomain(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
            } catch (IOException ioexc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
                boolean toClose = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
                synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
                    if (!terminated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
                        terminated = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
                        toClose = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
                if (toClose) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
                    // we should close the connection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
                    // but send a failed notif at first
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
                    final Notification failedNotif =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1494
                            new JMXConnectionNotification(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
                            JMXConnectionNotification.FAILED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
                            this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
                            connectionId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
                            clientNotifSeqNo++,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
                            "Failed to communicate with the server: "+ioe.toString(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
                            ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
                    sendNotification(failedNotif);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
                        close(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
                    } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
                        // OK.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
                        // We are closing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
            // forward the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
            if (ioe instanceof ServerException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
                /* Need to unwrap the exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
                   Some user-thrown exception at server side will be wrapped by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
                   rmi into a ServerException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
                   For example, a RMIConnnectorServer will wrap a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
                   ClassNotFoundException into a UnmarshalException, and rmi
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
                   will throw a ServerException at client side which wraps this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
                   UnmarshalException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
                   No failed notif here.
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1523
                 */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
                Throwable tt = ((ServerException)ioe).detail;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
                if (tt instanceof IOException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
                    throw (IOException)tt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
                } else if (tt instanceof RuntimeException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
                    throw (RuntimeException)tt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
            throw ioe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
        public void reconnectNotificationListeners(ClientListenerInfo[] old) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
            final int len  = old.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
            int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
            ClientListenerInfo[] clis = new ClientListenerInfo[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
            final Subject[] subjects = new Subject[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
            final ObjectName[] names = new ObjectName[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
            final NotificationListener[] listeners = new NotificationListener[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
            final NotificationFilter[] filters = new NotificationFilter[len];
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  1546
            final MarshalledObject<NotificationFilter>[] mFilters =
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  1547
                    Util.cast(new MarshalledObject<?>[len]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
            final Object[] handbacks = new Object[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
            for (i=0;i<len;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
                subjects[i]  = old[i].getDelegationSubject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
                names[i]     = old[i].getObjectName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
                listeners[i] = old[i].getListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
                filters[i]   = old[i].getNotificationFilter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
                mFilters[i]  = new MarshalledObject<NotificationFilter>(filters[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
                handbacks[i] = old[i].getHandback();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
                Integer[] ids = addListenersWithSubjects(names,mFilters,subjects,false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
                for (i=0;i<len;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
                    clis[i] = new ClientListenerInfo(ids[i],
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1564
                            names[i],
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1565
                            listeners[i],
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1566
                            filters[i],
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1567
                            handbacks[i],
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1568
                            subjects[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
                rmiNotifClient.postReconnection(clis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
            } catch (InstanceNotFoundException infe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
                // OK, we will do one by one
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
            int j = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
            for (i=0;i<len;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
                    Integer id = addListenerWithSubject(names[i],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
                            new MarshalledObject<NotificationFilter>(filters[i]),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
                            subjects[i],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
                            false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
                    clis[j++] = new ClientListenerInfo(id,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1587
                            names[i],
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1588
                            listeners[i],
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1589
                            filters[i],
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1590
                            handbacks[i],
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1591
                            subjects[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
                } catch (InstanceNotFoundException infe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
                    logger.warning("reconnectNotificationListeners",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1594
                            "Can't reconnect listener for " +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1595
                            names[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
            if (j != len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
                ClientListenerInfo[] tmp = clis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
                clis = new ClientListenerInfo[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
                System.arraycopy(tmp, 0, clis, 0, j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
            rmiNotifClient.postReconnection(clis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
        protected void checkConnection() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
                logger.debug("RMIClientCommunicatorAdmin-checkConnection",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1611
                        "Calling the method getDefaultDomain.");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
            connection.getDefaultDomain(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
        protected void doStart() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
            // Get RMIServer stub from directory or URL encoding if needed.
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
  1618
            RMIServer stub;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
                stub = (rmiServer!=null)?rmiServer:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
                    findRMIServer(jmxServiceURL, env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
            } catch (NamingException ne) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
                throw new IOException("Failed to get a RMI stub: "+ne);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
            // Calling newClient on the RMIServer stub.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
            Object credentials = env.get(CREDENTIALS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
            connection = stub.newClient(credentials);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
            // notif issues
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
            final ClientListenerInfo[] old = rmiNotifClient.preReconnection();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
            reconnectNotificationListeners(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
            connectionId = getConnectionId();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
            Notification reconnectedNotif =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1638
                    new JMXConnectionNotification(JMXConnectionNotification.OPENED,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1639
                    this,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1640
                    connectionId,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1641
                    clientNotifSeqNo++,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1642
                    "Reconnected to server",
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1643
                    null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
            sendNotification(reconnectedNotif);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
        protected void doStop() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
                close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
            } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
                logger.warning("RMIClientCommunicatorAdmin-doStop",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1653
                        "Failed to call the method close():" + ioe);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
                logger.debug("RMIClientCommunicatorAdmin-doStop",ioe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
    // Private stuff - Serialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
     * Read RMIConnector fields from an {@link java.io.ObjectInputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
     * ObjectInputStream}.
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 26594
diff changeset
  1665
     * Calls {@code s.defaultReadObject()} and then initializes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
     * all transient variables that need initializing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
     * @param s The ObjectInputStream to read from.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
     * @exception InvalidObjectException if none of <var>rmiServer</var> stub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
     *    or <var>jmxServiceURL</var> are set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
     * @see #RMIConnector(JMXServiceURL,Map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
     * @see #RMIConnector(RMIServer,Map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
    private void readObject(java.io.ObjectInputStream s)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1674
    throws IOException, ClassNotFoundException  {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
        if (rmiServer == null && jmxServiceURL == null) throw new
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1678
                InvalidObjectException("rmiServer and jmxServiceURL both null");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
        initTransients();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
     * Writes the RMIConnector fields to an {@link java.io.ObjectOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
     * ObjectOutputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
     * <p>Connects the underlying RMIServer stub to an ORB, if needed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
     * before serializing it. This is done using the environment
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
     * map that was provided to the constructor, if any, and as documented
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
     * in {@link javax.management.remote.rmi}.</p>
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 26594
diff changeset
  1690
     * <p>This method then calls {@code s.defaultWriteObject()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
     * Usually, <var>rmiServer</var> is null if this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
     * was constructed with a JMXServiceURL, and <var>jmxServiceURL</var>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
     * is null if this object is constructed with a RMIServer stub.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
     * <p>Note that the environment Map is not serialized, since the objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
     * it contains are assumed to be contextual and relevant only
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
     * with respect to the local environment (class loader, ORB, etc...).</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
     * <p>After an RMIConnector is deserialized, it is assumed that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
     * user will call {@link #connect(Map)}, providing a new Map that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
     * can contain values which are contextually relevant to the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
     * local environment.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
     * <p>Since connection to the ORB is needed prior to serializing, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
     * since the ORB to connect to is one of those contextual parameters,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
     * it is not recommended to re-serialize a just de-serialized object -
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
     * as the de-serialized object has no map. Thus, when an RMIConnector
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
     * object is needed for serialization or transmission to a remote
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
     * application, it is recommended to obtain a new RMIConnector stub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
     * by calling {@link RMIConnectorServer#toJMXConnector(Map)}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
     * @param s The ObjectOutputStream to write to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
     * @exception InvalidObjectException if none of <var>rmiServer</var> stub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
     *    or <var>jmxServiceURL</var> are set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
     * @see #RMIConnector(JMXServiceURL,Map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
     * @see #RMIConnector(RMIServer,Map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
    private void writeObject(java.io.ObjectOutputStream s)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1715
    throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
        if (rmiServer == null && jmxServiceURL == null) throw new
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1717
                InvalidObjectException("rmiServer and jmxServiceURL both null.");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
    // Initialization of transient variables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
    private void initTransients() {
19791
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1723
        rmbscMap = new WeakHashMap<Subject, WeakReference<MBeanServerConnection>>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
        connected = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
        terminated = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
        connectionBroadcaster = new NotificationBroadcasterSupport();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
    // Private stuff - Check if stub can be trusted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
    private static void checkStub(Remote stub,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1735
            Class<?> stubClass) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
        // Check remote stub is from the expected class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
        if (stub.getClass() != stubClass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
            if (!Proxy.isProxyClass(stub.getClass())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
                throw new SecurityException(
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1742
                        "Expecting a " + stubClass.getName() + " stub!");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
                InvocationHandler handler = Proxy.getInvocationHandler(stub);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
                if (handler.getClass() != RemoteObjectInvocationHandler.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
                    throw new SecurityException(
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1747
                            "Expecting a dynamic proxy instance with a " +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1748
                            RemoteObjectInvocationHandler.class.getName() +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1749
                            " invocation handler!");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
                    stub = (Remote) handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
        // Check RemoteRef in stub is from the expected class
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
        // "sun.rmi.server.UnicastRef2".
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
        RemoteRef ref = ((RemoteObject)stub).getRef();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
        if (ref.getClass() != UnicastRef2.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
            throw new SecurityException(
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1761
                    "Expecting a " + UnicastRef2.class.getName() +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1762
                    " remote reference in stub!");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
        // Check RMIClientSocketFactory in stub is from the expected class
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
        // "javax.rmi.ssl.SslRMIClientSocketFactory".
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
        LiveRef liveRef = ((UnicastRef2)ref).getLiveRef();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
        RMIClientSocketFactory csf = liveRef.getClientSocketFactory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
        if (csf == null || csf.getClass() != SslRMIClientSocketFactory.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
            throw new SecurityException(
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1771
                    "Expecting a " + SslRMIClientSocketFactory.class.getName() +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1772
                    " RMI client socket factory in stub!");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1775
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1776
    // Private stuff - RMIServer creation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
    private RMIServer findRMIServer(JMXServiceURL directoryURL,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1780
            Map<String, Object> environment)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1781
            throws NamingException, IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
        String path = directoryURL.getURLPath();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
        int end = path.indexOf(';');
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
        if (end < 0) end = path.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
        if (path.startsWith("/jndi/"))
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 32034
diff changeset
  1787
            return findRMIServerJNDI(path.substring(6,end), environment);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
        else if (path.startsWith("/stub/"))
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 32034
diff changeset
  1789
            return findRMIServerJRMP(path.substring(6,end), environment);
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 32034
diff changeset
  1790
        else {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
            final String msg = "URL path must begin with /jndi/ or /stub/ " +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1792
                    "or /ior/: " + path;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
            throw new MalformedURLException(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1795
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1796
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1797
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
     * Lookup the RMIServer stub in a directory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
     * @param jndiURL A JNDI URL indicating the location of the Stub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1800
     *                (see {@link javax.management.remote.rmi}), e.g.:
32034
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 26594
diff changeset
  1801
     *   <ul><li>{@code rmi://registry-host:port/rmi-stub-name}</li>
05676cfd40b5 8133040: docs: replace <tt> tags (obsolete in html5) for java.management
avstepan
parents: 26594
diff changeset
  1802
     *       <li>or {@code ldap://ldap-host:port/java-container-dn}</li>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1803
     *   </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1804
     * @param env the environment Map passed to the connector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
     * @return The retrieved RMIServer stub.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
     * @exception NamingException if the stub couldn't be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1807
     **/
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 32034
diff changeset
  1808
    private RMIServer findRMIServerJNDI(String jndiURL, Map<String, ?> env)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1809
            throws NamingException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1810
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
        InitialContext ctx = new InitialContext(EnvHelp.mapToHashtable(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1812
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1813
        Object objref = ctx.lookup(jndiURL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
        ctx.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1815
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 32034
diff changeset
  1816
        return narrowJRMPServer(objref);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1817
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1818
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1819
    private static RMIServer narrowJRMPServer(Object objref) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1820
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1821
        return (RMIServer) objref;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1822
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1823
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 32034
diff changeset
  1824
    private RMIServer findRMIServerJRMP(String base64, Map<String, ?> env)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1825
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1826
        final byte[] serialized;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1827
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1828
            serialized = base64ToByteArray(base64);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1829
        } catch (IllegalArgumentException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1830
            throw new MalformedURLException("Bad BASE64 encoding: " +
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1831
                    e.getMessage());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1832
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1833
        final ByteArrayInputStream bin = new ByteArrayInputStream(serialized);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1835
        final ClassLoader loader = EnvHelp.resolveClientClassLoader(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1836
        final ObjectInputStream oin =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1837
                (loader == null) ?
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1838
                    new ObjectInputStream(bin) :
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1839
                    new ObjectInputStreamWithLoader(bin, loader);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1840
        final Object stub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1841
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1842
            stub = oin.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1843
        } catch (ClassNotFoundException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1844
            throw new MalformedURLException("Class not found: " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1845
        }
4167
76f44f2d5d4d 6888179: Separate out dependency on CORBA
alanb
parents: 4156
diff changeset
  1846
        return (RMIServer)stub;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1847
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1848
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1849
    private static final class ObjectInputStreamWithLoader
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1850
            extends ObjectInputStream {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1851
        ObjectInputStreamWithLoader(InputStream in, ClassLoader cl)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1852
        throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1853
            super(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1854
            this.loader = cl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1855
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1856
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  1857
        @Override
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  1858
        protected Class<?> resolveClass(ObjectStreamClass classDesc)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1859
                throws IOException, ClassNotFoundException {
18206
136373d8d805 8008615: Improve robustness of JMX internal APIs
sjiang
parents: 14917
diff changeset
  1860
            String name = classDesc.getName();
136373d8d805 8008615: Improve robustness of JMX internal APIs
sjiang
parents: 14917
diff changeset
  1861
            ReflectUtil.checkPackageAccess(name);
136373d8d805 8008615: Improve robustness of JMX internal APIs
sjiang
parents: 14917
diff changeset
  1862
            return Class.forName(name, false, loader);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1863
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1864
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1865
        private final ClassLoader loader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1866
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1867
19791
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1868
    private MBeanServerConnection getConnectionWithSubject(Subject delegationSubject) {
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1869
        MBeanServerConnection conn = null;
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1870
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1871
        if (delegationSubject == null) {
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1872
            if (nullSubjectConnRef == null
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1873
                    || (conn = nullSubjectConnRef.get()) == null) {
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1874
                conn = new RemoteMBeanServerConnection(null);
24871
224e298c3978 8044865: Fix raw and unchecked lint warnings in management-related code
sjiang
parents: 21656
diff changeset
  1875
                nullSubjectConnRef = new WeakReference<MBeanServerConnection>(conn);
19791
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1876
            }
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1877
        } else {
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1878
            WeakReference<MBeanServerConnection> wr = rmbscMap.get(delegationSubject);
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1879
            if (wr == null || (conn = wr.get()) == null) {
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1880
                conn = new RemoteMBeanServerConnection(delegationSubject);
24871
224e298c3978 8044865: Fix raw and unchecked lint warnings in management-related code
sjiang
parents: 21656
diff changeset
  1881
                rmbscMap.put(delegationSubject, new WeakReference<MBeanServerConnection>(conn));
19791
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1882
            }
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1883
        }
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1884
        return conn;
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1885
    }
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  1886
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1887
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1888
       The following section of code avoids a class loading problem
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1889
       with RMI.  The problem is that an RMI stub, when deserializing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1890
       a remote method return value or exception, will first of all
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1891
       consult the first non-bootstrap class loader it finds in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1892
       call stack.  This can lead to behavior that is not portable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1893
       between implementations of the JMX Remote API.  Notably, an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1894
       implementation on J2SE 1.4 will find the RMI stub's loader on
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1895
       the stack.  But in J2SE 5, this stub is loaded by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1896
       bootstrap loader, so RMI will find the loader of the user code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1897
       that called an MBeanServerConnection method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1898
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1899
       To avoid this problem, we take advantage of what the RMI stub
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1900
       is doing internally.  Each remote call will end up calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1901
       ref.invoke(...), where ref is the RemoteRef parameter given to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1902
       the RMI stub's constructor.  It is within this call that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1903
       deserialization will happen.  So we fabricate our own RemoteRef
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1904
       that delegates everything to the "real" one but that is loaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1905
       by a class loader that knows no other classes.  The class
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1906
       loader NoCallStackClassLoader does this: the RemoteRef is an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1907
       instance of the class named by proxyRefClassName, which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1908
       fabricated by the class loader using byte code that is defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1909
       by the string below.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1910
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1911
       The call stack when the deserialization happens is thus this:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1912
       MBeanServerConnection.getAttribute (or whatever)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1913
       -> RMIConnectionImpl_Stub.getAttribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1914
          -> ProxyRef.invoke(...getAttribute...)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1915
             -> UnicastRef.invoke(...getAttribute...)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1916
                -> internal RMI stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1917
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1918
       Here UnicastRef is the RemoteRef created when the stub was
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1919
       deserialized (which is of some RMI internal class).  It and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1920
       "internal RMI stuff" are loaded by the bootstrap loader, so are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1921
       transparent to the stack search.  The first non-bootstrap
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1922
       loader found is our ProxyRefLoader, as required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1923
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1924
       In a future version of this code as integrated into J2SE 5,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1925
       this workaround could be replaced by direct access to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1926
       internals of RMI.  For now, we use the same code base for J2SE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1927
       and for the standalone Reference Implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1928
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1929
       The byte code below encodes the following class, compiled using
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1930
       J2SE 1.4.2 with the -g:none option.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1931
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1932
        package com.sun.jmx.remote.internal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1933
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1934
        import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1935
        import java.rmi.Remote;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1936
        import java.rmi.server.RemoteRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1937
        import com.sun.jmx.remote.internal.ProxyRef;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1938
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1939
        public class PRef extends ProxyRef {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1940
            public PRef(RemoteRef ref) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1941
                super(ref);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1942
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1943
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1944
            public Object invoke(Remote obj, Method method,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1945
                                 Object[] params, long opnum)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1946
                    throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1947
                return ref.invoke(obj, method, params, opnum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1948
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1949
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1950
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1951
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1952
    private static final String rmiServerImplStubClassName =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1953
        RMIServer.class.getName() + "Impl_Stub";
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  1954
    private static final Class<?> rmiServerImplStubClass;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1955
    private static final String rmiConnectionImplStubClassName =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1956
            RMIConnection.class.getName() + "Impl_Stub";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1957
    private static final Class<?> rmiConnectionImplStubClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1958
    private static final String pRefClassName =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1959
        "com.sun.jmx.remote.internal.PRef";
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  1960
    private static final Constructor<?> proxyRefConstructor;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1961
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1962
        final String pRefByteCodeString =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1963
                "\312\376\272\276\0\0\0.\0\27\12\0\5\0\15\11\0\4\0\16\13\0\17\0"+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1964
                "\20\7\0\21\7\0\22\1\0\6<init>\1\0\36(Ljava/rmi/server/RemoteRef;"+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1965
                ")V\1\0\4Code\1\0\6invoke\1\0S(Ljava/rmi/Remote;Ljava/lang/reflec"+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1966
                "t/Method;[Ljava/lang/Object;J)Ljava/lang/Object;\1\0\12Exception"+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1967
                "s\7\0\23\14\0\6\0\7\14\0\24\0\25\7\0\26\14\0\11\0\12\1\0\40com/"+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1968
                "sun/jmx/remote/internal/PRef\1\0$com/sun/jmx/remote/internal/Pr"+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1969
                "oxyRef\1\0\23java/lang/Exception\1\0\3ref\1\0\33Ljava/rmi/serve"+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1970
                "r/RemoteRef;\1\0\31java/rmi/server/RemoteRef\0!\0\4\0\5\0\0\0\0"+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1971
                "\0\2\0\1\0\6\0\7\0\1\0\10\0\0\0\22\0\2\0\2\0\0\0\6*+\267\0\1\261"+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1972
                "\0\0\0\0\0\1\0\11\0\12\0\2\0\10\0\0\0\33\0\6\0\6\0\0\0\17*\264\0"+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1973
                "\2+,-\26\4\271\0\3\6\0\260\0\0\0\0\0\13\0\0\0\4\0\1\0\14\0\0";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1974
        final byte[] pRefByteCode =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1975
                NoCallStackClassLoader.stringToBytes(pRefByteCodeString);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1976
        PrivilegedExceptionAction<Constructor<?>> action =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1977
                new PrivilegedExceptionAction<Constructor<?>>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1978
            public Constructor<?> run() throws Exception {
24871
224e298c3978 8044865: Fix raw and unchecked lint warnings in management-related code
sjiang
parents: 21656
diff changeset
  1979
                Class<RMIConnector> thisClass = RMIConnector.class;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1980
                ClassLoader thisLoader = thisClass.getClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1981
                ProtectionDomain thisProtectionDomain =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1982
                        thisClass.getProtectionDomain();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1983
                String[] otherClassNames = {ProxyRef.class.getName()};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1984
                ClassLoader cl =
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1985
                        new NoCallStackClassLoader(pRefClassName,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1986
                        pRefByteCode,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1987
                        otherClassNames,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1988
                        thisLoader,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  1989
                        thisProtectionDomain);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1990
                Class<?> c = cl.loadClass(pRefClassName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1991
                return c.getConstructor(RemoteRef.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1992
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1993
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1994
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  1995
        Class<?> serverStubClass;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1996
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1997
            serverStubClass = Class.forName(rmiServerImplStubClassName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1998
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1999
            logger.error("<clinit>",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2000
                    "Failed to instantiate " +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2001
                    rmiServerImplStubClassName + ": " + e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2002
            logger.debug("<clinit>",e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2003
            serverStubClass = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2004
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2005
        rmiServerImplStubClass = serverStubClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2006
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2007
        Class<?> stubClass;
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  2008
        Constructor<?> constr;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2009
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2010
            stubClass = Class.forName(rmiConnectionImplStubClassName);
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  2011
            constr = (Constructor<?>) AccessController.doPrivileged(action);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2012
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2013
            logger.error("<clinit>",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2014
                    "Failed to initialize proxy reference constructor "+
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2015
                    "for " + rmiConnectionImplStubClassName + ": " + e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2016
            logger.debug("<clinit>",e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2017
            stubClass = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2018
            constr = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2019
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2020
        rmiConnectionImplStubClass = stubClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2021
        proxyRefConstructor = constr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2022
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2023
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2024
    private static RMIConnection shadowJrmpStub(RemoteObject stub)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2025
    throws InstantiationException, IllegalAccessException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2026
            InvocationTargetException, ClassNotFoundException,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2027
            NoSuchMethodException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2028
        RemoteRef ref = stub.getRef();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2029
        RemoteRef proxyRef = (RemoteRef)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2030
            proxyRefConstructor.newInstance(new Object[] {ref});
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  2031
        final Constructor<?> rmiConnectionImplStubConstructor =
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1446
diff changeset
  2032
            rmiConnectionImplStubClass.getConstructor(RemoteRef.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2033
        Object[] args = {proxyRef};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2034
        RMIConnection proxyStub = (RMIConnection)
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2035
        rmiConnectionImplStubConstructor.newInstance(args);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2036
        return proxyStub;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2037
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2038
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2039
    private static RMIConnection getConnection(RMIServer server,
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2040
            Object credentials,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2041
            boolean checkStub)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2042
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2043
        RMIConnection c = server.newClient(credentials);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2044
        if (checkStub) checkStub(c, rmiConnectionImplStubClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2045
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2046
            if (c.getClass() == rmiConnectionImplStubClass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2047
                return shadowJrmpStub((RemoteObject) c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2048
            logger.trace("getConnection",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2049
                    "Did not wrap " + c.getClass() + " to foil " +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2050
                    "stack search for classes: class loading semantics " +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2051
                    "may be incorrect");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2052
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2053
            logger.error("getConnection",
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2054
                    "Could not wrap " + c.getClass() + " to foil " +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2055
                    "stack search for classes: class loading semantics " +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2056
                    "may be incorrect: " + e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2057
            logger.debug("getConnection",e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2058
            // so just return the original stub, which will work for all
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2059
            // but the most exotic class loading situations
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2060
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2061
        return c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2062
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2063
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2064
    private static byte[] base64ToByteArray(String s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2065
        int sLen = s.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2066
        int numGroups = sLen/4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2067
        if (4*numGroups != sLen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2068
            throw new IllegalArgumentException(
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2069
                    "String length must be a multiple of four.");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2070
        int missingBytesInLastGroup = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2071
        int numFullGroups = numGroups;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2072
        if (sLen != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2073
            if (s.charAt(sLen-1) == '=') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2074
                missingBytesInLastGroup++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2075
                numFullGroups--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2076
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2077
            if (s.charAt(sLen-2) == '=')
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2078
                missingBytesInLastGroup++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2079
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2080
        byte[] result = new byte[3*numGroups - missingBytesInLastGroup];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2081
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2082
        // Translate all full groups from base64 to byte array elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2083
        int inCursor = 0, outCursor = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2084
        for (int i=0; i<numFullGroups; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2085
            int ch0 = base64toInt(s.charAt(inCursor++));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2086
            int ch1 = base64toInt(s.charAt(inCursor++));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2087
            int ch2 = base64toInt(s.charAt(inCursor++));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2088
            int ch3 = base64toInt(s.charAt(inCursor++));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2089
            result[outCursor++] = (byte) ((ch0 << 2) | (ch1 >> 4));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2090
            result[outCursor++] = (byte) ((ch1 << 4) | (ch2 >> 2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2091
            result[outCursor++] = (byte) ((ch2 << 6) | ch3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2092
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2093
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2094
        // Translate partial group, if present
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2095
        if (missingBytesInLastGroup != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2096
            int ch0 = base64toInt(s.charAt(inCursor++));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2097
            int ch1 = base64toInt(s.charAt(inCursor++));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2098
            result[outCursor++] = (byte) ((ch0 << 2) | (ch1 >> 4));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2099
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2100
            if (missingBytesInLastGroup == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2101
                int ch2 = base64toInt(s.charAt(inCursor++));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2102
                result[outCursor++] = (byte) ((ch1 << 4) | (ch2 >> 2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2103
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2104
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2105
        // assert inCursor == s.length()-missingBytesInLastGroup;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2106
        // assert outCursor == result.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2107
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2109
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2111
     * Translates the specified character, which is assumed to be in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2112
     * "Base 64 Alphabet" into its equivalent 6-bit positive integer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2114
     * @throws IllegalArgumentException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2115
     *        c is not in the Base64 Alphabet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2117
    private static int base64toInt(char c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2118
        int result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2119
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2120
        if (c >= base64ToInt.length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2121
            result = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2122
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2123
            result = base64ToInt[c];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2124
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2125
        if (result < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2126
            throw new IllegalArgumentException("Illegal character " + c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2127
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2129
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2130
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2131
     * This array is a lookup table that translates unicode characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2132
     * drawn from the "Base64 Alphabet" (as specified in Table 1 of RFC 2045)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2133
     * into their 6-bit positive integer equivalents.  Characters that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2134
     * are not in the Base64 alphabet but fall within the bounds of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2135
     * array are translated to -1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2137
    private static final byte base64ToInt[] = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2138
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2139
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2140
        -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2141
        55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2142
        5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2143
        24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2144
        35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2145
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2146
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2147
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2148
    // Private stuff - Find / Set default class loader
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2149
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2150
    private ClassLoader pushDefaultClassLoader() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2151
        final Thread t = Thread.currentThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2152
        final ClassLoader old =  t.getContextClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2153
        if (defaultClassLoader != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2154
            AccessController.doPrivileged(new PrivilegedAction<Void>() {
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2155
                public Void run() {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2156
                    t.setContextClassLoader(defaultClassLoader);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2157
                    return null;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2158
                }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2159
            });
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2160
            return old;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2162
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2163
    private void popDefaultClassLoader(final ClassLoader old) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2164
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2165
            public Void run() {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2166
                Thread.currentThread().setContextClassLoader(old);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2167
                return null;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2168
            }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1510
diff changeset
  2169
        });
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2171
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2172
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2173
    // Private variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2174
    //--------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2176
     * @serial The RMIServer stub of the RMI JMX Connector server to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2177
     * which this client connector is (or will be) connected. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2178
     * field can be null when <var>jmxServiceURL</var> is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2179
     * null. This includes the case where <var>jmxServiceURL</var>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2180
     * contains a serialized RMIServer stub. If both
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2181
     * <var>rmiServer</var> and <var>jmxServiceURL</var> are null then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2182
     * serialization will fail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2183
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2184
     * @see #RMIConnector(RMIServer,Map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2185
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2186
    private final RMIServer rmiServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2187
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2188
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2189
     * @serial The JMXServiceURL of the RMI JMX Connector server to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2190
     * which this client connector will be connected. This field can
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2191
     * be null when <var>rmiServer</var> is not null. If both
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2192
     * <var>rmiServer</var> and <var>jmxServiceURL</var> are null then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2193
     * serialization will fail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2194
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2195
     * @see #RMIConnector(JMXServiceURL,Map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2196
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2197
    private final JMXServiceURL jmxServiceURL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2198
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2199
    // ---------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2200
    // WARNING - WARNING - WARNING - WARNING - WARNING - WARNING
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2201
    // ---------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2202
    // Any transient variable which needs to be initialized should
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2203
    // be initialized in the method initTransient()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2204
    private transient Map<String, Object> env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2205
    private transient ClassLoader defaultClassLoader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2206
    private transient RMIConnection connection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2207
    private transient String connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2208
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2209
    private transient long clientNotifSeqNo = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2210
19791
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  2211
    private transient WeakHashMap<Subject, WeakReference<MBeanServerConnection>> rmbscMap;
d0bcc2086175 6566891: RMIConnector: map value referencing map key in WeakHashMap prevents map entry to be removed
sjiang
parents: 18206
diff changeset
  2212
    private transient WeakReference<MBeanServerConnection> nullSubjectConnRef = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2213
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2214
    private transient RMINotifClient rmiNotifClient;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2215
    // = new RMINotifClient(new Integer(0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2217
    private transient long clientNotifCounter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2218
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2219
    private transient boolean connected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2220
    // = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2221
    private transient boolean terminated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2222
    // = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2223
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2224
    private transient Exception closeException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2225
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2226
    private transient NotificationBroadcasterSupport connectionBroadcaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2227
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2228
    private transient ClientCommunicatorAdmin communicatorAdmin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2229
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2230
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2231
     * A static WeakReference to an {@link org.omg.CORBA.ORB ORB} to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2232
     * connect unconnected stubs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2233
     **/
4167
76f44f2d5d4d 6888179: Separate out dependency on CORBA
alanb
parents: 4156
diff changeset
  2234
    private static volatile WeakReference<Object> orb = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2235
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2236
    // TRACES & DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2237
    //---------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2238
    private static String objects(final Object[] objs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2239
        if (objs == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2240
            return "null";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2241
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2242
            return Arrays.asList(objs).toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2244
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2245
    private static String strings(final String[] strs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2246
        return objects(strs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2247
    }
35282
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
  2248
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
  2249
    static String getAttributesNames(AttributeList attributes) {
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
  2250
        return attributes != null ?
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
  2251
                attributes.asList().stream()
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
  2252
                        .map(Attribute::getName)
35310
24e6bd6c0b75 8147857: RMIConnector logs attribute names incorrectly
sgehwolf
parents: 35282
diff changeset
  2253
                        .collect(Collectors.joining(", ", "[", "]"))
35282
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
  2254
                : "[]";
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
  2255
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  2256
}