jdk/src/java.management/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
author jbachorik
Tue, 03 Mar 2015 18:19:41 +0100
changeset 32639 339de1317e84
parent 31705 6fbc92f64425
child 35282 cbcd2afb6070
permissions -rw-r--r--
8043937: Drop support for the IIOP transport from the JMX RMIConnector Reviewed-by: alanb, erikj
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: 31705
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: 5175
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: 5175
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: 5175
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5175
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5175
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
14211
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    28
import java.io.IOException;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    29
import java.rmi.MarshalledObject;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    30
import java.rmi.UnmarshalException;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    31
import java.rmi.server.Unreferenced;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    32
import java.security.AccessControlContext;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    33
import java.security.AccessController;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    34
import java.security.Permission;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    35
import java.security.Permissions;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    36
import java.security.PrivilegedAction;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    37
import java.security.PrivilegedActionException;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    38
import java.security.PrivilegedExceptionAction;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    39
import java.security.ProtectionDomain;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    40
import java.util.Arrays;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    41
import java.util.Collections;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    42
import java.util.Map;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    43
import java.util.Set;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    44
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    45
import javax.management.*;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    46
import javax.management.remote.JMXServerErrorException;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    47
import javax.management.remote.NotificationResult;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    48
import javax.security.auth.Subject;
18205
17a6d802d24a 8009004: Better implementation of RMI connections
jfdenise
parents: 14223
diff changeset
    49
import sun.reflect.misc.ReflectUtil;
14211
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    50
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import static com.sun.jmx.mbeanserver.Util.cast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import com.sun.jmx.remote.internal.ServerCommunicatorAdmin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import com.sun.jmx.remote.internal.ServerNotifForwarder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import com.sun.jmx.remote.security.JMXSubjectDomainCombiner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import com.sun.jmx.remote.security.SubjectDelegator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import com.sun.jmx.remote.util.ClassLoaderWithRepository;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import com.sun.jmx.remote.util.ClassLogger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import com.sun.jmx.remote.util.EnvHelp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import com.sun.jmx.remote.util.OrderClassLoaders;
31705
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
    60
