jdk/src/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java
author dfuchs
Thu, 04 Sep 2008 14:46:36 +0200
changeset 1156 bbc2d15aaf7a
parent 2 90ce3da70b43
child 1510 e747d3193ef2
permissions -rw-r--r--
5072476: RFE: support cascaded (federated) MBean Servers 6299231: Add support for named MBean Servers Summary: New javax.management.namespace package. Reviewed-by: emcmanus
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
     2
 * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
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 com.sun.jmx.mbeanserver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    28
import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    29
import com.sun.jmx.interceptor.NamespaceDispatchInterceptor;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    30
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.security.Permission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.security.PrivilegedExceptionAction;
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    35
import java.util.Iterator;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    36
import java.util.Set;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    37
import java.util.logging.Level;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import javax.management.Attribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import javax.management.AttributeList;
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    41
import javax.management.AttributeNotFoundException;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    42
import javax.management.InstanceAlreadyExistsException;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    43
import javax.management.InstanceNotFoundException;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    44
import javax.management.IntrospectionException;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    45
import javax.management.InvalidAttributeValueException;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    46
import javax.management.ListenerNotFoundException;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    47
import javax.management.MBeanException;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    48
import javax.management.MBeanInfo;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    49
import javax.management.MBeanPermission;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    50
import javax.management.MBeanRegistrationException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import javax.management.MBeanServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import javax.management.MBeanServerDelegate;
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    53
import javax.management.NotCompliantMBeanException;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    54
import javax.management.NotificationFilter;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    55
import javax.management.NotificationListener;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    56
import javax.management.ObjectInstance;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    57
import javax.management.ObjectName;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    58
import javax.management.OperationsException;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    59
import javax.management.QueryExp;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    60
import javax.management.ReflectionException;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
    61
