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