jdk/src/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServerBuilder.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2007 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.jmx.mbeanserver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.management.MBeanServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.management.MBeanServerDelegate;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.management.MBeanServerBuilder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * This class represents a builder that creates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * {@link javax.management.MBeanServer} implementations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * The JMX {@link javax.management.MBeanServerFactory} allows
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * for applications to provide their custom MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * implementation. This class is not used when the whole Sun Reference JMX
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Implementation is used. However it may be used to substitute Sun
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * MBeanServer implementation to another JMX implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Contrarily to the default {@link javax.management.MBeanServerBuilder
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * javax.management.MBeanServerBuilder} this MBeanServerBuilder returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * MBeanServers on which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * {@link com.sun.jmx.interceptor.MBeanServerInterceptor}s are enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
public class JmxMBeanServerBuilder extends MBeanServerBuilder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * This method creates a new MBeanServerDelegate for a new MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * When creating a new MBeanServer the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * {@link javax.management.MBeanServerFactory} first calls this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * in order to create a new MBeanServerDelegate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * <br>Then it calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * <code>newMBeanServer(defaultDomain,outer,delegate)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * passing the <var>delegate</var> that should be used by the MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * <p>Note that the passed <var>delegate</var> might not be directly the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * MBeanServerDelegate that was returned by this method. It could
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * be, for instance, a new object wrapping the previously
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * returned object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @return A new {@link javax.management.MBeanServerDelegate}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public MBeanServerDelegate newMBeanServerDelegate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        return JmxMBeanServer.newMBeanServerDelegate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * This method creates a new MBeanServer implementation object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * When creating a new MBeanServer the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * {@link javax.management.MBeanServerFactory} first calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * <code>newMBeanServerDelegate()</code> in order to obtain a new
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * {@link javax.management.MBeanServerDelegate} for the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * MBeanServer. Then it calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * <code>newMBeanServer(defaultDomain,outer,delegate)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * passing the <var>delegate</var> that should be used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * MBeanServer  implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * <p>Note that the passed <var>delegate</var> might not be directly the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * MBeanServerDelegate that was returned by this implementation. It could
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * be, for instance, a new object wrapping the previously
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * returned delegate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * <p>The <var>outer</var> parameter is a pointer to the MBeanServer that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * should be passed to the {@link javax.management.MBeanRegistration}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * interface when registering MBeans inside the MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * If <var>outer</var> is <code>null</code>, then the MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * implementation is free to use its own <code>this</code> pointer when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * invoking the {@link javax.management.MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * <p>This makes it possible for a MBeanServer implementation to wrap
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * another MBeanServer implementation, in order to implement, e.g,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * security checks, or to prevent access to the actual MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * implementation by returning a pointer to a wrapping object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * This MBeanServerBuilder makes it possible to create MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * which support {@link com.sun.jmx.interceptor.MBeanServerInterceptor}s.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @param defaultDomain Default domain of the new MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param outer A pointer to the MBeanServer object that must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *        passed to the MBeans when invoking their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *        {@link javax.management.MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @param delegate A pointer to the MBeanServerDelegate associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *        with the new MBeanServer. The new MBeanServer must register
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *        this MBean in its MBean repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @return A new private implementation of an MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public MBeanServer newMBeanServer(String defaultDomain,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                                      MBeanServer outer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                                      MBeanServerDelegate delegate) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        return JmxMBeanServer.newMBeanServer(defaultDomain,outer,delegate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                                             true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
}