jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
author rriggs
Tue, 12 Nov 2013 14:03:28 -0500
changeset 21656 d4c777ccb1db
parent 18205 17a6d802d24a
child 23010 6dadb192ad81
permissions -rw-r--r--
8028014: Doclint warning/error cleanup in javax.management Summary: Improve generated html by fixing doclint warnings Reviewed-by: sla, jbachorik
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
     2
 * Copyright (c) 2002, 2012, 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.PermissionCollection;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    36
import java.security.Permissions;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    37
import java.security.PrivilegedAction;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    38
import java.security.PrivilegedActionException;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    39
import java.security.PrivilegedExceptionAction;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    40
import java.security.ProtectionDomain;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    41
import java.util.Arrays;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    42
import java.util.Collections;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    43
import java.util.Map;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    44
import java.util.Set;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    45
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    46
import javax.management.*;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    47
import javax.management.remote.JMXServerErrorException;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    48
import javax.management.remote.NotificationResult;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    49
import javax.management.remote.TargetedNotification;
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    50
import javax.security.auth.Subject;
18205
17a6d802d24a 8009004: Better implementation of RMI connections
jfdenise
parents: 14223
diff changeset
    51
import sun.reflect.misc.ReflectUtil;
14211
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
    52
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import static com.sun.jmx.mbeanserver.Util.cast;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import com.sun.jmx.remote.internal.ServerCommunicatorAdmin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import com.sun.jmx.remote.internal.ServerNotifForwarder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import com.sun.jmx.remote.security.JMXSubjectDomainCombiner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import com.sun.jmx.remote.security.SubjectDelegator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import com.sun.jmx.remote.util.ClassLoaderWithRepository;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import com.sun.jmx.remote.util.ClassLogger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
import com.sun.jmx.remote.util.EnvHelp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
import com.sun.jmx.remote.util.OrderClassLoaders;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <p>Implementation of the {@link RMIConnection} interface.  User
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * code will not usually reference this class.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * Notice that we omit the type parameter from MarshalledObject everywhere,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * even though it would add useful information to the documentation.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * reason is that it was only added in Mustang (Java SE 6), whereas versions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * 1.4 and 2.0 of the JMX API must be implementable on Tiger per our
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * commitments for JSR 255.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
public class RMIConnectionImpl implements RMIConnection, Unreferenced {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * Constructs a new {@link RMIConnection}. This connection can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * used with either the JRMP or IIOP transport. This object does
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * not export itself: it is the responsibility of the caller to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * export it appropriately (see {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * RMIIIOPServerImpl#makeClient(String,Subject)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @param rmiServer The RMIServerImpl object for which this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * connection is created.  The behavior is unspecified if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param connectionId The ID for this connection.  The behavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * is unspecified if this parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @param defaultClassLoader The default ClassLoader to be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * when deserializing marshalled objects.  Can be null, to signify
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * the bootstrap class loader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @param subject the authenticated subject to be used for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * authorization.  Can be null, to signify that no subject has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * been authenticated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @param env the environment containing attributes for the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * <code>RMIServerImpl</code>.  Can be null, equivalent to an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * empty map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public RMIConnectionImpl(RMIServerImpl rmiServer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                             String connectionId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                             ClassLoader defaultClassLoader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                             Subject subject,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                             Map<String,?> env) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        if (rmiServer == null || connectionId == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            throw new NullPointerException("Illegal null argument");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        if (env == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            env = Collections.emptyMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        this.rmiServer = rmiServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        this.connectionId = connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        this.defaultClassLoader = defaultClassLoader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        this.subjectDelegator = new SubjectDelegator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        this.subject = subject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        if (subject == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            this.acc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            this.removeCallerContext = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            this.removeCallerContext =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                SubjectDelegator.checkRemoveCallerContext(subject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            if (this.removeCallerContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                this.acc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                    JMXSubjectDomainCombiner.getDomainCombinerContext(subject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                this.acc =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                    JMXSubjectDomainCombiner.getContext(subject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        this.mbeanServer = rmiServer.getMBeanServer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        final ClassLoader dcl = defaultClassLoader;
14211
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   133
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        this.classLoaderWithRepository =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            AccessController.doPrivileged(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                new PrivilegedAction<ClassLoaderWithRepository>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                    public ClassLoaderWithRepository run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                        return new ClassLoaderWithRepository(
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   139
                                      mbeanServer.getClassLoaderRepository(),
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   140
                                      dcl);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                    }
14211
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   142
                },
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   143
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   144
                withPermissions( new MBeanPermission("*", "getClassLoaderRepository"),
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   145
                                 new RuntimePermission("createClassLoader"))
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   146
            );
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   147
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   148
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   149
        this.defaultContextClassLoader =
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   150
            AccessController.doPrivileged(
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   151
                new PrivilegedAction<ClassLoader>() {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   152
            @Override
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   153
                    public ClassLoader run() {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   154
                        return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   155
                                dcl);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   156
                    }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   157
                });
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   158
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        serverCommunicatorAdmin = new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
          RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        this.env = env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
14211
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   165
    private static AccessControlContext withPermissions(Permission ... perms){
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   166
        Permissions col = new Permissions();
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   167
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   168
        for (Permission thePerm : perms ) {
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   169
            col.add(thePerm);
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   170
        }
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   171
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   172
        final ProtectionDomain pd = new ProtectionDomain(null, col);
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   173
        return new AccessControlContext( new ProtectionDomain[] { pd });
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   174
    }
10681074e61b 7169888: Narrowing resource definitions in JMX RMI connector
dsamersoff
parents: 5506
diff changeset
   175
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   176
    private synchronized ServerNotifForwarder getServerNotifFwd() {
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   177
        // Lazily created when first use. Mainly when
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   178
        // addNotificationListener is first called.
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   179
        if (serverNotifForwarder == null)
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   180
            serverNotifForwarder =
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   181
                new ServerNotifForwarder(mbeanServer,
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   182
                                         env,
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   183
                                         rmiServer.getNotifBuffer(),
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   184
                                         connectionId);
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   185
        return serverNotifForwarder;
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   186
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    public String getConnectionId() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        // We should call reqIncomming() here... shouldn't we?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        return connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public void close() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        final boolean debug = logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        final String  idstr = (debug?"["+this.toString()+"]":null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            if (terminated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                if (debug) logger.debug("close",idstr + " already terminated.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            if (debug) logger.debug("close",idstr + " closing.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            terminated = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            if (serverCommunicatorAdmin != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                serverCommunicatorAdmin.terminate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   211
            if (serverNotifForwarder != null) {
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   212
                serverNotifForwarder.terminate();
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
   213
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        rmiServer.clientClosed(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        if (debug) logger.debug("close",idstr + " closed.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    public void unreferenced() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        logger.debug("unreferenced", "called");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            logger.debug("unreferenced", "done");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            logger.fine("unreferenced", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    //-------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    // MBeanServerConnection Wrapper
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    //-------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    public ObjectInstance createMBean(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                                      ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                                      Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        NotCompliantMBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            final Object params[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                new Object[] { className, name };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                logger.debug("createMBean(String,ObjectName)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                             "connectionId=" + connectionId +", className=" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                             className+", name=" + name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            return (ObjectInstance)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                  CREATE_MBEAN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            if (e instanceof InstanceAlreadyExistsException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                throw (InstanceAlreadyExistsException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            if (e instanceof MBeanRegistrationException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                throw (MBeanRegistrationException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            if (e instanceof NotCompliantMBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                throw (NotCompliantMBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    public ObjectInstance createMBean(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                                      ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                                      ObjectName loaderName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                                      Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        NotCompliantMBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            final Object params[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                new Object[] { className, name, loaderName };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            if (logger.debugOn())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                logger.debug("createMBean(String,ObjectName,ObjectName)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                      "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                      +", className=" + className
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                      +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                      +", loaderName=" + loaderName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            return (ObjectInstance)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                  CREATE_MBEAN_LOADER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            if (e instanceof InstanceAlreadyExistsException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                throw (InstanceAlreadyExistsException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            if (e instanceof MBeanRegistrationException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                throw (MBeanRegistrationException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            if (e instanceof NotCompliantMBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                throw (NotCompliantMBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   325
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    public ObjectInstance createMBean(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                                      ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                                      MarshalledObject params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                                      String signature[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                                      Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        NotCompliantMBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        final Object[] values;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        final boolean debug = logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        if (debug) logger.debug(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                  "createMBean(String,ObjectName,Object[],String[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                  "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                  +", unwrapping parameters using classLoaderWithRepository.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        values =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            nullIsEmpty(unwrap(params, classLoaderWithRepository, Object[].class));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            final Object params2[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                new Object[] { className, name, values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                               nullIsEmpty(signature) };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            if (debug)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
               logger.debug("createMBean(String,ObjectName,Object[],String[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                             +", className=" + className
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                             +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                             +", params=" + objects(values)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                             +", signature=" + strings(signature));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            return (ObjectInstance)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                  CREATE_MBEAN_PARAMS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                  params2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            if (e instanceof InstanceAlreadyExistsException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                throw (InstanceAlreadyExistsException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            if (e instanceof MBeanRegistrationException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                throw (MBeanRegistrationException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            if (e instanceof NotCompliantMBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                throw (NotCompliantMBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   386
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    public ObjectInstance createMBean(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                                 ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                                 ObjectName loaderName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                                 MarshalledObject params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                                 String signature[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                                 Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        NotCompliantMBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        final Object[] values;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        final boolean debug = logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        if (debug) logger.debug(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                 "createMBean(String,ObjectName,ObjectName,Object[],String[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                 +", unwrapping params with MBean extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        values = nullIsEmpty(unwrap(params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                                    getClassLoader(loaderName),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                                    defaultClassLoader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                                    Object[].class));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            final Object params2[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
               new Object[] { className, name, loaderName, values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                              nullIsEmpty(signature) };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
           if (debug) logger.debug(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                 "createMBean(String,ObjectName,ObjectName,Object[],String[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                 +", className=" + className
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                 +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                 +", loaderName=" + loaderName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                 +", params=" + objects(values)
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
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   525
        queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class);
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
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
   560
        queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class);
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,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                      Attribute.class);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                             +", attribute="+attr);
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,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                   AttributeList.class);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                             +", attributes="+attrlist);
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,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
                                    Object[].class));
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
                             +", params="+objects(values)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
                             +", signature="+strings(signature));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                  INVOKE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                  params2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            if (e instanceof MBeanException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                throw (MBeanException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    public String getDefaultDomain(Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
            final Object params[] = new Object[] { };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            if (logger.debugOn())  logger.debug("getDefaultDomain",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
                                    "connectionId=" + connectionId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            return (String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
                  GET_DEFAULT_DOMAIN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    public String[] getDomains(Subject delegationSubject) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
            final Object params[] = new Object[] { };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            if (logger.debugOn())  logger.debug("getDomains",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
                                    "connectionId=" + connectionId);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
            return (String[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
                  GET_DOMAINS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    public MBeanInfo getMBeanInfo(ObjectName name, Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        IntrospectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        ReflectionException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        checkNonNull("ObjectName", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
            final Object params[] = new Object[] { name };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
            if (logger.debugOn())  logger.debug("getMBeanInfo",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
                                    "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                                    +", name="+name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
            return (MBeanInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
                  GET_MBEAN_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                  delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            if (e instanceof IntrospectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                throw (IntrospectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            if (e instanceof ReflectionException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                throw (ReflectionException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    public boolean isInstanceOf(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                                String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
                                Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
        throws InstanceNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
        checkNonNull("ObjectName", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
            final Object params[] = new Object[] { name, className };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            if (logger.debugOn())  logger.debug("isInstanceOf",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
                                    "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
                                    +", name="+name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                                    +", className="+className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
            return ((Boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                  IS_INSTANCE_OF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                  params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                  delegationSubject)).booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
   952
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
    public Integer[] addNotificationListeners(ObjectName[] names,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                      MarshalledObject[] filters,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                      Subject[] delegationSubjects)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
            throws InstanceNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        if (names == null || filters == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
            throw new IllegalArgumentException("Got null arguments.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        Subject[] sbjs = (delegationSubjects != null) ? delegationSubjects :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        new Subject[names.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        if (names.length != filters.length || filters.length != sbjs.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
            final String msg =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                "The value lengths of 3 parameters are not same.";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
            throw new IllegalArgumentException(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        for (int i=0; i<names.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
            if (names[i] == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                throw new IllegalArgumentException("Null Object name.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
        int i=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
        ClassLoader targetCl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
        NotificationFilter[] filterValues =
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
   979
            new NotificationFilter[names.length];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        Integer[] ids = new Integer[names.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
            for (; i<names.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                targetCl = getClassLoaderFor(names[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                                        "(ObjectName,NotificationFilter)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                                        "connectionId=" + connectionId +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                      " unwrapping filter with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                filterValues[i] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
                    unwrap(filters[i], targetCl, defaultClassLoader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
                           NotificationFilter.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
                if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
                                        "(ObjectName,NotificationFilter)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
                                        "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                                        +", name=" + names[i]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
                                        +", filter=" + filterValues[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
                ids[i] = (Integer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
                    doPrivilegedOperation(ADD_NOTIFICATION_LISTENERS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
                                          new Object[] { names[i],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
                                                         filterValues[i] },
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
                                          sbjs[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
            return ids;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
            // remove all registered listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
            for (int j=0; j<i; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                try {
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1014
                    getServerNotifFwd().removeNotificationListener(names[j],
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1015
                                                                   ids[j]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                } catch (Exception eee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
                    // strange
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
            if (e instanceof PrivilegedActionException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
                e = extractException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
            if (e instanceof ClassCastException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
                throw (ClassCastException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
            } else if (e instanceof IOException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
                throw (IOException)e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
            } else if (e instanceof InstanceNotFoundException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
            } else if (e instanceof RuntimeException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
                throw (RuntimeException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
                throw newIOException("Got unexpected server exception: "+e,e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
  1039
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
    public void addNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
                       ObjectName listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
                       MarshalledObject filter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
                       MarshalledObject handback,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                       Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
        throws InstanceNotFoundException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
        checkNonNull("Target MBean name", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
        checkNonNull("Listener MBean name", listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
        final NotificationFilter filterValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
        final Object handbackValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        final ClassLoader targetCl = getClassLoaderFor(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
                 +" unwrapping filter with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
        filterValue =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
            unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
        if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
                 +" unwrapping handback with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
        handbackValue =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
            unwrap(handback, targetCl, defaultClassLoader, Object.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
            final Object params[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
                new Object[] { name, listener, filterValue, handbackValue };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
            if (debug) logger.debug("addNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                             +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
                             +", listenerName=" + listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                             +", filter=" + filterValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                             +", handback=" + handbackValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
              ADD_NOTIFICATION_LISTENER_OBJECTNAME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
    public void removeNotificationListeners(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
                                            Integer[] listenerIDs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
                                            Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
        ListenerNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
        if (name == null || listenerIDs == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
            throw new IllegalArgumentException("Illegal null parameter");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
        for (int i = 0; i < listenerIDs.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
            if (listenerIDs[i] == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
                throw new IllegalArgumentException("Null listener ID");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
            final Object params[] = new Object[] { name, listenerIDs };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
            if (logger.debugOn()) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
                                   "(ObjectName,Integer[])",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
                                   "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
                                   +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
                                   +", listenerIDs=" + objects(listenerIDs));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
              REMOVE_NOTIFICATION_LISTENER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
            if (e instanceof ListenerNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
                throw (ListenerNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
    public void removeNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
                                           ObjectName listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
                                           Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        ListenerNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
        checkNonNull("Target MBean name", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
        checkNonNull("Listener MBean name", listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
            final Object params[] = new Object[] { name, listener };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
            if (logger.debugOn()) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
                                   "(ObjectName,ObjectName)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
                                   "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
                                   +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
                                   +", listenerName=" + listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
              REMOVE_NOTIFICATION_LISTENER_OBJECTNAME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
            if (e instanceof ListenerNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
                throw (ListenerNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
  1175
    @SuppressWarnings("rawtypes")  // MarshalledObject
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
    public void removeNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
                        ObjectName listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
                        MarshalledObject filter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
                        MarshalledObject handback,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
                        Subject delegationSubject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
        throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
        InstanceNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
        ListenerNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
        IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
        checkNonNull("Target MBean name", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
        checkNonNull("Listener MBean name", listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        final NotificationFilter filterValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
        final Object handbackValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
        final boolean debug=logger.debugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
        final ClassLoader targetCl = getClassLoaderFor(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
        if (debug) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
                 +" unwrapping filter with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        filterValue =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
            unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        if (debug) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
                 "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
                 +" unwrapping handback with target extended ClassLoader.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
        handbackValue =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
            unwrap(handback, targetCl, defaultClassLoader, Object.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
            final Object params[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
                new Object[] { name, listener, filterValue, handbackValue };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
            if (debug) logger.debug("removeNotificationListener"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
                 "(ObjectName,ObjectName,NotificationFilter,Object)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
                             "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
                             +", name=" + name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
                             +", listenerName=" + listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
                             +", filter=" + filterValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
                             +", handback=" + handbackValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
            doPrivilegedOperation(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
              REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
              params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
              delegationSubject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
            if (e instanceof InstanceNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
                throw (InstanceNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
            if (e instanceof ListenerNotFoundException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
                throw (ListenerNotFoundException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
            if (e instanceof IOException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
            throw newIOException("Got unexpected server exception: " + e, e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
    public NotificationResult fetchNotifications(long clientSequenceNumber,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
                                                 int maxNotifications,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
                                                 long timeout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
        if (logger.debugOn()) logger.debug("fetchNotifications",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
                               "connectionId=" + connectionId
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
                               +", timeout=" + timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
        if (maxNotifications < 0 || timeout < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
            throw new IllegalArgumentException("Illegal negative argument");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
        final boolean serverTerminated =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
            serverCommunicatorAdmin.reqIncoming();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
            if (serverTerminated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
                // we must not call fetchNotifs() if the server is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
                // terminated (timeout elapsed).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
                return new NotificationResult(0L, 0L,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
                                              new TargetedNotification[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
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
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
  1552
    private static <T> T unwrap(final MarshalledObject<?> mo,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
                                final ClassLoader cl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
                                final Class<T> wrappedClass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
        if (mo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
        try {
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1560
            final ClassLoader old = AccessController.doPrivileged(new SetCcl(cl));
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1561
            try {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1562
                return wrappedClass.cast(mo.get());
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1563
            } catch (ClassNotFoundException cnfe) {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1564
                throw new UnmarshalException(cnfe.toString(), cnfe);
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1565
            } finally {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1566
                AccessController.doPrivileged(new SetCcl(old));
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1567
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
            if (e instanceof IOException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
            if (e instanceof ClassNotFoundException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
                throw new UnmarshalException(e.toString(), e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
            logger.warning("unwrap", "Failed to unmarshall object: " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
            logger.debug("unwrap", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 1247
diff changeset
  1582
    private static <T> T unwrap(final MarshalledObject<?> mo,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
                                final ClassLoader cl1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
                                final ClassLoader cl2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
                                final Class<T> wrappedClass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
        throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
        if (mo == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
        try {
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1591
            ClassLoader orderCL = AccessController.doPrivileged(
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1592
                new PrivilegedExceptionAction<ClassLoader>() {
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1593
                    public ClassLoader run() throws Exception {
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1594
                        return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1595
                                new OrderClassLoaders(cl1, cl2));
5175
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1596
                    }
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1597
                }
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1598
            );
56d64b1e78f9 6893947: Deserialization of RMIConnectionImpl objects should enforce stricter checks [ZDI-CAN-588]
mchung
parents: 4156
diff changeset
  1599
            return unwrap(mo, orderCL, wrappedClass);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
        } catch (PrivilegedActionException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
            Exception e = extractException(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
            if (e instanceof IOException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
                throw (IOException) e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
            if (e instanceof ClassNotFoundException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
                throw new UnmarshalException(e.toString(), e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
            logger.warning("unwrap", "Failed to unmarshall object: " + e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
            logger.debug("unwrap", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
        }
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
     * Construct a new IOException with a nested exception.
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 18205
diff changeset
  1616
     * The nested exception is set only if JDK {@literal >= 1.4}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
    private static IOException newIOException(String message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
                                              Throwable cause) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
        final IOException x = new IOException(message);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
        return EnvHelp.initCause(x,cause);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
     * Iterate until we extract the real exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
     * from a stack of PrivilegedActionExceptions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
    private static Exception extractException(Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
        while (e instanceof PrivilegedActionException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
            e = ((PrivilegedActionException)e).getException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
        return e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
    private static final Object[] NO_OBJECTS = new Object[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
    private static final String[] NO_STRINGS = new String[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
     * The JMX spec doesn't explicitly say that a null Object[] or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
     * String[] in e.g. MBeanServer.invoke is equivalent to an empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
     * array, but the RI behaves that way.  In the interests of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
     * maximal interoperability, we make it so even when we're
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
     * connected to some other JMX implementation that might not do
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
     * that.  This should be clarified in the next version of JMX.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
    private static Object[] nullIsEmpty(Object[] array) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
        return (array == null) ? NO_OBJECTS : array;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
    private static String[] nullIsEmpty(String[] array) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
        return (array == null) ? NO_STRINGS : array;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
     * Similarly, the JMX spec says for some but not all methods in
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
     * MBeanServer that take an ObjectName target, that if it's null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
     * you get this exception.  We specify it for all of them, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
     * make it so for the ones where it's not specified in JMX even if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
     * the JMX implementation doesn't do so.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
    private static void checkNonNull(String what, Object x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
        if (x == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
            RuntimeException wrapped =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
                new IllegalArgumentException(what + " must not be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
            throw new RuntimeOperationsException(wrapped);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
    //------------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
    // private variables
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 final Subject subject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
    private final SubjectDelegator subjectDelegator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
    private final boolean removeCallerContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
    private final AccessControlContext acc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
    private final RMIServerImpl rmiServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
    private final MBeanServer mbeanServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
    private final ClassLoader defaultClassLoader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1687
    private final ClassLoader defaultContextClassLoader;
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1688
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
    private final ClassLoaderWithRepository classLoaderWithRepository;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
    private boolean terminated = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
    private final String connectionId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
    private final ServerCommunicatorAdmin serverCommunicatorAdmin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
    // Method IDs for doOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
    //---------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
        ADD_NOTIFICATION_LISTENERS                              = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
        ADD_NOTIFICATION_LISTENER_OBJECTNAME                    = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
        CREATE_MBEAN                                            = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
        CREATE_MBEAN_PARAMS                                     = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
        CREATE_MBEAN_LOADER                                     = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
        CREATE_MBEAN_LOADER_PARAMS                              = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
        GET_ATTRIBUTE                                           = 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
        GET_ATTRIBUTES                                          = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
        GET_DEFAULT_DOMAIN                                      = 9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
        GET_DOMAINS                                             = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
        GET_MBEAN_COUNT                                         = 11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
        GET_MBEAN_INFO                                          = 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
        GET_OBJECT_INSTANCE                                     = 13;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
        INVOKE                                                  = 14;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
        IS_INSTANCE_OF                                          = 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
        IS_REGISTERED                                           = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
        QUERY_MBEANS                                            = 17;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
        QUERY_NAMES                                             = 18;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
    private final static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
        REMOVE_NOTIFICATION_LISTENER                            = 19;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1739
        REMOVE_NOTIFICATION_LISTENER_OBJECTNAME                 = 20;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1741
        REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK = 21;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1743
        SET_ATTRIBUTE                                           = 22;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1745
        SET_ATTRIBUTES                                          = 23;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
    private final static int
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1747
        UNREGISTER_MBEAN                                        = 24;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
    // SERVER NOTIFICATION
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
    //--------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1510
diff changeset
  1752
    private ServerNotifForwarder serverNotifForwarder;
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 2
diff changeset
  1753
    private Map<String, ?> env;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
    // TRACES & DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
    //---------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
    private static String objects(final Object[] objs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
        if (objs == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
            return "null";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1761
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1762
            return Arrays.asList(objs).toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1763
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1764
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1765
    private static String strings(final String[] strs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1766
        return objects(strs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1767
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1768
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1769
    private static final ClassLogger logger =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1770
        new ClassLogger("javax.management.remote.rmi", "RMIConnectionImpl");
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1771
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1772
    private static final class CombinedClassLoader extends ClassLoader {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1773
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1774
        private final static class ClassLoaderWrapper extends ClassLoader {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1775
            ClassLoaderWrapper(ClassLoader cl) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1776
                super(cl);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1777
            }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1778
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1779
            @Override
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1780
            protected Class<?> loadClass(String name, boolean resolve)
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1781
                    throws ClassNotFoundException {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1782
                return super.loadClass(name, resolve);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1783
            }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1784
        };
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1785
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1786
        final ClassLoaderWrapper defaultCL;
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1787
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1788
        private CombinedClassLoader(ClassLoader parent, ClassLoader defaultCL) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1789
            super(parent);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1790
            this.defaultCL = new ClassLoaderWrapper(defaultCL);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1791
        }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1792
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1793
        @Override
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1794
        protected Class<?> loadClass(String name, boolean resolve)
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1795
        throws ClassNotFoundException {
18205
17a6d802d24a 8009004: Better implementation of RMI connections
jfdenise
parents: 14223
diff changeset
  1796
            ReflectUtil.checkPackageAccess(name);
14223
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1797
            try {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1798
                super.loadClass(name, resolve);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1799
            } catch(Exception e) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1800
                for(Throwable t = e; t != null; t = t.getCause()) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1801
                    if(t instanceof SecurityException) {
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1802
                        throw t==e?(SecurityException)t:new SecurityException(t.getMessage(), e);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1803
                    }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1804
                }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1805
            }
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1806
            final Class<?> cl = defaultCL.loadClass(name, resolve);
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1807
            return cl;
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
754dc892778f 7198296: Problem with classloader in JMX
dsamersoff
parents: 14211
diff changeset
  1810
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1811
}