import javax.management.RuntimeOperationsException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
import javax.management.loading.ClassLoaderRepository;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * This is the base class for MBean manipulation on the agent side. It
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * contains the methods necessary for the creation, registration, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * deletion of MBeans as well as the access methods for registered MBeans.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * This is the core component of the JMX infrastructure.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * Every MBean which is added to the MBean server becomes manageable:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * its attributes and operations become remotely accessible through
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * the connectors/adaptors connected to that MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * A Java object cannot be registered in the MBean server unless it is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * JMX compliant MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * When an MBean is registered or unregistered in the MBean server an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * {@link javax.management.MBeanServerNotification MBeanServerNotification}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * Notification is emitted. To register an object as listener to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * MBeanServerNotifications you should call the MBean server method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * {@link #addNotificationListener addNotificationListener} with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * the <CODE>ObjectName</CODE> of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * {@link javax.management.MBeanServerDelegate MBeanServerDelegate}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * This <CODE>ObjectName</CODE> is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * <BR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * <CODE>JMImplementation:type=MBeanServerDelegate</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
public final class JmxMBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    implements SunJmxMBeanServer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /** Control the default locking policy of the repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *  By default, we will be using a fair locking policy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public static final boolean DEFAULT_FAIR_LOCK_POLICY = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private final MBeanInstantiator instantiator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    private final SecureClassLoaderRepository secureClr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /** true if interceptors are enabled **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    private final boolean interceptorsEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
   103
    private final MBeanServer outerShell;
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
   104
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
   105
    private volatile MBeanServer mbsInterceptor = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
   107
    /** The MBeanServerDelegate object representing the MBean Server */
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
   108
    private final MBeanServerDelegate mBeanServerDelegateObject;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
   110
    private final String mbeanServerName;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * <b>Package:</b> Creates an MBeanServer with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * specified default domain name, outer interface, and delegate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * <p>The default domain name is used as the domain part in the ObjectName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * of MBeans if no domain is specified by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * <ul><b>Note:</b>Using this constructor directly is strongly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *     discouraged. You should use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     *     {@link javax.management.MBeanServerFactory#createMBeanServer(java.lang.String)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *     or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *     {@link javax.management.MBeanServerFactory#newMBeanServer(java.lang.String)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *     instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *     <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *     By default, {@link MBeanServerInterceptor} are disabled. Use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *     {@link #JmxMBeanServer(java.lang.String,javax.management.MBeanServer,javax.management.MBeanServerDelegate,boolean)} to enable them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @param domain The default domain name used by this MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @param outer A pointer to the MBeanServer object that must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *        passed to the MBeans when invoking their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *        {@link javax.management.MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param delegate A pointer to the MBeanServerDelegate associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *        with the new MBeanServer. The new MBeanServer must register
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *        this MBean in its MBean repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @exception IllegalArgumentException if the instantiator is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    JmxMBeanServer(String domain, MBeanServer outer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                   MBeanServerDelegate delegate) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        this(domain,outer,delegate,null,false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * <b>Package:</b> Creates an MBeanServer with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * specified default domain name, outer interface, and delegate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * <p>The default domain name is used as the domain part in the ObjectName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * of MBeans if no domain is specified by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * <ul><b>Note:</b>Using this constructor directly is strongly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *     discouraged. You should use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *     {@link javax.management.MBeanServerFactory#createMBeanServer(java.lang.String)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *     or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *     {@link javax.management.MBeanServerFactory#newMBeanServer(java.lang.String)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *     instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @param domain The default domain name used by this MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @param outer A pointer to the MBeanServer object that must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *        passed to the MBeans when invoking their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *        {@link javax.management.MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @param delegate A pointer to the MBeanServerDelegate associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *        with the new MBeanServer. The new MBeanServer must register
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *        this MBean in its MBean repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @param interceptors If <code>true</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *        {@link MBeanServerInterceptor} will be enabled (default is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *        <code>false</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *        Note: this parameter is not taken into account by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *        implementation - the default value <code>false</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *        always used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @exception IllegalArgumentException if the instantiator is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    JmxMBeanServer(String domain, MBeanServer outer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                   MBeanServerDelegate delegate, boolean interceptors) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        this(domain,outer,delegate,null,false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * <b>Package:</b> Creates an MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @param domain The default domain name used by this MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @param outer A pointer to the MBeanServer object that must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *        passed to the MBeans when invoking their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *        {@link javax.management.MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @param delegate A pointer to the MBeanServerDelegate associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     *        with the new MBeanServer. The new MBeanServer must register
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *        this MBean in its MBean repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @param instantiator The MBeanInstantiator that will be used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     *        instantiate MBeans and take care of class loading issues.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @param metadata The MetaData object that will be used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *        MBean server in order to invoke the MBean interface of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *        the registered MBeans.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * @param interceptors If <code>true</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     *        {@link MBeanServerInterceptor} will be enabled (default is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *        <code>false</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    JmxMBeanServer(String domain, MBeanServer outer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                   MBeanServerDelegate    delegate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                   MBeanInstantiator      instantiator,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                   boolean                interceptors)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                   this(domain,outer,delegate,instantiator,interceptors,true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * <b>Package:</b> Creates an MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @param domain The default domain name used by this MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @param outer A pointer to the MBeanServer object that must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *        passed to the MBeans when invoking their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *        {@link javax.management.MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @param delegate A pointer to the MBeanServerDelegate associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *        with the new MBeanServer. The new MBeanServer must register
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *        this MBean in its MBean repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @param instantiator The MBeanInstantiator that will be used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *        instantiate MBeans and take care of class loading issues.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @param metadata The MetaData object that will be used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     *        MBean server in order to invoke the MBean interface of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *        the registered MBeans.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @param interceptors If <code>true</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     *        {@link MBeanServerInterceptor} will be enabled (default is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *        <code>false</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @param fairLock If {@code true}, the MBean repository will use a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *        java.util.concurrent.locks.ReentrantReadWriteLock#ReentrantReadWriteLock(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *        fair locking} policy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    JmxMBeanServer(String domain, MBeanServer outer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                   MBeanServerDelegate    delegate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                   MBeanInstantiator      instantiator,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                   boolean                interceptors,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                   boolean                fairLock)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        if (instantiator == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            final ModifiableClassLoaderRepository
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                clr = new ClassLoaderRepositorySupport();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            instantiator = new MBeanInstantiator(clr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        this.secureClr = new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
          SecureClassLoaderRepository(instantiator.getClassLoaderRepository());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        if (delegate == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            delegate = new MBeanServerDelegateImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        if (outer == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            outer = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        this.instantiator = instantiator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        this.mBeanServerDelegateObject = delegate;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        this.outerShell   = outer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        final Repository repository = new Repository(domain,fairLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        this.mbsInterceptor =
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
   243
            new NamespaceDispatchInterceptor(outer, delegate, instantiator,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                                              repository);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        this.interceptorsEnabled = interceptors;
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
   246
        this.mbeanServerName = Util.getMBeanServerSecurityName(delegate);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        initialize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * Tell whether {@link MBeanServerInterceptor}s are enabled on this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * @return <code>true</code> if {@link MBeanServerInterceptor}s are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     *         enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @see #newMBeanServer(java.lang.String,javax.management.MBeanServer,javax.management.MBeanServerDelegate,boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    public boolean interceptorsEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        return interceptorsEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * Return the MBeanInstantiator associated to this MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * @exception UnsupportedOperationException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     *            {@link MBeanServerInterceptor}s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     *            are not enabled on this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @see #interceptorsEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    public MBeanInstantiator getMBeanInstantiator() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        if (interceptorsEnabled) return instantiator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        else throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                       "MBeanServerInterceptors are disabled.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * Instantiates and registers an MBean in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * The MBean server will use its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * {@link javax.management.loading.ClassLoaderRepository Default Loader Repository}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * to load the class of the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * An object name is associated to the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * If the object name given is null, the MBean can automatically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * provide its own name by implementing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * {@link javax.management.MBeanRegistration MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * The call returns an <CODE>ObjectInstance</CODE> object representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * the newly created MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @param className The class name of the MBean to be instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @param name The object name of the MBean. May be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @return  An <CODE>ObjectInstance</CODE>, containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *     <CODE>ObjectName</CODE> and the Java class name of the newly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     *     instantiated MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @exception ReflectionException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     *     <CODE>{@link java.lang.ClassNotFoundException}</CODE> or an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     *     <CODE>{@link java.lang.Exception}</CODE> that occurred
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     *     when trying to invoke the MBean's constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * @exception InstanceAlreadyExistsException The MBean is already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     *     under the control of the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * @exception MBeanRegistrationException The <CODE>preRegister()</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     *     (<CODE>MBeanRegistration</CODE> interface) method of the MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     *     has thrown an exception. The MBean will not be registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @exception MBeanException The constructor of the MBean has thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     *     an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * @exception NotCompliantMBeanException This class is not a JMX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *     compliant MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     *     <CODE>{@link java.lang.IllegalArgumentException}</CODE>:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *     The className passed in parameter is null, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     *     <CODE>ObjectName</CODE> passed in parameter contains a pattern
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     *     or no <CODE>ObjectName</CODE> is specified for the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    public ObjectInstance createMBean(String className, ObjectName name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        throws ReflectionException, InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
               MBeanRegistrationException, MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
               NotCompliantMBeanException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        return mbsInterceptor.createMBean(className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                                          cloneObjectName(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                                          (Object[]) null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                                          (String[]) null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * Instantiates and registers an MBean in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * The class loader to be used is identified by its object  name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * An object name is associated to the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * If the object name  of the loader is null, the ClassLoader that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * loaded the MBean server will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * If the MBean's object name given is null, the MBean can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * automatically provide its own name by implementing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * {@link javax.management.MBeanRegistration MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * The call returns an <CODE>ObjectInstance</CODE> object representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * the newly created MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @param className The class name of the MBean to be instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * @param name The object name of the MBean. May be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * @param loaderName The object name of the class loader to be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * @return  An <CODE>ObjectInstance</CODE>, containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     *     <CODE>ObjectName</CODE> and the Java class name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *     of the newly instantiated MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @exception ReflectionException  Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     *     <CODE>{@link java.lang.ClassNotFoundException}</CODE> or an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *     <CODE>{@link java.lang.Exception}</CODE> that occurred when trying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     *     to invoke the MBean's constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * @exception InstanceAlreadyExistsException The MBean is already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *     under the control of the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * @exception MBeanRegistrationException The <CODE>preRegister()</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     *     (<CODE>MBeanRegistration</CODE>  interface) method of the MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     *     has thrown an exception. The MBean will not be registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @exception MBeanException The constructor of the MBean has thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     *     an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * @exception NotCompliantMBeanException This class is not a JMX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     *     compliant MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * @exception InstanceNotFoundException The specified class loader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     *     is not registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     *     <CODE>{@link java.lang.IllegalArgumentException}</CODE>: The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     *     className passed in parameter is null, the <CODE>ObjectName</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     *     passed in parameter contains a pattern or no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     *     <CODE>ObjectName</CODE> is specified for the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public ObjectInstance createMBean(String className, ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                                      ObjectName loaderName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        throws ReflectionException, InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
               MBeanRegistrationException, MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
               NotCompliantMBeanException, InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        return mbsInterceptor.createMBean(className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                                          cloneObjectName(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                                          loaderName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                                          (Object[]) null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                                          (String[]) null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * Instantiates and registers an MBean in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * The MBean server will use its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * {@link javax.management.loading.ClassLoaderRepository Default Loader Repository}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * to load the class of the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * An object name is associated to the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * If the object name given is null, the MBean can automatically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * provide its own name by implementing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * {@link javax.management.MBeanRegistration MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * The call returns an <CODE>ObjectInstance</CODE> object representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * the newly created MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @param className The class name of the MBean to be instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * @param name The object name of the MBean. May be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * @param params An array containing the parameters of the constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *     to be invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * @param signature An array containing the signature of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *     constructor to be invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @return  An <CODE>ObjectInstance</CODE>, containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *     <CODE>ObjectName</CODE> and the Java class name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     *     of the newly instantiated MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * @exception ReflectionException Wraps a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     *     <CODE>{@link java.lang.ClassNotFoundException}</CODE> or an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     *     <CODE>{@link java.lang.Exception}</CODE> that occurred
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     *     when trying to invoke the MBean's constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * @exception InstanceAlreadyExistsException The MBean is already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     *     under the control of the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * @exception MBeanRegistrationException The <CODE>preRegister()</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     *     (<CODE>MBeanRegistration</CODE>  interface) method of the MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     *     has thrown an exception. The MBean will not be registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * @exception MBeanException The constructor of the MBean has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     *     thrown an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     *     <CODE>{@link java.lang.IllegalArgumentException}</CODE>: The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     *     className passed in parameter is null, the <CODE>ObjectName</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     *     passed in parameter contains a pattern or no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     *     <CODE>ObjectName</CODE> is specified for the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    public ObjectInstance createMBean(String className, ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                                      Object params[], String signature[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        throws ReflectionException, InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
               MBeanRegistrationException, MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
               NotCompliantMBeanException  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        return mbsInterceptor.createMBean(className, cloneObjectName(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                                          params, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * Instantiates and registers an MBean in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * The class loader to be used is identified by its object name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * An object name is associated to the MBean. If the object name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * of the loader is not specified, the ClassLoader that loaded the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * MBean server will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * If  the MBean object name given is null, the MBean can automatically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * provide its own name by implementing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * {@link javax.management.MBeanRegistration MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * The call returns an <CODE>ObjectInstance</CODE> object representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * the newly created MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * @param className The class name of the MBean to be instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * @param name The object name of the MBean. May be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @param params An array containing the parameters of the constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     *      to be invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * @param signature An array containing the signature of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     *     constructor to be invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @param loaderName The object name of the class loader to be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * @return  An <CODE>ObjectInstance</CODE>, containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *     <CODE>ObjectName</CODE> and the Java class name of the newly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     *     instantiated MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * @exception ReflectionException Wraps a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     *     <CODE>{@link java.lang.ClassNotFoundException}</CODE> or an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     *     <CODE>{@link java.lang.Exception}</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     *     that occurred when trying to invoke the MBean's constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * @exception InstanceAlreadyExistsException The MBean is already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     *     under the control of the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * @exception MBeanRegistrationException The <CODE>preRegister()</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     *     (<CODE>MBeanRegistration</CODE>  interface) method of the MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     *     has thrown an exception. The MBean will not be registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * @exception MBeanException The constructor of the MBean has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     *      thrown an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @exception InstanceNotFoundException The specified class loader is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     *      not registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *     <CODE>{@link java.lang.IllegalArgumentException}</CODE>: The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *     className passed in parameter is null, the <CODE>ObjectName</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     *     passed in parameter contains a pattern or no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     *     <CODE>ObjectName</CODE> is specified for the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    public ObjectInstance createMBean(String className, ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                                      ObjectName loaderName, Object params[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                                      String signature[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        throws ReflectionException, InstanceAlreadyExistsException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
               MBeanRegistrationException, MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
               NotCompliantMBeanException, InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        return mbsInterceptor.createMBean(className, cloneObjectName(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                                          loaderName, params, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * Registers a pre-existing object as an MBean with the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * If the object name given is null, the MBean may automatically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * provide its own name by implementing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * {@link javax.management.MBeanRegistration MBeanRegistration}  interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * The call returns an <CODE>ObjectInstance</CODE> object representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * the registered MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @param object The  MBean to be registered as an MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @param name The object name of the MBean. May be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @return The <CODE>ObjectInstance</CODE> for the MBean that has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     *      registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * @exception InstanceAlreadyExistsException The MBean is already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     *      under the control of the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @exception MBeanRegistrationException The <CODE>preRegister()</CODE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     *      (<CODE>MBeanRegistration</CODE>  interface) method of the MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     *      has thrown an exception. The MBean will not be registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * @exception NotCompliantMBeanException This object is not a JMX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     *      compliant MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     *      <CODE>{@link java.lang.IllegalArgumentException}</CODE>: The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     *      object passed in parameter is null or no object name is specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    public ObjectInstance registerMBean(Object object, ObjectName name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        throws InstanceAlreadyExistsException, MBeanRegistrationException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
               NotCompliantMBeanException  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        return mbsInterceptor.registerMBean(object, cloneObjectName(name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * De-registers an MBean from the MBean server. The MBean is identified by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * its object name. Once the method has been invoked, the MBean may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * no longer be accessed by its object name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * @param name The object name of the MBean to be de-registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * @exception InstanceNotFoundException The MBean specified is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     *     registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * @exception MBeanRegistrationException The <code>preDeregister()</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     *     (<CODE>MBeanRegistration</CODE>  interface) method of the MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     *     has thrown an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     *     <CODE>{@link java.lang.IllegalArgumentException}</CODE>: The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     *     object name in parameter is null or the MBean you are when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     *     trying to de-register is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     *     {@link javax.management.MBeanServerDelegate MBeanServerDelegate}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     *     MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    public void unregisterMBean(ObjectName name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        throws InstanceNotFoundException, MBeanRegistrationException  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        mbsInterceptor.unregisterMBean(cloneObjectName(name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * Gets the <CODE>ObjectInstance</CODE> for a given MBean registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * with the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * @param name The object name of the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * @return The <CODE>ObjectInstance</CODE> associated to the MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     *       specified by <VAR>name</VAR>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * @exception InstanceNotFoundException The MBean specified is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     *       registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    public ObjectInstance getObjectInstance(ObjectName name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        return mbsInterceptor.getObjectInstance(cloneObjectName(name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * Gets MBeans controlled by the MBean server. This method allows any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * of the following to be obtained: All MBeans, a set of MBeans specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * by pattern matching on the <CODE>ObjectName</CODE> and/or a Query
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * expression, a specific MBean. When the object name is null or no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * domain and key properties are specified, all objects are to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * selected (and filtered if a query is specified). It returns the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * set of <CODE>ObjectInstance</CODE> objects (containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * <CODE>ObjectName</CODE> and the Java Class name) for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * the selected MBeans.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * @param name The object name pattern identifying the MBeans to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     *      be retrieved. If null or or no domain and key properties
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     *      are specified, all the MBeans registered will be retrieved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * @param query The query expression to be applied for selecting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     *      MBeans. If null no query expression will be applied for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     *      selecting MBeans.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * @return  A set containing the <CODE>ObjectInstance</CODE> objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     *      for the selected MBeans.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     *      If no MBean satisfies the query an empty list is returned.
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 Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        return mbsInterceptor.queryMBeans(cloneObjectName(name), query);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * Gets the names of MBeans controlled by the MBean server. This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * enables any of the following to be obtained: The names of all MBeans,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * the names of a set of MBeans specified by pattern matching on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * <CODE>ObjectName</CODE> and/or a Query expression, a specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * MBean name (equivalent to testing whether an MBean is registered).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * When the object name is null or or no domain and key properties are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * specified, all objects are selected (and filtered if a query is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * specified). It returns the set of ObjectNames for the MBeans
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * @param name The object name pattern identifying the MBeans to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     *     retrieved. If null or no domain and key properties are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     *     specified, all the MBeans registered will be retrieved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * @param query The query expression to be applied for selecting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     *     MBeans. If null no query expression will be applied for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     *     selecting MBeans.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * @return  A set containing the ObjectNames for the MBeans selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     *     If no MBean satisfies the query, an empty list is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        return mbsInterceptor.queryNames(cloneObjectName(name), query);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * Checks whether an MBean, identified by its object name, is already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * registered with the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * @param name The object name of the MBean to be checked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * @return  True if the MBean is already registered in the MBean server,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     *     false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     *     <CODE>{@link java.lang.IllegalArgumentException}</CODE>: The object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     *      name in parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    public boolean isRegistered(ObjectName name)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        return mbsInterceptor.isRegistered(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * Returns the number of MBeans registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    public Integer getMBeanCount()  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        return mbsInterceptor.getMBeanCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * Gets the value of a specific attribute of a named MBean. The MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * is identified by its object name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * @param name The object name of the MBean from which the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     *     is to be retrieved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * @param attribute A String specifying the name of the attribute to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     *     retrieved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * @return  The value of the retrieved attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * @exception AttributeNotFoundException The attribute specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     *     is not accessible in the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * @exception MBeanException  Wraps an exception thrown by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     *     MBean's getter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * @exception InstanceNotFoundException The MBean specified is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     *     registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * @exception ReflectionException  Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     *     <CODE>{@link java.lang.Exception}</CODE> thrown when trying to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     *     invoke the setter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     *     <CODE>{@link java.lang.IllegalArgumentException}</CODE>:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     *     The object name in parameter is null or the attribute in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     *     parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    public Object getAttribute(ObjectName name, String attribute)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        throws MBeanException, AttributeNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
               InstanceNotFoundException, ReflectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        return mbsInterceptor.getAttribute(cloneObjectName(name), attribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * Enables the values of several attributes of a named MBean. The MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * is identified by its object name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * @param name The object name of the MBean from which the attributes are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     *     retrieved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * @param attributes A list of the attributes to be retrieved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * @return The list of the retrieved attributes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * @exception InstanceNotFoundException The MBean specified is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     *     registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * @exception ReflectionException An exception occurred when trying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     *     to invoke the getAttributes method of a Dynamic MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * @exception RuntimeOperationsException Wrap an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     *     <CODE>{@link java.lang.IllegalArgumentException}</CODE>: The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     *     object name in parameter is null or attributes in parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     *     is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    public AttributeList getAttributes(ObjectName name, String[] attributes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        throws InstanceNotFoundException, ReflectionException  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        return mbsInterceptor.getAttributes(cloneObjectName(name), attributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * Sets the value of a specific attribute of a named MBean. The MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * is identified by its object name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * @param name The name of the MBean within which the attribute is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     *     to be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * @param attribute The identification of the attribute to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     *     and the value it is to be set to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * @exception InstanceNotFoundException The MBean specified is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     *     not registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * @exception AttributeNotFoundException The attribute specified is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     *     not accessible in the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * @exception InvalidAttributeValueException The value specified for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     *     the attribute is not valid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * @exception MBeanException Wraps an exception thrown by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     *     MBean's setter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * @exception ReflectionException  Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     *     <CODE>{@link java.lang.Exception}</CODE> thrown when trying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     *     to invoke the setter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     *     <CODE>{@link java.lang.IllegalArgumentException}</CODE>: The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     *     object name in parameter is null or the attribute in parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     *     is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    public void setAttribute(ObjectName name, Attribute attribute)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        throws InstanceNotFoundException, AttributeNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
               InvalidAttributeValueException, MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
               ReflectionException  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        mbsInterceptor.setAttribute(cloneObjectName(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
                                    cloneAttribute(attribute));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     * Sets the values of several attributes of a named MBean. The MBean is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
     * identified by its object name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * @param name The object name of the MBean within which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     *     attributes are to  be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * @param attributes A list of attributes: The identification of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     *     attributes to be set and  the values they are to be set to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * @return  The list of attributes that were set, with their new values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * @exception InstanceNotFoundException The MBean specified is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     *      registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     * @exception ReflectionException An exception occurred when trying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     *      to invoke the getAttributes method of a Dynamic MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     *      <CODE>{@link java.lang.IllegalArgumentException}</CODE>:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     *     The object name in parameter is null or  attributes in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     *     parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    public AttributeList setAttributes(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                                       AttributeList attributes)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        throws InstanceNotFoundException, ReflectionException  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        return mbsInterceptor.setAttributes(cloneObjectName(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                                            cloneAttributeList(attributes));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * Invokes an operation on an MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * @param name The object name of the MBean on which the method is to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     *     invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     * @param operationName The name of the operation to be invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * @param params An array containing the parameters to be set when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     *     the operation is invoked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * @param signature An array containing the signature of the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     *     The class objects will be loaded using the same class loader as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     *     the one used for loading the MBean on which the operation was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     *     invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * @return  The object returned by the operation, which represents the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     *      result ofinvoking the operation on the  MBean specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * @exception InstanceNotFoundException The MBean specified is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     *       registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     * @exception MBeanException  Wraps an exception thrown by the MBean's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     *       invoked method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     * @exception ReflectionException  Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     *       <CODE>{@link java.lang.Exception}</CODE> thrown while trying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     *        to invoke the method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    public Object invoke(ObjectName name, String operationName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                         Object params[], String signature[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        throws InstanceNotFoundException, MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
               ReflectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        return mbsInterceptor.invoke(cloneObjectName(name), operationName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
                                     params, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * Returns the default domain used for naming the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * The default domain name is used as the domain part in the ObjectName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * of MBeans if no domain is specified by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    public String getDefaultDomain()  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        return mbsInterceptor.getDefaultDomain();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    // From MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
    public String[] getDomains() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        return mbsInterceptor.getDomains();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     * Adds a listener to a registered MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     * @param name The name of the MBean on which the listener should be added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     * @param listener The listener object which will handle the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     *        notifications emitted by the registered MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     * @param filter The filter object. If filter is null, no filtering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     *        will be performed before handling notifications.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     * @param handback The context to be sent to the listener when a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     *        notification is emitted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     * @exception InstanceNotFoundException The MBean name provided does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     *       not match any of the registered MBeans.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    public void addNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                                        NotificationListener listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
                                        NotificationFilter filter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
                                        Object handback)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        mbsInterceptor.addNotificationListener(cloneObjectName(name), listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
                                               filter, handback);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * Adds a listener to a registered MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * @param name The name of the MBean on which the listener should be added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * @param listener The object name of the listener which will handle the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     *        notifications emitted by the registered MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * @param filter The filter object. If filter is null, no filtering will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     *        be performed before handling notifications.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     * @param handback The context to be sent to the listener when a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     *        notification is emitted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     * @exception InstanceNotFoundException The MBean name of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     *       notification listener or of the notification broadcaster
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     *       does not match any of the registered MBeans.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    public void addNotificationListener(ObjectName name, ObjectName listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                                   NotificationFilter filter, Object handback)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        mbsInterceptor.addNotificationListener(cloneObjectName(name), listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                                               filter, handback);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    public void removeNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
                                           NotificationListener listener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
            throws InstanceNotFoundException, ListenerNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        mbsInterceptor.removeNotificationListener(cloneObjectName(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                                                  listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    public void removeNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                                           NotificationListener listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                                           NotificationFilter filter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                                           Object handback)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
            throws InstanceNotFoundException, ListenerNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        mbsInterceptor.removeNotificationListener(cloneObjectName(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
                                                  listener, filter, handback);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    public void removeNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                                           ObjectName listener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        throws InstanceNotFoundException, ListenerNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        mbsInterceptor.removeNotificationListener(cloneObjectName(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
                                                  listener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
    public void removeNotificationListener(ObjectName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
                                           ObjectName listener,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
                                           NotificationFilter filter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
                                           Object handback)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
            throws InstanceNotFoundException, ListenerNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        mbsInterceptor.removeNotificationListener(cloneObjectName(name),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                                                  listener, filter, handback);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     * This method discovers the attributes and operations that an MBean exposes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     * for management.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     * @param name The name of the MBean to analyze
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
     * @return  An instance of <CODE>MBeanInfo</CODE> allowing the retrieval of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
     * all attributes and operations of this MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     * @exception IntrospectionException An exception occurs during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     * introspection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     * @exception InstanceNotFoundException The MBean specified is not found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
     * @exception ReflectionException An exception occurred when trying to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
     * invoke the getMBeanInfo of a Dynamic MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
    public MBeanInfo getMBeanInfo(ObjectName name) throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    InstanceNotFoundException, IntrospectionException, ReflectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
        return mbsInterceptor.getMBeanInfo(cloneObjectName(name));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
     * Instantiates an object using the list of all class loaders registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     * in the MBean server (using its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     * {@link javax.management.loading.ClassLoaderRepository Default Loader Repository}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     * The object's class should have a public constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     * It returns a reference to the newly created object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     * The newly created object is not registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
     * @param className The class name of the object to be instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
     * @return The newly instantiated object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     * @exception ReflectionException Wraps the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     *     <CODE>{@link java.lang.ClassNotFoundException}</CODE> or the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
     *     <CODE>{@link java.lang.Exception}</CODE> that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
     *     occurred when trying to invoke the object's constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
     * @exception MBeanException The constructor of the object has thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
     *     an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
     *     <CODE>{@link java.lang.IllegalArgumentException}</CODE>:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     *     The className passed in parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    public Object instantiate(String className)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        throws ReflectionException, MBeanException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        /* Permission check */
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
   942
        checkMBeanPermission(mbeanServerName, className, null, null,
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
   943
                "instantiate");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
        return instantiator.instantiate(className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * Instantiates an object using the class Loader specified by its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     * <CODE>ObjectName</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     * If the loader name is null, the ClassLoader that loaded the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * MBean Server will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     * The object's class should have a public constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     * It returns a reference to the newly created object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     * The newly created object is not registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
     * @param className The class name of the MBean to be instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
     * @param loaderName The object name of the class loader to be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
     * @return The newly instantiated object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
     * @exception ReflectionException Wraps the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
     *     <CODE>{@link java.lang.ClassNotFoundException}</CODE> or the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
     *     <CODE>{@link java.lang.Exception}</CODE> that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
     *     occurred when trying to invoke the object's constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
     * @exception MBeanException The constructor of the object has thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
     *     an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
     * @exception InstanceNotFoundException The specified class loader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
     *     is not registered in the MBaenServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
     *     <CODE>{@link java.lang.IllegalArgumentException}</CODE>: The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
     *     className passed in parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
    public Object instantiate(String className, ObjectName loaderName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
        throws ReflectionException, MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
               InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
        /* Permission check */
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
   980
        checkMBeanPermission(mbeanServerName, className, null,
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
   981
                null, "instantiate");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        ClassLoader myLoader = outerShell.getClass().getClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
        return instantiator.instantiate(className, loaderName, myLoader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     * Instantiates an object using the list of all class loaders registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     * in the MBean server (using its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
     * {@link javax.management.loading.ClassLoaderRepository Default Loader Repository}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     * The object's class should have a public constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
     * The call returns a reference to the newly created object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     * The newly created object is not registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
     * @param className The class name of the object to be instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     * @param params An array containing the parameters of the constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     *     to be invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * @param signature An array containing the signature of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     *     constructor to be invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * @return The newly instantiated object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     * @exception ReflectionException Wraps the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
     *     <CODE>{@link java.lang.ClassNotFoundException}</CODE> or the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     *     <CODE>{@link java.lang.Exception}</CODE> that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
     *     occurred when trying to invoke the object's constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     * @exception MBeanException The constructor of the object has thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     *     an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
     *     <CODE>{@link java.lang.IllegalArgumentException}</CODE>:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     *     The className passed in parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
    public Object instantiate(String className, Object params[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                              String signature[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
        throws ReflectionException, MBeanException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
        /* Permission check */
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1019
        checkMBeanPermission(mbeanServerName, className, null, null,
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1020
                "instantiate");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
        ClassLoader myLoader = outerShell.getClass().getClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
        return instantiator.instantiate(className, params, signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
                                        myLoader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * Instantiates an object. The class loader to be used is identified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     * by its object name. If the object name of the loader is null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     * the ClassLoader that loaded the MBean server will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     * The object's class should have a public constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     * The call returns a reference to the newly created object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     * The newly created object is not registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
     * @param className The class name of the object to be instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
     * @param params An array containing the parameters of the constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
     *     to be invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     * @param signature An array containing the signature of the constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     *     to be invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     * @param loaderName The object name of the class loader to be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     * @return The newly instantiated object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     * @exception ReflectionException Wraps the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     *    <CODE>{@link java.lang.ClassNotFoundException}</CODE> or the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
     *    <CODE>{@link java.lang.Exception}</CODE> that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
     *    occurred when trying to invoke the object's constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
     * @exception MBeanException The constructor of the object has thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
     *    an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
     * @exception InstanceNotFoundException The specified class loader
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
     *    is not registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
     *    <CODE>{@link java.lang.IllegalArgumentException}</CODE>:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
     *    The className passed in parameter is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
    public Object instantiate(String className, ObjectName loaderName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                              Object params[], String signature[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
        throws ReflectionException, MBeanException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
               InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
        /* Permission check */
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1063
        checkMBeanPermission(mbeanServerName, className, null,
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1064
                null, "instantiate");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        ClassLoader myLoader = outerShell.getClass().getClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
        return instantiator.instantiate(className,loaderName,params,signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
                                        myLoader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
     * Returns true if the MBean specified is an instance of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
     * class, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
     * @param name The <CODE>ObjectName</CODE> of the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
     * @param className The name of the class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
     * @return true if the MBean specified is an instance of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
     *     class, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
     * @exception InstanceNotFoundException The MBean specified is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
     *     registered in the MBean server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
    public boolean isInstanceOf(ObjectName name, String className)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
        throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
        return mbsInterceptor.isInstanceOf(cloneObjectName(name), className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
     * De-serializes a byte array in the context of the class loader
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
     * of an MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
     * @param name The name of the MBean whose class loader should
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
     *     be used for the de-serialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
     * @param data The byte array to be de-sererialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
     * @return  The de-serialized object stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
     * @exception InstanceNotFoundException The MBean specified is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
     *     found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
     * @exception OperationsException Any of the usual Input/Output
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
     *     related exceptions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
    public ObjectInputStream deserialize(ObjectName name, byte[] data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
        throws InstanceNotFoundException, OperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
        /* Permission check */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
        // This call requires MBeanPermission 'getClassLoaderFor'
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
        final ClassLoader loader = getClassLoaderFor(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
        return instantiator.deserialize(loader, data);
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
     * De-serializes a byte array in the context of a given MBean class loader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
     * The class loader is the one that loaded the class with name "className".
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
     * @param className The name of the class whose class loader should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
     *      used for the de-serialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     * @param data The byte array to be de-sererialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     * @return  The de-serialized object stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     * @exception OperationsException Any of the usual Input/Output
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
     *      related exceptions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
     * @exception ReflectionException The specified class could not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
     *      loaded by the default loader repository
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
    public ObjectInputStream deserialize(String className, byte[] data)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
        throws OperationsException, ReflectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
        if (className == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
            throw new  RuntimeOperationsException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
                                        new IllegalArgumentException(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
                                        "Null className passed in parameter");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
        /* Permission check */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        // This call requires MBeanPermission 'getClassLoaderRepository'
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
        final ClassLoaderRepository clr = getClassLoaderRepository();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
        Class theClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
            if (clr == null) throw new ClassNotFoundException(className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
            theClass = clr.loadClass(className);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
        } catch (ClassNotFoundException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
            throw new ReflectionException(e,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
                                          "The given class could not be " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
                                          "loaded by the default loader " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
                                          "repository");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
        return instantiator.deserialize(theClass.getClassLoader(), data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
     * De-serializes a byte array in the context of a given MBean class loader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
     * The class loader is the one that loaded the class with name "className".
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
     * The name of the class loader to be used for loading the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
     * class is specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
     * If null, the MBean Server's class loader will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
     * @param className The name of the class whose class loader should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
     *     used for the de-serialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
     * @param data The byte array to be de-sererialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
     * @param loaderName The name of the class loader to be used for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
     *     loading the specified class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
     *     If null, the MBean Server's class loader will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
     * @return  The de-serialized object stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
     * @exception InstanceNotFoundException The specified class loader
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
     *     MBean is not found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
     * @exception OperationsException Any of the usual Input/Output
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
     *     related exceptions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
     * @exception ReflectionException The specified class could not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
     *     be loaded by the specified class loader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
    public ObjectInputStream deserialize(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
                                         ObjectName loaderName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
                                         byte[] data) throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        InstanceNotFoundException, OperationsException, ReflectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
        // Clone ObjectName
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
        loaderName = cloneObjectName(loaderName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
        /* Permission check */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
        // Make this call just to force the 'getClassLoader'
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
        // permission check
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
            getClassLoader(loaderName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        } catch (SecurityException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
            throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
        ClassLoader myLoader = outerShell.getClass().getClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
        return instantiator.deserialize(className, loaderName, data, myLoader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
     * Initializes this MBeanServer, registering the MBeanServerDelegate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
     * <p>This method must be called once, before using the MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
    private void initialize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
        if (instantiator == null) throw new
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
            IllegalStateException("instantiator must not be null.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
        // Registers the MBeanServer identification MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
                public Object run() throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
                    mbsInterceptor.registerMBean(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
                            mBeanServerDelegateObject,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
                            MBeanServerDelegate.DELEGATE_NAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
        } catch (SecurityException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
            if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
                MBEANSERVER_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
                        JmxMBeanServer.class.getName(), "initialize",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
                        "Unexpected security exception occurred", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
            throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
            if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
                MBEANSERVER_LOGGER.logp(Level.FINEST,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
                        JmxMBeanServer.class.getName(), "initialize",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
                        "Unexpected exception occurred", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
            throw new
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1241
                IllegalStateException("Can't register delegate.",e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
        /* Add my class loader to the repository
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
           This can be null if my class loader is the bootstrap
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
           class loader.  The ClassLoaderRepository knows how
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
           to handle that case.  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
        ClassLoader myLoader = outerShell.getClass().getClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        final ModifiableClassLoaderRepository loaders =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
            instantiator.getClassLoaderRepository();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        if (loaders != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
            loaders.addClassLoader(myLoader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
            /* Add the system class loader, so that if the MBean server is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
               loaded by the bootstrap class loader we can still load
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
               MBeans from the classpath using
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
               createMBean(className, objectName).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
               If this class (JmxMBeanServer) was not loaded by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
               system class loader or a parent of it, then the caller
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
               must have RuntimePermission("getClassLoader") for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
               getSystemClassLoader() call to succeed.  If the caller
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
               does not have that permission, any call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
               Class.getClassLoader() will fail.  Since there are lots
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
               of those in JMX, we better throw the exception now.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
               This permission question is irrelevant when JMX is part
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
               of J2SE (as of 1.5). */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
            ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
            if (systemLoader != myLoader)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
                loaders.addClassLoader(systemLoader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
     * Return the MBeanServerInterceptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
     * @exception UnsupportedOperationException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
     *            {@link MBeanServerInterceptor}s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
     *            are not enabled on this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
     * @see #interceptorsEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
     **/
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1283
    public synchronized MBeanServer getMBeanServerInterceptor() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
        if (interceptorsEnabled) return mbsInterceptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
        else throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
                       "MBeanServerInterceptors are disabled.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
     * Set the MBeanServerInterceptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
     * @exception UnsupportedOperationException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
     *            {@link MBeanServerInterceptor}s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
     *            are not enabled on this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
     * @see #interceptorsEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
    public synchronized void
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1297
        setMBeanServerInterceptor(MBeanServer interceptor) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
        if (!interceptorsEnabled) throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
                       "MBeanServerInterceptors are disabled.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
        if (interceptor == null) throw new
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
            IllegalArgumentException("MBeanServerInterceptor is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
        mbsInterceptor = interceptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
     * <p>Return the {@link java.lang.ClassLoader} that was used for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
     * loading the class of the named MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
     * @param mbeanName The ObjectName of the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
     * @return The ClassLoader used for that MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
     * @exception InstanceNotFoundException if the named MBean is not found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
    public ClassLoader getClassLoaderFor(ObjectName mbeanName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
        throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
        return mbsInterceptor.getClassLoaderFor(cloneObjectName(mbeanName));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
     * <p>Return the named {@link java.lang.ClassLoader}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
     * @param loaderName The ObjectName of the ClassLoader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
     * @return The named ClassLoader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
     * @exception InstanceNotFoundException if the named ClassLoader
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
     * is not found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
    public ClassLoader getClassLoader(ObjectName loaderName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
        throws InstanceNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
        return mbsInterceptor.getClassLoader(cloneObjectName(loaderName));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
     * <p>Return the ClassLoaderRepository for that MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
     * @return The ClassLoaderRepository for that MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
    public ClassLoaderRepository getClassLoaderRepository() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
        /* Permission check */
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1335
        checkMBeanPermission(mbeanServerName, null, null,
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1336
                null, "getClassLoaderRepository");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
        return secureClr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
    public MBeanServerDelegate getMBeanServerDelegate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
        if (!interceptorsEnabled) throw new UnsupportedOperationException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
                       "MBeanServerInterceptors are disabled.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
        return mBeanServerDelegateObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
    // These methods are called by the JMX MBeanServerBuilder.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
     * This method creates a new MBeanServerDelegate for a new MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
     * When creating a new MBeanServer the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
     * {@link javax.management.MBeanServerBuilder} first calls this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
     * in order to create a new MBeanServerDelegate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
     * <br>Then it calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
     * <code>newMBeanServer(defaultDomain,outer,delegate,interceptors)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
     * passing the <var>delegate</var> that should be used by the MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
     * implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
     * <p>Note that the passed <var>delegate</var> might not be directly the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
     * MBeanServerDelegate that was returned by this method. It could
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
     * be, for instance, a new object wrapping the previously
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
     * returned object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
     * @return A new {@link javax.management.MBeanServerDelegate}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
    public static MBeanServerDelegate newMBeanServerDelegate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
        return new MBeanServerDelegateImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
     * This method creates a new MBeanServer implementation object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
     * When creating a new MBeanServer the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
     * {@link javax.management.MBeanServerBuilder} first calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
     * <code>newMBeanServerDelegate()</code> in order to obtain a new
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
     * {@link javax.management.MBeanServerDelegate} for the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
     * MBeanServer. Then it calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
     * <code>newMBeanServer(defaultDomain,outer,delegate)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
     * passing the <var>delegate</var> that should be used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
     * MBeanServer  implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
     * <p>Note that the passed <var>delegate</var> might not be directly the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
     * MBeanServerDelegate that was returned by this implementation. It could
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
     * be, for instance, a new object wrapping the previously
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
     * returned delegate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
     * <p>The <var>outer</var> parameter is a pointer to the MBeanServer that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
     * should be passed to the {@link javax.management.MBeanRegistration}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
     * interface when registering MBeans inside the MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
     * If <var>outer</var> is <code>null</code>, then the MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
     * implementation is free to use its own <code>this</code> pointer when
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
     * invoking the {@link javax.management.MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
     * <p>This makes it possible for a MBeanServer implementation to wrap
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
     * another MBeanServer implementation, in order to implement, e.g,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
     * security checks, or to prevent access to the actual MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
     * implementation by returning a pointer to a wrapping object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
     * @param defaultDomain Default domain of the new MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
     * @param outer A pointer to the MBeanServer object that must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
     *        passed to the MBeans when invoking their
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
     *        {@link javax.management.MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
     * @param delegate A pointer to the MBeanServerDelegate associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
     *        with the new MBeanServer. The new MBeanServer must register
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
     *        this MBean in its MBean repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
     * @param interceptors If <code>true</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
     *        {@link MBeanServerInterceptor}s will be enabled (default is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
     *        <code>false</code>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
     *        Note: this parameter is not taken into account by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
     *        implementation - the default value <code>false</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
     *        always used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
     * @return A new private implementation of an MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
     * @see #interceptorsEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
     * @see javax.management.MBeanServerBuilder
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
     * @see com.sun.jmx.mbeanserver.JmxMBeanServerBuilder
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
    public static MBeanServer newMBeanServer(String defaultDomain,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
                                             MBeanServer outer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
                                             MBeanServerDelegate delegate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
                                             boolean interceptors) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
        // Determine whether to use fair locking for the repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
        // Default is true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
        final boolean fairLock = DEFAULT_FAIR_LOCK_POLICY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
        // This constructor happens to disregard the value of the interceptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
        // flag - that is, it always uses the default value - false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
        // This is admitedly a bug, but we chose not to fix it for now
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
        // since we would rather not have anybody depending on the Sun private
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
        // interceptor APIs - which is most probably going to be removed and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
        // replaced by a public (javax) feature in the future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
        return new JmxMBeanServer(defaultDomain,outer,delegate,null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
                                  interceptors,fairLock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
    // JMX OBJECT CLONING
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
    //-------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
     * Clone object name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
    private ObjectName cloneObjectName(ObjectName name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
        if (name != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
            return ObjectName.getInstance(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
     * Clone attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
    private Attribute cloneAttribute(Attribute attribute) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
        if (attribute != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
            if (!attribute.getClass().equals(Attribute.class)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
                return new Attribute(attribute.getName(), attribute.getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
        return attribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
     * Clone attribute list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
    private AttributeList cloneAttributeList(AttributeList list) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
        if (list != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
            if (!list.getClass().equals(AttributeList.class)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
                // Create new attribute list
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
                AttributeList newList = new AttributeList(list.size());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
                // Iterate through list and replace non JMX attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
                for (Iterator i = list.iterator(); i.hasNext(); ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
                    Attribute attribute = (Attribute) i.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
                    newList.add(cloneAttribute(attribute));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
                return newList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
                // Iterate through list and replace non JMX attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
                //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
                for (int i = 0; i < list.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
                    Attribute attribute = (Attribute) list.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
                    if (!attribute.getClass().equals(Attribute.class)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
                        list.set(i, cloneAttribute(attribute));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
                return list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
        return list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
    // SECURITY CHECKS
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
    //----------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1490
    private static void checkMBeanPermission(String serverName,
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1491
                                             String classname,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
                                             String member,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
                                             ObjectName objectName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
                                             String actions)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
        throws SecurityException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
        SecurityManager sm = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
        if (sm != null) {
1156
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1498
            Permission perm = new MBeanPermission(serverName,
bbc2d15aaf7a 5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents: 2
diff changeset
  1499
                                                  classname,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
                                                  member,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
                                                  objectName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
                                                  actions);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
            sm.checkPermission(perm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
}