src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
author never
Mon, 25 Nov 2019 11:13:02 -0800
changeset 59260 b0a649295f25
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234359: [JVMCI] invalidate_nmethod_mirror shouldn't use a phantom reference Reviewed-by: kvn, eosterlund
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
43203
955e87b8f623 8165230: RMIConnection addNotificationListeners failing with specific inputs
hb
parents: 43200
diff changeset
     2
 * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 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
43503
bc7f8619ab70 8173607: JMX RMI connector should be in its own module
dfuchs
parents: 43203
diff changeset
    51
import static javax.management.remote.rmi.RMIConnector.Util.cast;
2
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 =
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
   350
            nullIsEmpty(unwrap(params, classLoaderWithRepository, Object[].class,delegationSubject));
2
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
                             +", signature=" + strings(signature));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            return (ObjectInstance)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                  CREATE_MBEAN_PARAMS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                  params2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            if (e instanceof InstanceAlreadyExistsException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                throw (InstanceAlreadyExistsException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            if (e instanceof MBeanRegistrationException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                throw (MBeanRegistrationException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            if (e instanceof NotCompliantMBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                throw (NotCompliantMBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   387
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    public ObjectInstance createMBean(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                                 ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                                 ObjectName loaderName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                                 MarshalledObject params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                                 String signature[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                                 Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        NotCompliantMBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        final Object[] values;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        final boolean debug = logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        if (debug) logger.debug(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                 "createMBean(String,ObjectName,ObjectName,Object[],String[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                 +", unwrapping params with MBean extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        values = nullIsEmpty(unwrap(params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                                    getClassLoader(loaderName),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                                    defaultClassLoader,
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
   414
                                    Object[].class,delegationSubject));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            final Object params2[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
               new Object[] { className, name, loaderName, values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                              nullIsEmpty(signature) };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
           if (debug) logger.debug(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                 "createMBean(String,ObjectName,ObjectName,Object[],String[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                 +", className=" + className
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                 +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                 +", loaderName=" + loaderName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                 +", signature=" + strings(signature));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            return (ObjectInstance)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                  CREATE_MBEAN_LOADER_PARAMS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                  params2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            if (e instanceof InstanceAlreadyExistsException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                throw (InstanceAlreadyExistsException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            if (e instanceof MBeanRegistrationException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                throw (MBeanRegistrationException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            if (e instanceof NotCompliantMBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                throw (NotCompliantMBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    public void unregisterMBean(ObjectName name, Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            final Object params[] = new Object[] { name };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            if (logger.debugOn()) logger.debug("unregisterMBean",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                 +", name="+name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
              UNREGISTER_MBEAN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            if (e instanceof MBeanRegistrationException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                throw (MBeanRegistrationException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    public ObjectInstance getObjectInstance(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                                            Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        checkNonNull("ObjectName", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            final Object params[] = new Object[] { name };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            if (logger.debugOn()) logger.debug("getObjectInstance",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                 +", name="+name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
            return (ObjectInstance)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                  GET_OBJECT_INSTANCE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   512
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    public Set<ObjectInstance>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        queryMBeans(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                    MarshalledObject query,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                    Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        final QueryExp queryValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        if (debug) logger.debug("queryMBeans",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                 +" unwrapping query with defaultClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
   525
        queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class, delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
            final Object params[] = new Object[] { name, queryValue };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            if (debug) logger.debug("queryMBeans",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                 +", name="+name +", query="+query);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            return cast(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                  QUERY_MBEANS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                  delegationSubject));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   547
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    public Set<ObjectName>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        queryNames(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                   MarshalledObject query,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
                   Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        final QueryExp queryValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        if (debug) logger.debug("queryNames",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                 +" unwrapping query with defaultClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
   560
        queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class, delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            final Object params[] = new Object[] { name, queryValue };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            if (debug) logger.debug("queryNames",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                 +", name="+name +", query="+query);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            return cast(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                  QUERY_NAMES,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                  delegationSubject));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    public boolean isRegistered(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
                                Subject delegationSubject) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            final Object params[] = new Object[] { name };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            return ((Boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                  IS_REGISTERED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                  delegationSubject)).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    public Integer getMBeanCount(Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            final Object params[] = new Object[] { };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            if (logger.debugOn()) logger.debug("getMBeanCount",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                 "connectionId=" + connectionId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
            return (Integer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                  GET_MBEAN_COUNT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    public Object getAttribute(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                               String attribute,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                               Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        AttributeNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            final Object params[] = new Object[] { name, attribute };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            if (logger.debugOn()) logger.debug("getAttribute",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                                   "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                                   +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                                   +", attribute="+ attribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
            return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                  GET_ATTRIBUTE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            if (e instanceof AttributeNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                throw (AttributeNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    public AttributeList getAttributes(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                                       String[] attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                                       Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
            final Object params[] = new Object[] { name, attributes };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            if (logger.debugOn()) logger.debug("getAttributes",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                                   "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                                   +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                                   +", attributes="+ strings(attributes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            return (AttributeList)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                  GET_ATTRIBUTES,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   689
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    public void setAttribute(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                             MarshalledObject attribute,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                             Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        AttributeNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        InvalidAttributeValueException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        final Attribute attr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        if (debug) logger.debug("setAttribute",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                 +" unwrapping attribute with MBean extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        attr = unwrap(attribute,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                      getClassLoaderFor(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                      defaultClassLoader,
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
   710
                      Attribute.class, delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            final Object params[] = new Object[] { name, attr };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
            if (debug) logger.debug("setAttribute",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
                             +", name="+name
35282
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
   718
                             +", attribute name="+attr.getName());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
              SET_ATTRIBUTE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
            if (e instanceof AttributeNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
                throw (AttributeNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
            if (e instanceof InvalidAttributeValueException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
                throw (InvalidAttributeValueException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   742
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    public AttributeList setAttributes(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                         MarshalledObject attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                         Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        final AttributeList attrlist;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        if (debug) logger.debug("setAttributes",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                 +" unwrapping attributes with MBean extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        attrlist =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
            unwrap(attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                   getClassLoaderFor(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                   defaultClassLoader,
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
   761
                   AttributeList.class, delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
            final Object params[] = new Object[] { name, attrlist };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
            if (debug) logger.debug("setAttributes",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
                             +", name="+name
35282
cbcd2afb6070 8130710: Better attributes processing
sjiang
parents: 32639
diff changeset
   769
                             +", attribute names="+RMIConnector.getAttributesNames(attrlist));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            return (AttributeList)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
                  SET_ATTRIBUTES,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   788
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    public Object invoke(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                         String operationName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                         MarshalledObject params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
                         String signature[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
                         Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        checkNonNull("ObjectName", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        checkNonNull("Operation name", operationName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        final Object[] values;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        if (debug) logger.debug("invoke",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
                 +" unwrapping params with MBean extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        values = nullIsEmpty(unwrap(params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
                                    getClassLoaderFor(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
                                    defaultClassLoader,
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
   813
                                    Object[].class, delegationSubject));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
            final Object params2[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
                new Object[] { name, operationName, values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
                               nullIsEmpty(signature) };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
            if (debug) logger.debug("invoke",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
                             +", name="+name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
                             +", operationName="+operationName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
                             +", signature="+strings(signature));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
                  INVOKE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                  params2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
    public String getDefaultDomain(Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            final Object params[] = new Object[] { };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            if (logger.debugOn())  logger.debug("getDefaultDomain",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                                    "connectionId=" + connectionId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
            return (String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                  GET_DEFAULT_DOMAIN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    public String[] getDomains(Subject delegationSubject) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
            final Object params[] = new Object[] { };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
            if (logger.debugOn())  logger.debug("getDomains",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
                                    "connectionId=" + connectionId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
            return (String[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
                  GET_DOMAINS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
    public MBeanInfo getMBeanInfo(ObjectName name, Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        IntrospectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        checkNonNull("ObjectName", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
            final Object params[] = new Object[] { name };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
            if (logger.debugOn())  logger.debug("getMBeanInfo",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
                                    "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                                    +", name="+name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            return (MBeanInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
                  GET_MBEAN_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
            if (e instanceof IntrospectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
                throw (IntrospectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
    public boolean isInstanceOf(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                                String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                                Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
        throws InstanceNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
        checkNonNull("ObjectName", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            final Object params[] = new Object[] { name, className };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
            if (logger.debugOn())  logger.debug("isInstanceOf",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                                    "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
                                    +", name="+name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
                                    +", className="+className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
            return ((Boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                  IS_INSTANCE_OF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                  delegationSubject)).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   951
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
    public Integer[] addNotificationListeners(ObjectName[] names,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
                      MarshalledObject[] filters,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                      Subject[] delegationSubjects)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
            throws InstanceNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        if (names == null || filters == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            throw new IllegalArgumentException("Got null arguments.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
        Subject[] sbjs = (delegationSubjects != null) ? delegationSubjects :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        new Subject[names.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        if (names.length != filters.length || filters.length != sbjs.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
            final String msg =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
                "The value lengths of 3 parameters are not same.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
            throw new IllegalArgumentException(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
        for (int i=0; i<names.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
            if (names[i] == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                throw new IllegalArgumentException("Null Object name.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
        int i=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
        ClassLoader targetCl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
        NotificationFilter[] filterValues =
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   978
            new NotificationFilter[names.length];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
        Integer[] ids = new Integer[names.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
            for (; i<names.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
                targetCl = getClassLoaderFor(names[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                                        "(ObjectName,NotificationFilter)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                                        "connectionId=" + connectionId +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                      " unwrapping filter with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                filterValues[i] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                    unwrap(filters[i], targetCl, defaultClassLoader,
43203
955e87b8f623 8165230: RMIConnection addNotificationListeners failing with specific inputs
hb
parents: 43200
diff changeset
   993
                           NotificationFilter.class, sbjs[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
                if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                                        "(ObjectName,NotificationFilter)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
                                        "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                                        +", name=" + names[i]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                                        +", filter=" + filterValues[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
                ids[i] = (Integer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
                    doPrivilegedOperation(ADD_NOTIFICATION_LISTENERS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
                                          new Object[] { names[i],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                                                         filterValues[i] },
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
                                          sbjs[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
            return ids;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
            // remove all registered listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
            for (int j=0; j<i; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
                try {
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1013
                    getServerNotifFwd().removeNotificationListener(names[j],
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1014
                                                                   ids[j]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                } catch (Exception eee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                    // strange
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
            if (e instanceof PrivilegedActionException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                e = extractException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            if (e instanceof ClassCastException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
                throw (ClassCastException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
            } else if (e instanceof IOException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
                throw (IOException)e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
            } else if (e instanceof InstanceNotFoundException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
            } else if (e instanceof RuntimeException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
                throw (RuntimeException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
                throw newIOException("Got unexpected server exception: "+e,e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
  1038
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
    public void addNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
                       ObjectName listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
                       MarshalledObject filter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
                       MarshalledObject handback,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
                       Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
        throws InstanceNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        checkNonNull("Target MBean name", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
        checkNonNull("Listener MBean name", listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
        final NotificationFilter filterValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
        final Object handbackValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        final ClassLoader targetCl = getClassLoaderFor(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
        if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                 +" unwrapping filter with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
        filterValue =
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1061
            unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class, delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
        if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
                 +" unwrapping handback with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
        handbackValue =
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1069
            unwrap(handback, targetCl, defaultClassLoader, Object.class, delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
            final Object params[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                new Object[] { name, listener, filterValue, handbackValue };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
            if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                             +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                             +", listenerName=" + listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
                             +", filter=" + filterValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                             +", handback=" + handbackValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
              ADD_NOTIFICATION_LISTENER_OBJECTNAME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
    public void removeNotificationListeners(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
                                            Integer[] listenerIDs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
                                            Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
        ListenerNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
        if (name == null || listenerIDs == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
            throw new IllegalArgumentException("Illegal null parameter");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        for (int i = 0; i < listenerIDs.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
            if (listenerIDs[i] == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
                throw new IllegalArgumentException("Null listener ID");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
            final Object params[] = new Object[] { name, listenerIDs };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
            if (logger.debugOn()) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
                                   "(ObjectName,Integer[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
                                   "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
                                   +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
                                   +", listenerIDs=" + objects(listenerIDs));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
              REMOVE_NOTIFICATION_LISTENER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
            if (e instanceof ListenerNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
                throw (ListenerNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
    public void removeNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
                                           ObjectName listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
                                           Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
        ListenerNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        checkNonNull("Target MBean name", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
        checkNonNull("Listener MBean name", listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
            final Object params[] = new Object[] { name, listener };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
            if (logger.debugOn()) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
                                   "(ObjectName,ObjectName)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
                                   "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
                                   +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
                                   +", listenerName=" + listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
              REMOVE_NOTIFICATION_LISTENER_OBJECTNAME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
            if (e instanceof ListenerNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
                throw (ListenerNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
  1174
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
    public void removeNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
                        ObjectName listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
                        MarshalledObject filter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
                        MarshalledObject handback,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
                        Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
        ListenerNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        checkNonNull("Target MBean name", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
        checkNonNull("Listener MBean name", listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
        final NotificationFilter filterValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        final Object handbackValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
        final ClassLoader targetCl = getClassLoaderFor(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
        if (debug) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
                 +" unwrapping filter with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
        filterValue =
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1200
            unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class, delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
        if (debug) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
                 +" unwrapping handback with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
        handbackValue =
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1208
            unwrap(handback, targetCl, defaultClassLoader, Object.class, delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
            final Object params[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
                new Object[] { name, listener, filterValue, handbackValue };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
            if (debug) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
                             +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
                             +", listenerName=" + listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
                             +", filter=" + filterValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
                             +", handback=" + handbackValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
              REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
            if (e instanceof ListenerNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
                throw (ListenerNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
    public NotificationResult fetchNotifications(long clientSequenceNumber,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
                                                 int maxNotifications,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
                                                 long timeout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
        if (logger.debugOn()) logger.debug("fetchNotifications",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
                               "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
                               +", timeout=" + timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
        if (maxNotifications < 0 || timeout < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
            throw new IllegalArgumentException("Illegal negative argument");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        final boolean serverTerminated =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
            serverCommunicatorAdmin.reqIncoming();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
            if (serverTerminated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
                // we must not call fetchNotifs() if the server is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
                // terminated (timeout elapsed).
29273
f32302d0ba47 8073148: "The server has decided to close this client connection" repeated continuously
sjiang
parents: 25859
diff changeset
  1256
                // 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
  1257
                if (logger.debugOn()) logger.debug("fetchNotifications",
f32302d0ba47 8073148: "The server has decided to close this client connection" repeated continuously
sjiang
parents: 25859
diff changeset
  1258
                               "The notification server has been closed, "
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
                return null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
            final long csn = clientSequenceNumber;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
            final int mn = maxNotifications;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
            final long t = timeout;
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1265
            PrivilegedAction<NotificationResult> action =
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1266
                new PrivilegedAction<NotificationResult>() {
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1267
                    public NotificationResult run() {
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1268
                        return getServerNotifFwd().fetchNotifs(csn, t, mn);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
            };
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1271
            if (acc == null)
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1272
                return action.run();
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1273
            else
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1274
                return AccessController.doPrivileged(action, acc);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
            serverCommunicatorAdmin.rspOutgoing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
     * <p>Returns a string representation of this object.  In general,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
     * the <code>toString</code> method returns a string that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
     * "textually represents" this object. The result should be a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
     * concise but informative representation that is easy for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
     * person to read.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
     * @return a String representation of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
     **/
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1289
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
        return super.toString() + ": connectionId=" + connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
    // private classes
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 class PrivilegedOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
            implements PrivilegedExceptionAction<Object> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
        public PrivilegedOperation(int operation, Object[] params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
            this.operation = operation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
            this.params = params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
        public Object run() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
            return doOperation(operation, params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
        private int operation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
        private Object[] params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
    // private classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
    private class RMIServerCommunicatorAdmin extends ServerCommunicatorAdmin {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
        public RMIServerCommunicatorAdmin(long timeout) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
            super(timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
        protected void doStop() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
                close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
            } catch (IOException ie) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
                logger.warning("RMIServerCommunicatorAdmin-doStop",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
                               "Failed to close: " + ie);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
                logger.debug("RMIServerCommunicatorAdmin-doStop",ie);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
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
    // private methods
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 ClassLoader getClassLoader(final ObjectName name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
        throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
            return
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
                AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
                    new PrivilegedExceptionAction<ClassLoader>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
                        public ClassLoader run() throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
                            return mbeanServer.getClassLoader(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
                        }
14211
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
  1348
                    },
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
  1349
                    withPermissions(new MBeanPermission("*", "getClassLoader"))
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
  1350
            );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
            throw (InstanceNotFoundException) extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
    private ClassLoader getClassLoaderFor(final ObjectName name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
        throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
            return (ClassLoader)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
                AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
                    new PrivilegedExceptionAction<Object>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
                        public Object run() throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
                            return mbeanServer.getClassLoaderFor(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
                        }
14211
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
  1365
                    },
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
  1366
                    withPermissions(new MBeanPermission("*", "getClassLoaderFor"))
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
  1367
            );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
            throw (InstanceNotFoundException) extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
    private Object doPrivilegedOperation(final int operation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
                                         final Object[] params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
                                         final Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
        throws PrivilegedActionException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
        serverCommunicatorAdmin.reqIncoming();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
            final AccessControlContext reqACC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
            if (delegationSubject == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
                reqACC = acc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
                if (subject == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
                    final String msg =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
                        "Subject delegation cannot be enabled unless " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
                        "an authenticated subject is put in place";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
                    throw new SecurityException(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
                reqACC = subjectDelegator.delegatedContext(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
                    acc, delegationSubject, removeCallerContext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
            PrivilegedOperation op =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
                new PrivilegedOperation(operation, params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
            if (reqACC == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
                    return op.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
                } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
                    if (e instanceof RuntimeException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
                        throw (RuntimeException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
                    throw new PrivilegedActionException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
                return AccessController.doPrivileged(op, reqACC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
        } catch (Error e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
            throw new JMXServerErrorException(e.toString(),e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
            serverCommunicatorAdmin.rspOutgoing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
    private Object doOperation(int operation, Object[] params)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
        throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
        switch (operation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
        case CREATE_MBEAN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
            return mbeanServer.createMBean((String)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
                                           (ObjectName)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
        case CREATE_MBEAN_LOADER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
            return mbeanServer.createMBean((String)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
                                           (ObjectName)params[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
                                           (ObjectName)params[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
        case CREATE_MBEAN_PARAMS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
            return mbeanServer.createMBean((String)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
                                           (ObjectName)params[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
                                           (Object[])params[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
                                           (String[])params[3]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
        case CREATE_MBEAN_LOADER_PARAMS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
            return mbeanServer.createMBean((String)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
                                           (ObjectName)params[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
                                           (ObjectName)params[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
                                           (Object[])params[3],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
                                           (String[])params[4]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
        case GET_ATTRIBUTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
            return mbeanServer.getAttribute((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
                                            (String)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
        case GET_ATTRIBUTES:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
            return mbeanServer.getAttributes((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
                                             (String[])params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
        case GET_DEFAULT_DOMAIN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
            return mbeanServer.getDefaultDomain();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
        case GET_DOMAINS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
            return mbeanServer.getDomains();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
        case GET_MBEAN_COUNT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
            return mbeanServer.getMBeanCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
        case GET_MBEAN_INFO:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
            return mbeanServer.getMBeanInfo((ObjectName)params[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
        case GET_OBJECT_INSTANCE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
            return mbeanServer.getObjectInstance((ObjectName)params[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
        case INVOKE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
            return mbeanServer.invoke((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
                                      (String)params[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
                                      (Object[])params[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
                                      (String[])params[3]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
        case IS_INSTANCE_OF:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
            return mbeanServer.isInstanceOf((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
                                            (String)params[1])
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
                ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
        case IS_REGISTERED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
            return mbeanServer.isRegistered((ObjectName)params[0])
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
                ? Boolean.TRUE : Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
        case QUERY_MBEANS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
            return mbeanServer.queryMBeans((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
                                           (QueryExp)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
        case QUERY_NAMES:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
            return mbeanServer.queryNames((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
                                          (QueryExp)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
        case SET_ATTRIBUTE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
            mbeanServer.setAttribute((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
                                     (Attribute)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
        case SET_ATTRIBUTES:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
            return mbeanServer.setAttributes((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
                                             (AttributeList)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
        case UNREGISTER_MBEAN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
            mbeanServer.unregisterMBean((ObjectName)params[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
        case ADD_NOTIFICATION_LISTENERS:
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1502
            return getServerNotifFwd().addNotificationListener(
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1503
                                                (ObjectName)params[0],
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1504
                                                (NotificationFilter)params[1]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
        case ADD_NOTIFICATION_LISTENER_OBJECTNAME:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
            mbeanServer.addNotificationListener((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
                                                (ObjectName)params[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
                                                (NotificationFilter)params[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
                                                params[3]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
        case REMOVE_NOTIFICATION_LISTENER:
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1514
            getServerNotifFwd().removeNotificationListener(
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1515
                                                   (ObjectName)params[0],
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1516
                                                   (Integer[])params[1]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
        case REMOVE_NOTIFICATION_LISTENER_OBJECTNAME:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
            mbeanServer.removeNotificationListener((ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
                                                   (ObjectName)params[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
        case REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
            mbeanServer.removeNotificationListener(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
                                          (ObjectName)params[0],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
                                          (ObjectName)params[1],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
                                          (NotificationFilter)params[2],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
                                          params[3]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
            throw new IllegalArgumentException("Invalid operation");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1537
    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
  1538
        private final ClassLoader classLoader;
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1539
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1540
        SetCcl(ClassLoader classLoader) {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1541
            this.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
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1544
        public ClassLoader run() {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1545
            Thread currentThread = Thread.currentThread();
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1546
            ClassLoader old = currentThread.getContextClassLoader();
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1547
            currentThread.setContextClassLoader(classLoader);
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1548
            return old;
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1549
        }
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1550
    }
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1551
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1552
    private <T> T unwrap(final MarshalledObject<?> mo,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
                                final ClassLoader cl,
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1554
                                final Class<T> wrappedClass,
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1555
                                Subject delegationSubject)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
        if (mo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
        try {
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1561
            final ClassLoader old = AccessController.doPrivileged(new SetCcl(cl));
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1562
            try{
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1563
                final AccessControlContext reqACC;
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1564
                if (delegationSubject == null)
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1565
                    reqACC = acc;
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1566
                else {
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1567
                    if (subject == null) {
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1568
                        final String msg =
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1569
                            "Subject delegation cannot be enabled unless " +
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1570
                            "an authenticated subject is put in place";
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1571
                        throw new SecurityException(msg);
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1572
                    }
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1573
                    reqACC = subjectDelegator.delegatedContext(
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1574
                        acc, delegationSubject, removeCallerContext);
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1575
                }
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1576
                if(reqACC != null){
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1577
                    return AccessController.doPrivileged(
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1578
                            (PrivilegedExceptionAction<T>) () ->
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1579
                                    wrappedClass.cast(mo.get()), reqACC);
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1580
                }else{
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1581
                    return wrappedClass.cast(mo.get());
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1582
                }
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1583
            }finally{
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1584
                AccessController.doPrivileged(new SetCcl(old));
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1585
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
            if (e instanceof IOException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
            if (e instanceof ClassNotFoundException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
                throw new UnmarshalException(e.toString(), e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
            logger.warning("unwrap", "Failed to unmarshall object: " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
            logger.debug("unwrap", e);
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1596
        }catch (ClassNotFoundException ex) {
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1597
            logger.warning("unwrap", "Failed to unmarshall object: " + ex);
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1598
            logger.debug("unwrap", ex);
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1599
            throw new UnmarshalException(ex.toString(), ex);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1604
    private <T> T unwrap(final MarshalledObject<?> mo,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
                                final ClassLoader cl1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
                                final ClassLoader cl2,
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1607
                                final Class<T> wrappedClass,
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1608
                                Subject delegationSubject)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
        if (mo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
        try {
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1614
            ClassLoader orderCL = AccessController.doPrivileged(
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1615
                new PrivilegedExceptionAction<ClassLoader>() {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1616
                    public ClassLoader run() throws Exception {
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1617
                        return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1618
                                new OrderClassLoaders(cl1, cl2));
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1619
                    }
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1620
                }
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1621
            );
43200
ac8db82dab60 8158406: Limited Parameter Processing
hb
parents: 35282
diff changeset
  1622
            return unwrap(mo, orderCL, wrappedClass,delegationSubject);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
            if (e instanceof IOException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
            if (e instanceof ClassNotFoundException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
                throw new UnmarshalException(e.toString(), e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
            logger.warning("unwrap", "Failed to unmarshall object: " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
            logger.debug("unwrap", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
     * Construct a new IOException with a nested exception.
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 18205
diff changeset
  1639
     * The nested exception is set only if JDK {@literal >= 1.4}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
    private static IOException newIOException(String message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
                                              Throwable cause) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
        final IOException x = new IOException(message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
        return EnvHelp.initCause(x,cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
     * Iterate until we extract the real exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
     * from a stack of PrivilegedActionExceptions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
    private static Exception extractException(Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
        while (e instanceof PrivilegedActionException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
            e = ((PrivilegedActionException)e).getException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
        return e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
    private static final Object[] NO_OBJECTS = new Object[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
    private static final String[] NO_STRINGS = new String[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
     * The JMX spec doesn't explicitly say that a null Object[] or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
     * String[] in e.g. MBeanServer.invoke is equivalent to an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
     * array, but the RI behaves that way.  In the interests of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
     * maximal interoperability, we make it so even when we're
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
     * connected to some other JMX implementation that might not do
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
     * that.  This should be clarified in the next version of JMX.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
    private static Object[] nullIsEmpty(Object[] array) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
        return (array == null) ? NO_OBJECTS : array;
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 static String[] nullIsEmpty(String[] array) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
        return (array == null) ? NO_STRINGS : array;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
     * Similarly, the JMX spec says for some but not all methods in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
     * MBeanServer that take an ObjectName target, that if it's null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
     * you get this exception.  We specify it for all of them, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
     * make it so for the ones where it's not specified in JMX even if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
     * the JMX implementation doesn't do so.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
    private static void checkNonNull(String what, Object x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
        if (x == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
            RuntimeException wrapped =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
                new IllegalArgumentException(what + " must not be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
            throw new RuntimeOperationsException(wrapped);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
    // private variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
    private final Subject subject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
    private final SubjectDelegator subjectDelegator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
    private final boolean removeCallerContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
    private final AccessControlContext acc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
    private final RMIServerImpl rmiServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
    private final MBeanServer mbeanServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
    private final ClassLoader defaultClassLoader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1710
    private final ClassLoader defaultContextClassLoader;
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1711
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
    private final ClassLoaderWithRepository classLoaderWithRepository;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
    private boolean terminated = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
    private final String connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
    private final ServerCommunicatorAdmin serverCommunicatorAdmin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
    // Method IDs for doOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
    //---------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
        ADD_NOTIFICATION_LISTENERS                              = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
        ADD_NOTIFICATION_LISTENER_OBJECTNAME                    = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
        CREATE_MBEAN                                            = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
        CREATE_MBEAN_PARAMS                                     = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
        CREATE_MBEAN_LOADER                                     = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
        CREATE_MBEAN_LOADER_PARAMS                              = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
        GET_ATTRIBUTE                                           = 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
        GET_ATTRIBUTES                                          = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
        GET_DEFAULT_DOMAIN                                      = 9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
        GET_DOMAINS                                             = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
        GET_MBEAN_COUNT                                         = 11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
        GET_MBEAN_INFO                                          = 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
        GET_OBJECT_INSTANCE                                     = 13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
        INVOKE                                                  = 14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
        IS_INSTANCE_OF                                          = 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
        IS_REGISTERED                                           = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
        QUERY_MBEANS                                            = 17;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
        QUERY_NAMES                                             = 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
        REMOVE_NOTIFICATION_LISTENER                            = 19;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1762
        REMOVE_NOTIFICATION_LISTENER_OBJECTNAME                 = 20;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1764
        REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK = 21;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1766
        SET_ATTRIBUTE                                           = 22;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1768
        SET_ATTRIBUTES                                          = 23;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1770
        UNREGISTER_MBEAN                                        = 24;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1772
    // SERVER NOTIFICATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1773
    //--------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1774
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1775
    private ServerNotifForwarder serverNotifForwarder;
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1776
    private Map<String, ?> env;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1777
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
    // TRACES & DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1779
    //---------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1780
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1781
    private static String objects(final Object[] objs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1782
        if (objs == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1783
            return "null";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1784
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
            return Arrays.asList(objs).toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1786
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1787
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1788
    private static String strings(final String[] strs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1789
        return objects(strs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1791
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1792
    private static final ClassLogger logger =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
        new ClassLogger("javax.management.remote.rmi", "RMIConnectionImpl");
14223
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
    private static final class CombinedClassLoader extends ClassLoader {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1796
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1797
        private final static class ClassLoaderWrapper extends ClassLoader {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1798
            ClassLoaderWrapper(ClassLoader cl) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1799
                super(cl);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1800
            }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1801
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1802
            @Override
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1803
            protected Class<?> loadClass(String name, boolean resolve)
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1804
                    throws ClassNotFoundException {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1805
                return super.loadClass(name, resolve);
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 ClassLoaderWrapper defaultCL;
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1810
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1811
        private CombinedClassLoader(ClassLoader parent, ClassLoader defaultCL) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1812
            super(parent);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1813
            this.defaultCL = new ClassLoaderWrapper(defaultCL);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1814
        }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1815
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1816
        @Override
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1817
        protected Class<?> loadClass(String name, boolean resolve)
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1818
        throws ClassNotFoundException {
18205
17a6d802d24a 8009004: Better implementation of RMI connections
jfdenise
parents: 14223
diff changeset
  1819
            ReflectUtil.checkPackageAccess(name);
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1820
            try {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1821
                super.loadClass(name, resolve);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1822
            } catch(Exception e) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1823
                for(Throwable t = e; t != null; t = t.getCause()) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1824
                    if(t instanceof SecurityException) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1825
                        throw t==e?(SecurityException)t:new SecurityException(t.getMessage(), e);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1826
                    }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1827
                }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1828
            }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1829
            final Class<?> cl = defaultCL.loadClass(name, resolve);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1830
            return cl;
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1831
        }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1832
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1833
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1834
}