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