jdk/src/share/classes/javax/management/MBeanServerBuilder.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import com.sun.jmx.mbeanserver.JmxMBeanServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * <p>This class represents a builder that creates a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * {@link javax.management.MBeanServer} implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * The JMX {@link javax.management.MBeanServerFactory} allows
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * applications to provide their custom MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * implementation by providing a subclass of this class.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @see MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @see MBeanServerFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
public class MBeanServerBuilder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     * Public default constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    public MBeanServerBuilder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
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 MBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * 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 must use its own <code>this</code> reference 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
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @param defaultDomain Default domain of the new MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @param outer A pointer to the MBeanServer object that must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *        passed to the MBeans when invoking their
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *        {@link javax.management.MBeanRegistration} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @param delegate A pointer to the MBeanServerDelegate associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *        with the new MBeanServer. The new MBeanServer must register
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *        this MBean in its MBean repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @return A new private implementation of an MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public MBeanServer newMBeanServer(String              defaultDomain,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                                      MBeanServer         outer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                                      MBeanServerDelegate delegate) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        // By default, MBeanServerInterceptors are disabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        // Use com.sun.jmx.mbeanserver.MBeanServerBuilder to obtain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        // MBeanServers on which MBeanServerInterceptors are enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        return JmxMBeanServer.newMBeanServer(defaultDomain,outer,delegate,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                                             false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
}