KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > management > MBeanServerBuilder


1 /*
2  * @(#)MBeanServerBuilder.java 1.18 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.management;
9
10 import com.sun.jmx.mbeanserver.JmxMBeanServer;
11
12 /**
13  * <p>This class represents a builder that creates a default
14  * {@link javax.management.MBeanServer} implementation.
15  * The JMX {@link javax.management.MBeanServerFactory} allows
16  * applications to provide their custom MBeanServer
17  * implementation by providing a subclass of this class.</p>
18  *
19  * @see MBeanServer
20  * @see MBeanServerFactory
21  *
22  * @since 1.5
23  * @since.unbundled JMX 1.2
24  */

25 public class MBeanServerBuilder {
26     /**
27      * Public default constructor.
28      **/

29     public MBeanServerBuilder() {
30     }
31
32     /**
33      * This method creates a new MBeanServerDelegate for a new MBeanServer.
34      * When creating a new MBeanServer the
35      * {@link javax.management.MBeanServerFactory} first calls this method
36      * in order to create a new MBeanServerDelegate.
37      * <br>Then it calls
38      * <code>newMBeanServer(defaultDomain,outer,delegate)</code>
39      * passing the <var>delegate</var> that should be used by the MBeanServer
40      * implementation.
41      * <p>Note that the passed <var>delegate</var> might not be directly the
42      * MBeanServerDelegate that was returned by this method. It could
43      * be, for instance, a new object wrapping the previously
44      * returned object.
45      *
46      * @return A new {@link javax.management.MBeanServerDelegate}.
47      **/

48     public MBeanServerDelegate JavaDoc newMBeanServerDelegate() {
49     return JmxMBeanServer.newMBeanServerDelegate();
50     }
51
52     /**
53      * This method creates a new MBeanServer implementation object.
54      * When creating a new MBeanServer the
55      * {@link javax.management.MBeanServerFactory} first calls
56      * <code>newMBeanServerDelegate()</code> in order to obtain a new
57      * {@link javax.management.MBeanServerDelegate} for the new
58      * MBeanServer. Then it calls
59      * <code>newMBeanServer(defaultDomain,outer,delegate)</code>
60      * passing the <var>delegate</var> that should be used by the MBeanServer
61      * implementation.
62      * <p>Note that the passed <var>delegate</var> might not be directly the
63      * MBeanServerDelegate that was returned by this implementation. It could
64      * be, for instance, a new object wrapping the previously
65      * returned delegate.
66      * <p>The <var>outer</var> parameter is a pointer to the MBeanServer that
67      * should be passed to the {@link javax.management.MBeanRegistration}
68      * interface when registering MBeans inside the MBeanServer.
69      * If <var>outer</var> is <code>null</code>, then the MBeanServer
70      * implementation must use its own <code>this</code> reference when
71      * invoking the {@link javax.management.MBeanRegistration} interface.
72      * <p>This makes it possible for a MBeanServer implementation to wrap
73      * another MBeanServer implementation, in order to implement, e.g,
74      * security checks, or to prevent access to the actual MBeanServer
75      * implementation by returning a pointer to a wrapping object.
76      *
77      * @param defaultDomain Default domain of the new MBeanServer.
78      * @param outer A pointer to the MBeanServer object that must be
79      * passed to the MBeans when invoking their
80      * {@link javax.management.MBeanRegistration} interface.
81      * @param delegate A pointer to the MBeanServerDelegate associated
82      * with the new MBeanServer. The new MBeanServer must register
83      * this MBean in its MBean repository.
84      *
85      * @return A new private implementation of an MBeanServer.
86      **/

87     public MBeanServer JavaDoc newMBeanServer(String JavaDoc defaultDomain,
88                       MBeanServer JavaDoc outer,
89                       MBeanServerDelegate JavaDoc delegate) {
90     // By default, MBeanServerInterceptors are disabled.
91
// Use com.sun.jmx.mbeanserver.MBeanServerBuilder to obtain
92
// MBeanServers on which MBeanServerInterceptors are enabled.
93
return JmxMBeanServer.newMBeanServer(defaultDomain,outer,delegate,
94                          false);
95     }
96 }
97
Popular Tags