import javax.management.loading.ClassLoaderRepository;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <p>Implementation of the {@link RMIConnection} interface.  User
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * code will not usually reference this class.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * Notice that we omit the type parameter from MarshalledObject everywhere,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * even though it would add useful information to the documentation.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * reason is that it was only added in Mustang (Java SE 6), whereas versions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * 1.4 and 2.0 of the JMX API must be implementable on Tiger per our
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * commitments for JSR 255.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
public class RMIConnectionImpl implements RMIConnection, Unreferenced {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Constructs a new {@link RMIConnection}. This connection can be
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 31705
diff changeset
    79
     * used with the JRMP transport. This object does
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * not export itself: it is the responsibility of the caller to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * export it appropriately (see {@link
32639
339de1317e84 8043937: Drop support for the IIOP transport from the JMX RMIConnector
jbachorik
parents: 31705
diff changeset
    82
     * RMIJRMPServerImpl#makeClient(String,Subject)}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @param rmiServer The RMIServerImpl object for which this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * connection is created.  The behavior is unspecified if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @param connectionId The ID for this connection.  The behavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * is unspecified if this parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param defaultClassLoader The default ClassLoader to be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * when deserializing marshalled objects.  Can be null, to signify
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * the bootstrap class loader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param subject the authenticated subject to be used for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * authorization.  Can be null, to signify that no subject has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * been authenticated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @param env the environment containing attributes for the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * <code>RMIServerImpl</code>.  Can be null, equivalent to an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * empty map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public RMIConnectionImpl(RMIServerImpl rmiServer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                             String connectionId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                             ClassLoader defaultClassLoader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                             Subject subject,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                             Map<String,?> env) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        if (rmiServer == null || connectionId == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            throw new NullPointerException("Illegal null argument");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        if (env == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            env = Collections.emptyMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        this.rmiServer = rmiServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        this.connectionId = connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        this.defaultClassLoader = defaultClassLoader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        this.subjectDelegator = new SubjectDelegator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        this.subject = subject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        if (subject == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            this.acc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            this.removeCallerContext = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            this.removeCallerContext =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                SubjectDelegator.checkRemoveCallerContext(subject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            if (this.removeCallerContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                this.acc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                    JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                this.acc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                    JMXSubjectDomainCombiner.getContext(subject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        this.mbeanServer = rmiServer.getMBeanServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        final ClassLoader dcl = defaultClassLoader;
14211
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   131
31705
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   132
        ClassLoaderRepository repository = AccessController.doPrivileged(
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   133
            new PrivilegedAction<ClassLoaderRepository>() {
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   134
                public ClassLoaderRepository run() {
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   135
                    return mbeanServer.getClassLoaderRepository();
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   136
                }
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   137
            },
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   138
            withPermissions(new MBeanPermission("*", "getClassLoaderRepository"))
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   139
        );
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   140
        this.classLoaderWithRepository = AccessController.doPrivileged(
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   141
            new PrivilegedAction<ClassLoaderWithRepository>() {
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   142
                public ClassLoaderWithRepository run() {
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   143
                    return new ClassLoaderWithRepository(
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   144
                        repository,
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   145
                        dcl);
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   146
                }
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   147
            },
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   148
            withPermissions(new RuntimePermission("createClassLoader"))
6fbc92f64425 8075853: Proxy for MBean proxies
sjiang
parents: 29273
diff changeset
   149
        );
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   150
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   151
        this.defaultContextClassLoader =
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   152
            AccessController.doPrivileged(
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   153
                new PrivilegedAction<ClassLoader>() {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   154
            @Override
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   155
                    public ClassLoader run() {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   156
                        return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   157
                                dcl);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   158
                    }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   159
                });
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   160
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        serverCommunicatorAdmin = new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
          RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        this.env = env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
14211
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   167
    private static AccessControlContext withPermissions(Permission ... perms){
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   168
        Permissions col = new Permissions();
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   169
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   170
        for (Permission thePerm : perms ) {
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   171
            col.add(thePerm);
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   172
        }
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   173
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   174
        final ProtectionDomain pd = new ProtectionDomain(null, col);
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   175
        return new AccessControlContext( new ProtectionDomain[] { pd });
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   176
    }
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   177
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   178
    private synchronized ServerNotifForwarder getServerNotifFwd() {
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   179
        // Lazily created when first use. Mainly when
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   180
        // addNotificationListener is first called.
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   181
        if (serverNotifForwarder == null)
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   182
            serverNotifForwarder =
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   183
                new ServerNotifForwarder(mbeanServer,
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   184
                                         env,
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   185
                                         rmiServer.getNotifBuffer(),
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   186
                                         connectionId);
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   187
        return serverNotifForwarder;
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   188
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public String getConnectionId() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        // We should call reqIncomming() here... shouldn't we?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        return connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public void close() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        final boolean debug = logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        final String  idstr = (debug?"["+this.toString()+"]":null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            if (terminated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                if (debug) logger.debug("close",idstr + " already terminated.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            if (debug) logger.debug("close",idstr + " closing.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            terminated = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            if (serverCommunicatorAdmin != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                serverCommunicatorAdmin.terminate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   213
            if (serverNotifForwarder != null) {
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   214
                serverNotifForwarder.terminate();
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   215
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        rmiServer.clientClosed(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        if (debug) logger.debug("close",idstr + " closed.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    public void unreferenced() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        logger.debug("unreferenced", "called");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            logger.debug("unreferenced", "done");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            logger.fine("unreferenced", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
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
    // MBeanServerConnection Wrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    //-------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    public ObjectInstance createMBean(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                                      ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                                      Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        NotCompliantMBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            final Object params[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                new Object[] { className, name };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                logger.debug("createMBean(String,ObjectName)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                             "connectionId=" + connectionId +", className=" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                             className+", name=" + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            return (ObjectInstance)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                  CREATE_MBEAN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            if (e instanceof InstanceAlreadyExistsException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                throw (InstanceAlreadyExistsException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            if (e instanceof MBeanRegistrationException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                throw (MBeanRegistrationException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            if (e instanceof NotCompliantMBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                throw (NotCompliantMBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    public ObjectInstance createMBean(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                                      ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                                      ObjectName loaderName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                                      Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        NotCompliantMBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            final Object params[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                new Object[] { className, name, loaderName };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                logger.debug("createMBean(String,ObjectName,ObjectName)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                      "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                      +", className=" + className
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                      +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                      +", loaderName=" + loaderName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            return (ObjectInstance)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                  CREATE_MBEAN_LOADER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            if (e instanceof InstanceAlreadyExistsException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                throw (InstanceAlreadyExistsException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            if (e instanceof MBeanRegistrationException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                throw (MBeanRegistrationException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            if (e instanceof NotCompliantMBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                throw (NotCompliantMBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   327
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    public ObjectInstance createMBean(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                                      ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                                      MarshalledObject params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                                      String signature[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                                      Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        NotCompliantMBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        final Object[] values;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        final boolean debug = logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        if (debug) logger.debug(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                  "createMBean(String,ObjectName,Object[],String[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                  "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                  +", unwrapping parameters using classLoaderWithRepository.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        values =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            nullIsEmpty(unwrap(params, classLoaderWithRepository, Object[].class));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            final Object params2[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                new Object[] { className, name, values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                               nullIsEmpty(signature) };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            if (debug)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
               logger.debug("createMBean(String,ObjectName,Object[],String[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                             +", className=" + className
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                             +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                             +", params=" + objects(values)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                             +", signature=" + strings(signature));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            return (ObjectInstance)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                  CREATE_MBEAN_PARAMS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                  params2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            if (e instanceof InstanceAlreadyExistsException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                throw (InstanceAlreadyExistsException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            if (e instanceof MBeanRegistrationException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                throw (MBeanRegistrationException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            if (e instanceof NotCompliantMBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                throw (NotCompliantMBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   388
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    public ObjectInstance createMBean(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                                 ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                                 ObjectName loaderName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                                 MarshalledObject params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                                 String signature[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                                 Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        NotCompliantMBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        final Object[] values;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        final boolean debug = logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        if (debug) logger.debug(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                 "createMBean(String,ObjectName,ObjectName,Object[],String[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                 +", unwrapping params with MBean extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        values = nullIsEmpty(unwrap(params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                                    getClassLoader(loaderName),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                                    defaultClassLoader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                                    Object[].class));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            final Object params2[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
               new Object[] { className, name, loaderName, values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                              nullIsEmpty(signature) };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
           if (debug) logger.debug(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                 "createMBean(String,ObjectName,ObjectName,Object[],String[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                 +", className=" + className
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                 +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                 +", loaderName=" + loaderName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                 +", params=" + objects(values)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                 +", signature=" + strings(signature));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            return (ObjectInstance)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                  CREATE_MBEAN_LOADER_PARAMS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                  params2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            if (e instanceof InstanceAlreadyExistsException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                throw (InstanceAlreadyExistsException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            if (e instanceof MBeanRegistrationException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                throw (MBeanRegistrationException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            if (e instanceof NotCompliantMBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                throw (NotCompliantMBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    public void unregisterMBean(ObjectName name, Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            final Object params[] = new Object[] { name };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            if (logger.debugOn()) logger.debug("unregisterMBean",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                 +", name="+name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
              UNREGISTER_MBEAN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            if (e instanceof MBeanRegistrationException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                throw (MBeanRegistrationException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    public ObjectInstance getObjectInstance(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                                            Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        checkNonNull("ObjectName", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            final Object params[] = new Object[] { name };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            if (logger.debugOn()) logger.debug("getObjectInstance",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                 +", name="+name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
            return (ObjectInstance)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                  GET_OBJECT_INSTANCE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   514
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    public Set<ObjectInstance>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        queryMBeans(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                    MarshalledObject query,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                    Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        final QueryExp queryValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        if (debug) logger.debug("queryMBeans",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                 +" unwrapping query with defaultClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   527
        queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            final Object params[] = new Object[] { name, queryValue };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            if (debug) logger.debug("queryMBeans",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                 +", name="+name +", query="+query);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            return cast(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                  QUERY_MBEANS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                  delegationSubject));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   549
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    public Set<ObjectName>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        queryNames(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
                   MarshalledObject query,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                   Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        final QueryExp queryValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        if (debug) logger.debug("queryNames",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                 +" unwrapping query with defaultClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   562
        queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            final Object params[] = new Object[] { name, queryValue };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            if (debug) logger.debug("queryNames",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                 +", name="+name +", query="+query);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            return cast(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                  QUERY_NAMES,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                  delegationSubject));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    public boolean isRegistered(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
                                Subject delegationSubject) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            final Object params[] = new Object[] { name };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            return ((Boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                  IS_REGISTERED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                  delegationSubject)).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            throw newIOException("Got unexpected server exception: " + e, e);
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
    public Integer getMBeanCount(Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            final Object params[] = new Object[] { };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
            if (logger.debugOn()) logger.debug("getMBeanCount",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                 "connectionId=" + connectionId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            return (Integer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                  GET_MBEAN_COUNT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    public Object getAttribute(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                               String attribute,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                               Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        AttributeNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            final Object params[] = new Object[] { name, attribute };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            if (logger.debugOn()) logger.debug("getAttribute",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                                   "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                                   +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                                   +", attribute="+ attribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                  GET_ATTRIBUTE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            if (e instanceof AttributeNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                throw (AttributeNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    public AttributeList getAttributes(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                                       String[] attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                                       Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            final Object params[] = new Object[] { name, attributes };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            if (logger.debugOn()) logger.debug("getAttributes",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                                   "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                                   +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                                   +", attributes="+ strings(attributes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            return (AttributeList)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                  GET_ATTRIBUTES,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   691
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    public void setAttribute(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                             MarshalledObject attribute,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                             Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        AttributeNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        InvalidAttributeValueException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        final Attribute attr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        if (debug) logger.debug("setAttribute",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                 +" unwrapping attribute with MBean extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        attr = unwrap(attribute,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                      getClassLoaderFor(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                      defaultClassLoader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                      Attribute.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            final Object params[] = new Object[] { name, attr };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
            if (debug) logger.debug("setAttribute",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                             +", name="+name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                             +", attribute="+attr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
              SET_ATTRIBUTE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
            if (e instanceof AttributeNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                throw (AttributeNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            if (e instanceof InvalidAttributeValueException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                throw (InvalidAttributeValueException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   744
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    public AttributeList setAttributes(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                         MarshalledObject attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                         Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        final AttributeList attrlist;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        if (debug) logger.debug("setAttributes",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                 +" unwrapping attributes with MBean extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        attrlist =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
            unwrap(attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                   getClassLoaderFor(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                   defaultClassLoader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                   AttributeList.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
            final Object params[] = new Object[] { name, attrlist };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            if (debug) logger.debug("setAttributes",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                             +", name="+name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
                             +", attributes="+attrlist);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
            return (AttributeList)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                  SET_ATTRIBUTES,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   790
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
    public Object invoke(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
                         String operationName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
                         MarshalledObject params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
                         String signature[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                         Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        checkNonNull("ObjectName", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        checkNonNull("Operation name", operationName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        final Object[] values;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        if (debug) logger.debug("invoke",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
                 +" unwrapping params with MBean extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        values = nullIsEmpty(unwrap(params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                                    getClassLoaderFor(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
                                    defaultClassLoader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
                                    Object[].class));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
            final Object params2[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
                new Object[] { name, operationName, values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
                               nullIsEmpty(signature) };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
            if (debug) logger.debug("invoke",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
                             +", name="+name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
                             +", operationName="+operationName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                             +", params="+objects(values)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
                             +", signature="+strings(signature));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
            return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                  INVOKE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
                  params2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    public String getDefaultDomain(Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            final Object params[] = new Object[] { };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
            if (logger.debugOn())  logger.debug("getDefaultDomain",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                                    "connectionId=" + connectionId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
            return (String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                  GET_DEFAULT_DOMAIN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    public String[] getDomains(Subject delegationSubject) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            final Object params[] = new Object[] { };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
            if (logger.debugOn())  logger.debug("getDomains",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
                                    "connectionId=" + connectionId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
            return (String[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
                  GET_DOMAINS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
    public MBeanInfo getMBeanInfo(ObjectName name, Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        IntrospectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        checkNonNull("ObjectName", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
            final Object params[] = new Object[] { name };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
            if (logger.debugOn())  logger.debug("getMBeanInfo",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
                                    "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
                                    +", name="+name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            return (MBeanInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                  GET_MBEAN_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            if (e instanceof IntrospectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                throw (IntrospectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    public boolean isInstanceOf(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                                String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                                Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
        throws InstanceNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
        checkNonNull("ObjectName", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            final Object params[] = new Object[] { name, className };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
            if (logger.debugOn())  logger.debug("isInstanceOf",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                                    "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
                                    +", name="+name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
                                    +", className="+className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
            return ((Boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                  IS_INSTANCE_OF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                  delegationSubject)).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   954
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
    public Integer[] addNotificationListeners(ObjectName[] names,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
                      MarshalledObject[] filters,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
                      Subject[] delegationSubjects)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            throws InstanceNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        if (names == null || filters == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
            throw new IllegalArgumentException("Got null arguments.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        Subject[] sbjs = (delegationSubjects != null) ? delegationSubjects :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        new Subject[names.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        if (names.length != filters.length || filters.length != sbjs.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
            final String msg =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                "The value lengths of 3 parameters are not same.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
            throw new IllegalArgumentException(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        for (int i=0; i<names.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
            if (names[i] == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
                throw new IllegalArgumentException("Null Object name.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
        int i=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
        ClassLoader targetCl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        NotificationFilter[] filterValues =
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   981
            new NotificationFilter[names.length];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
        Integer[] ids = new Integer[names.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
            for (; i<names.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                targetCl = getClassLoaderFor(names[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                                        "(ObjectName,NotificationFilter)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                                        "connectionId=" + connectionId +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                      " unwrapping filter with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
                filterValues[i] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
                    unwrap(filters[i], targetCl, defaultClassLoader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                           NotificationFilter.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                                        "(ObjectName,NotificationFilter)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
                                        "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                                        +", name=" + names[i]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
                                        +", filter=" + filterValues[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                ids[i] = (Integer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
                    doPrivilegedOperation(ADD_NOTIFICATION_LISTENERS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
                                          new Object[] { names[i],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                                                         filterValues[i] },
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                                          sbjs[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
            return ids;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
            // remove all registered listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
            for (int j=0; j<i; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                try {
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1016
                    getServerNotifFwd().removeNotificationListener(names[j],
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1017
                                                                   ids[j]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
                } catch (Exception eee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
                    // strange
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
            if (e instanceof PrivilegedActionException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
                e = extractException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
            if (e instanceof ClassCastException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
                throw (ClassCastException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
            } else if (e instanceof IOException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
                throw (IOException)e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
            } else if (e instanceof InstanceNotFoundException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
            } else if (e instanceof RuntimeException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
                throw (RuntimeException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
                throw newIOException("Got unexpected server exception: "+e,e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
  1041
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
    public void addNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
                       ObjectName listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                       MarshalledObject filter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
                       MarshalledObject handback,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
                       Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
        throws InstanceNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
        checkNonNull("Target MBean name", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
        checkNonNull("Listener MBean name", listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        final NotificationFilter filterValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        final Object handbackValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        final ClassLoader targetCl = getClassLoaderFor(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
        if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                 +" unwrapping filter with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
        filterValue =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
            unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
                 +" unwrapping handback with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
        handbackValue =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
            unwrap(handback, targetCl, defaultClassLoader, Object.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
            final Object params[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                new Object[] { name, listener, filterValue, handbackValue };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
            if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                             +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                             +", listenerName=" + listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
                             +", filter=" + filterValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
                             +", handback=" + handbackValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
              ADD_NOTIFICATION_LISTENER_OBJECTNAME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
    public void removeNotificationListeners(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
                                            Integer[] listenerIDs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
                                            Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
        ListenerNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        if (name == null || listenerIDs == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
            throw new IllegalArgumentException("Illegal null parameter");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
        for (int i = 0; i < listenerIDs.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
            if (listenerIDs[i] == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
                throw new IllegalArgumentException("Null listener ID");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
            final Object params[] = new Object[] { name, listenerIDs };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
            if (logger.debugOn()) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
                                   "(ObjectName,Integer[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
                                   "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
                                   +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
                                   +", listenerIDs=" + objects(listenerIDs));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
              REMOVE_NOTIFICATION_LISTENER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
            if (e instanceof ListenerNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
                throw (ListenerNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
    public void removeNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
                                           ObjectName listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
                                           Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        ListenerNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
        checkNonNull("Target MBean name", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
        checkNonNull("Listener MBean name", listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
            final Object params[] = new Object[] { name, listener };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
            if (logger.debugOn()) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
                                   "(ObjectName,ObjectName)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
                                   "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
                                   +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
                                   +", listenerName=" + listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
              REMOVE_NOTIFICATION_LISTENER_OBJECTNAME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
            if (e instanceof ListenerNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
                throw (ListenerNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
  1177
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
    public void removeNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
                        ObjectName listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
                        MarshalledObject filter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
                        MarshalledObject handback,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
                        Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        ListenerNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
        checkNonNull("Target MBean name", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        checkNonNull("Listener MBean name", listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
        final NotificationFilter filterValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
        final Object handbackValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
        final ClassLoader targetCl = getClassLoaderFor(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
        if (debug) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
                 +" unwrapping filter with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
        filterValue =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
            unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
        if (debug) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
                 +" unwrapping handback with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
        handbackValue =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
            unwrap(handback, targetCl, defaultClassLoader, Object.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
            final Object params[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
                new Object[] { name, listener, filterValue, handbackValue };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
            if (debug) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
                             +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
                             +", listenerName=" + listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
                             +", filter=" + filterValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
                             +", handback=" + handbackValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
              REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
            if (e instanceof ListenerNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
                throw (ListenerNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
    public NotificationResult fetchNotifications(long clientSequenceNumber,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
                                                 int maxNotifications,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
                                                 long timeout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
        if (logger.debugOn()) logger.debug("fetchNotifications",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
                               "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
                               +", timeout=" + timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        if (maxNotifications < 0 || timeout < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
            throw new IllegalArgumentException("Illegal negative argument");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
        final boolean serverTerminated =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
            serverCommunicatorAdmin.reqIncoming();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
            if (serverTerminated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
                // we must not call fetchNotifs() if the server is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
                // terminated (timeout elapsed).
29273
f32302d0ba47 8073148: "The server has decided to close this client connection" repeated continuously
sjiang
parents: 25859
diff changeset
  1259
                // returns null to force the client to stop fetching
f32302d0ba47 8073148: "The server has decided to close this client connection" repeated continuously
sjiang
parents: 25859
diff changeset
  1260
                if (logger.debugOn()) logger.debug("fetchNotifications",
f32302d0ba47 8073148: "The server has decided to close this client connection" repeated continuously
sjiang
parents: 25859
diff changeset
  1261
                               "The notification server has been closed, "
f32302d0ba47 8073148: "The server has decided to close this client connection" repeated continuously
sjiang
parents: 25859
diff changeset
  1262
                                       + "returns null to force the client to stop fetching");
f32302d0ba47 8073148: "The server has decided to close this client connection" repeated continuously
sjiang
parents: 25859
diff changeset
  1263
                return null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
            final long csn = clientSequenceNumber;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
            final int mn = maxNotifications;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
            final long t = timeout;
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1268
            PrivilegedAction<NotificationResult> action =
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1269
                new PrivilegedAction<NotificationResult>() {
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1270
                    public NotificationResult run() {
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1271
                        return getServerNotifFwd().fetchNotifs(csn, t, mn);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
            };
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1274
            if (acc == null)
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1275
                return action.run();
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1276
            else
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1277
                return AccessController.doPrivileged(action, acc);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
            serverCommunicatorAdmin.rspOutgoing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
     * <p>Returns a string representation of this object.  In general,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
     * the <code>toString</code> method returns a string that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
     * "textually represents" this object. The result should be a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
     * concise but informative representation that is easy for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
     * person to read.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
     * @return a String representation of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
     **/
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1292
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
        return super.toString() + ": connectionId=" + connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
    // private classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
    private class PrivilegedOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
            implements PrivilegedExceptionAction<Object> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
        public PrivilegedOperation(int operation, Object[] params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
            this.operation = operation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
            this.params = params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
        public Object run() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
            return doOperation(operation, params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
        private int operation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
        private Object[] params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
    // private classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
    private class RMIServerCommunicatorAdmin extends ServerCommunicatorAdmin {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
        public RMIServerCommunicatorAdmin(long timeout) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
            super(timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
        protected void doStop() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
                close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
            } catch (IOException ie) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
                logger.warning("RMIServerCommunicatorAdmin-doStop",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
                               "Failed to close: " + ie);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
                logger.debug("RMIServerCommunicatorAdmin-doStop",ie);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
    // private methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
    private ClassLoader getClassLoader(final ObjectName name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
        throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
            return
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
                AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
                    new PrivilegedExceptionAction<ClassLoader>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
                        public ClassLoader run() throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
                            return mbeanServer.getClassLoader(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
                        }
14211
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
  1351
                    },
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
  1352
                    withPermissions(new MBeanPermission("*", "getClassLoader"))
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
  1353
            );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
            throw (InstanceNotFoundException) extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
    private ClassLoader getClassLoaderFor(final ObjectName name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
        throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
            return (ClassLoader)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
                AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
                    new PrivilegedExceptionAction<Object>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
                        public Object run() throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
                            return mbeanServer.getClassLoaderFor(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
                        }
14211
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
  1368
                    },
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
  1369
                    withPermissions(new MBeanPermission("*", "getClassLoaderFor"))
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
  1370
            );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
            throw (InstanceNotFoundException) extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
    private Object doPrivilegedOperation(final int operation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
                                         final Object[] params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
                                         final Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
        throws PrivilegedActionException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
        serverCommunicatorAdmin.reqIncoming();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
            final AccessControlContext reqACC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
            if (delegationSubject == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
                reqACC = acc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
                if (subject == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
                    final String msg =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
                        "Subject delegation cannot be enabled unless " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
                        "an authenticated subject is put in place";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
                    throw new SecurityException(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
                reqACC = subjectDelegator.delegatedContext(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
                    acc, delegationSubject, removeCallerContext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
            PrivilegedOperation op =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
                new PrivilegedOperation(operation, params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
            if (reqACC == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
                    return op.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
                } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
                    if (e instanceof RuntimeException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
                        throw (RuntimeException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
                    throw new PrivilegedActionException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
                return AccessController.doPrivileged(op, reqACC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
        } catch (Error e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
            throw new JMXServerErrorException(e.toString(),e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
            serverCommunicatorAdmin.rspOutgoing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
    private Object doOperation(int operation, Object[] params)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
        throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
        switch (operation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
        case CREATE_MBEAN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
            return mbeanServer.createMBean((String)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
                                           (ObjectName)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
        case CREATE_MBEAN_LOADER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
            return mbeanServer.createMBean((String)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
                                           (ObjectName)params[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
                                           (ObjectName)params[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
        case CREATE_MBEAN_PARAMS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
            return mbeanServer.createMBean((String)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
                                           (ObjectName)params[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
                                           (Object[])params[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
                                           (String[])params[3]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
        case CREATE_MBEAN_LOADER_PARAMS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
            return mbeanServer.createMBean((String)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
                                           (ObjectName)params[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
                                           (ObjectName)params[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
                                           (Object[])params[3],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
                                           (String[])params[4]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
        case GET_ATTRIBUTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
            return mbeanServer.getAttribute((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
                                            (String)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
        case GET_ATTRIBUTES:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
            return mbeanServer.getAttributes((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
                                             (String[])params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
        case GET_DEFAULT_DOMAIN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
            return mbeanServer.getDefaultDomain();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
        case GET_DOMAINS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
            return mbeanServer.getDomains();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
        case GET_MBEAN_COUNT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
            return mbeanServer.getMBeanCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
        case GET_MBEAN_INFO:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
            return mbeanServer.getMBeanInfo((ObjectName)params[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
        case GET_OBJECT_INSTANCE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
            return mbeanServer.getObjectInstance((ObjectName)params[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
        case INVOKE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
            return mbeanServer.invoke((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
                                      (String)params[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
                                      (Object[])params[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
                                      (String[])params[3]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
        case IS_INSTANCE_OF:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
            return mbeanServer.isInstanceOf((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
                                            (String)params[1])
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
                ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
        case IS_REGISTERED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
            return mbeanServer.isRegistered((ObjectName)params[0])
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
                ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
        case QUERY_MBEANS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
            return mbeanServer.queryMBeans((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
                                           (QueryExp)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
        case QUERY_NAMES:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
            return mbeanServer.queryNames((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
                                          (QueryExp)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
        case SET_ATTRIBUTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
            mbeanServer.setAttribute((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
                                     (Attribute)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
        case SET_ATTRIBUTES:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
            return mbeanServer.setAttributes((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
                                             (AttributeList)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
        case UNREGISTER_MBEAN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
            mbeanServer.unregisterMBean((ObjectName)params[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
        case ADD_NOTIFICATION_LISTENERS:
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1505
            return getServerNotifFwd().addNotificationListener(
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1506
                                                (ObjectName)params[0],
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1507
                                                (NotificationFilter)params[1]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
        case ADD_NOTIFICATION_LISTENER_OBJECTNAME:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
            mbeanServer.addNotificationListener((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
                                                (ObjectName)params[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
                                                (NotificationFilter)params[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
                                                params[3]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
        case REMOVE_NOTIFICATION_LISTENER:
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1517
            getServerNotifFwd().removeNotificationListener(
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1518
                                                   (ObjectName)params[0],
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1519
                                                   (Integer[])params[1]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
        case REMOVE_NOTIFICATION_LISTENER_OBJECTNAME:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
            mbeanServer.removeNotificationListener((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
                                                   (ObjectName)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
        case REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
            mbeanServer.removeNotificationListener(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
                                          (ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
                                          (ObjectName)params[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
                                          (NotificationFilter)params[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
                                          params[3]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
            throw new IllegalArgumentException("Invalid operation");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1540
    private static class SetCcl implements PrivilegedExceptionAction<ClassLoader> {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1541
        private final ClassLoader classLoader;
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1542
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1543
        SetCcl(ClassLoader classLoader) {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1544
            this.classLoader = classLoader;
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1545
        }
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1546
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1547
        public ClassLoader run() {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1548
            Thread currentThread = Thread.currentThread();
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1549
            ClassLoader old = currentThread.getContextClassLoader();
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1550
            currentThread.setContextClassLoader(classLoader);
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1551
            return old;
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1552
        }
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1553
    }
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1554
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
  1555
    private static <T> T unwrap(final MarshalledObject<?> mo,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
                                final ClassLoader cl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
                                final Class<T> wrappedClass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
        if (mo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
        try {
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1563
            final ClassLoader old = AccessController.doPrivileged(new SetCcl(cl));
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1564
            try {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1565
                return wrappedClass.cast(mo.get());
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1566
            } catch (ClassNotFoundException cnfe) {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1567
                throw new UnmarshalException(cnfe.toString(), cnfe);
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1568
            } finally {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1569
                AccessController.doPrivileged(new SetCcl(old));
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1570
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
            if (e instanceof IOException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
            if (e instanceof ClassNotFoundException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
                throw new UnmarshalException(e.toString(), e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
            logger.warning("unwrap", "Failed to unmarshall object: " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
            logger.debug("unwrap", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
  1585
    private static <T> T unwrap(final MarshalledObject<?> mo,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
                                final ClassLoader cl1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
                                final ClassLoader cl2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
                                final Class<T> wrappedClass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
        if (mo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
        try {
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1594
            ClassLoader orderCL = AccessController.doPrivileged(
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1595
                new PrivilegedExceptionAction<ClassLoader>() {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1596
                    public ClassLoader run() throws Exception {
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1597
                        return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1598
                                new OrderClassLoaders(cl1, cl2));
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1599
                    }
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1600
                }
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1601
            );
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1602
            return unwrap(mo, orderCL, wrappedClass);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
            if (e instanceof IOException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
            if (e instanceof ClassNotFoundException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
                throw new UnmarshalException(e.toString(), e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
            logger.warning("unwrap", "Failed to unmarshall object: " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
            logger.debug("unwrap", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
     * Construct a new IOException with a nested exception.
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 18205
diff changeset
  1619
     * The nested exception is set only if JDK {@literal >= 1.4}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
    private static IOException newIOException(String message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
                                              Throwable cause) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
        final IOException x = new IOException(message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
        return EnvHelp.initCause(x,cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
     * Iterate until we extract the real exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
     * from a stack of PrivilegedActionExceptions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
    private static Exception extractException(Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
        while (e instanceof PrivilegedActionException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
            e = ((PrivilegedActionException)e).getException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
        return e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
    private static final Object[] NO_OBJECTS = new Object[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
    private static final String[] NO_STRINGS = new String[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
     * The JMX spec doesn't explicitly say that a null Object[] or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
     * String[] in e.g. MBeanServer.invoke is equivalent to an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
     * array, but the RI behaves that way.  In the interests of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
     * maximal interoperability, we make it so even when we're
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
     * connected to some other JMX implementation that might not do
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
     * that.  This should be clarified in the next version of JMX.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
    private static Object[] nullIsEmpty(Object[] array) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
        return (array == null) ? NO_OBJECTS : array;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
    private static String[] nullIsEmpty(String[] array) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
        return (array == null) ? NO_STRINGS : array;
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
     * Similarly, the JMX spec says for some but not all methods in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
     * MBeanServer that take an ObjectName target, that if it's null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
     * you get this exception.  We specify it for all of them, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
     * make it so for the ones where it's not specified in JMX even if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
     * the JMX implementation doesn't do so.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
    private static void checkNonNull(String what, Object x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
        if (x == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
            RuntimeException wrapped =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
                new IllegalArgumentException(what + " must not be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
            throw new RuntimeOperationsException(wrapped);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
    // private variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
    private final Subject subject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
    private final SubjectDelegator subjectDelegator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
    private final boolean removeCallerContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
    private final AccessControlContext acc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
    private final RMIServerImpl rmiServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
    private final MBeanServer mbeanServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
    private final ClassLoader defaultClassLoader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1690
    private final ClassLoader defaultContextClassLoader;
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1691
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
    private final ClassLoaderWithRepository classLoaderWithRepository;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
    private boolean terminated = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
    private final String connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
    private final ServerCommunicatorAdmin serverCommunicatorAdmin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
    // Method IDs for doOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
    //---------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
        ADD_NOTIFICATION_LISTENERS                              = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
        ADD_NOTIFICATION_LISTENER_OBJECTNAME                    = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
        CREATE_MBEAN                                            = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
        CREATE_MBEAN_PARAMS                                     = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
        CREATE_MBEAN_LOADER                                     = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
        CREATE_MBEAN_LOADER_PARAMS                              = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
        GET_ATTRIBUTE                                           = 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
        GET_ATTRIBUTES                                          = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
        GET_DEFAULT_DOMAIN                                      = 9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
        GET_DOMAINS                                             = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
        GET_MBEAN_COUNT                                         = 11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
        GET_MBEAN_INFO                                          = 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
        GET_OBJECT_INSTANCE                                     = 13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
        INVOKE                                                  = 14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
        IS_INSTANCE_OF                                          = 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
        IS_REGISTERED                                           = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
        QUERY_MBEANS                                            = 17;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
        QUERY_NAMES                                             = 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
        REMOVE_NOTIFICATION_LISTENER                            = 19;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1742
        REMOVE_NOTIFICATION_LISTENER_OBJECTNAME                 = 20;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1744
        REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK = 21;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1746
        SET_ATTRIBUTE                                           = 22;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1748
        SET_ATTRIBUTES                                          = 23;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1750
        UNREGISTER_MBEAN                                        = 24;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
    // SERVER NOTIFICATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
    //--------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1755
    private ServerNotifForwarder serverNotifForwarder;
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1756
    private Map<String, ?> env;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
    // TRACES & DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
    //---------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
    private static String objects(final Object[] objs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
        if (objs == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
            return "null";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
            return Arrays.asList(objs).toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
    private static String strings(final String[] strs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
        return objects(strs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
    private static final ClassLogger logger =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
        new ClassLogger("javax.management.remote.rmi", "RMIConnectionImpl");
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1774
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1775
    private static final class CombinedClassLoader extends ClassLoader {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1776
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1777
        private final static class ClassLoaderWrapper extends ClassLoader {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1778
            ClassLoaderWrapper(ClassLoader cl) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1779
                super(cl);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1780
            }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1781
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1782
            @Override
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1783
            protected Class<?> loadClass(String name, boolean resolve)
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1784
                    throws ClassNotFoundException {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1785
                return super.loadClass(name, resolve);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1786
            }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1787
        };
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1788
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1789
        final ClassLoaderWrapper defaultCL;
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1790
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1791
        private CombinedClassLoader(ClassLoader parent, ClassLoader defaultCL) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1792
            super(parent);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1793
            this.defaultCL = new ClassLoaderWrapper(defaultCL);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1794
        }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1795
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1796
        @Override
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1797
        protected Class<?> loadClass(String name, boolean resolve)
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1798
        throws ClassNotFoundException {
18205
17a6d802d24a 8009004: Better implementation of RMI connections
jfdenise
parents: 14223
diff changeset
  1799
            ReflectUtil.checkPackageAccess(name);
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1800
            try {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1801
                super.loadClass(name, resolve);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1802
            } catch(Exception e) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1803
                for(Throwable t = e; t != null; t = t.getCause()) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1804
                    if(t instanceof SecurityException) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1805
                        throw t==e?(SecurityException)t:new SecurityException(t.getMessage(), e);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1806
                    }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1807
                }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1808
            }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1809
            final Class<?> cl = defaultCL.loadClass(name, resolve);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1810
            return cl;
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1811
        }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1812
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1813
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1814
}