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