Path: blob/master/src/java.management/share/classes/javax/management/MBeanServerBuilder.java
41155 views
/*1* Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.management;2627import com.sun.jmx.mbeanserver.JmxMBeanServer;2829/**30* <p>This class represents a builder that creates a default31* {@link javax.management.MBeanServer} implementation.32* The JMX {@link javax.management.MBeanServerFactory} allows33* applications to provide their custom MBeanServer34* implementation by providing a subclass of this class.</p>35*36* @see MBeanServer37* @see MBeanServerFactory38*39* @since 1.540*/41public class MBeanServerBuilder {42/**43* Public default constructor.44**/45public MBeanServerBuilder() {46}4748/**49* This method creates a new MBeanServerDelegate for a new MBeanServer.50* When creating a new MBeanServer the51* {@link javax.management.MBeanServerFactory} first calls this method52* in order to create a new MBeanServerDelegate.53* <br>Then it calls54* <code>newMBeanServer(defaultDomain,outer,delegate)</code>55* passing the <var>delegate</var> that should be used by the MBeanServer56* implementation.57* <p>Note that the passed <var>delegate</var> might not be directly the58* MBeanServerDelegate that was returned by this method. It could59* be, for instance, a new object wrapping the previously60* returned object.61*62* @return A new {@link javax.management.MBeanServerDelegate}.63**/64public MBeanServerDelegate newMBeanServerDelegate() {65return JmxMBeanServer.newMBeanServerDelegate();66}6768/**69* This method creates a new MBeanServer implementation object.70* When creating a new MBeanServer the71* {@link javax.management.MBeanServerFactory} first calls72* <code>newMBeanServerDelegate()</code> in order to obtain a new73* {@link javax.management.MBeanServerDelegate} for the new74* MBeanServer. Then it calls75* <code>newMBeanServer(defaultDomain,outer,delegate)</code>76* passing the <var>delegate</var> that should be used by the MBeanServer77* implementation.78* <p>Note that the passed <var>delegate</var> might not be directly the79* MBeanServerDelegate that was returned by this implementation. It could80* be, for instance, a new object wrapping the previously81* returned delegate.82* <p>The <var>outer</var> parameter is a pointer to the MBeanServer that83* should be passed to the {@link javax.management.MBeanRegistration}84* interface when registering MBeans inside the MBeanServer.85* If <var>outer</var> is <code>null</code>, then the MBeanServer86* implementation must use its own <code>this</code> reference when87* invoking the {@link javax.management.MBeanRegistration} interface.88* <p>This makes it possible for a MBeanServer implementation to wrap89* another MBeanServer implementation, in order to implement, e.g,90* security checks, or to prevent access to the actual MBeanServer91* implementation by returning a pointer to a wrapping object.92*93* @param defaultDomain Default domain of the new MBeanServer.94* @param outer A pointer to the MBeanServer object that must be95* passed to the MBeans when invoking their96* {@link javax.management.MBeanRegistration} interface.97* @param delegate A pointer to the MBeanServerDelegate associated98* with the new MBeanServer. The new MBeanServer must register99* this MBean in its MBean repository.100*101* @return A new private implementation of an MBeanServer.102**/103public MBeanServer newMBeanServer(String defaultDomain,104MBeanServer outer,105MBeanServerDelegate delegate) {106// By default, MBeanServerInterceptors are disabled.107// Use com.sun.jmx.mbeanserver.MBeanServerBuilder to obtain108// MBeanServers on which MBeanServerInterceptors are enabled.109return JmxMBeanServer.newMBeanServer(defaultDomain,outer,delegate,110false);111}112}113114115