01: /* JFox, the OpenSource J2EE Application Server
02: *
03: * Copyright (C) 2002 huihoo.com
04: * Distributable under GNU LGPL license
05: * See the GNU Lesser General Public License for more details.
06: */
07:
08: package javax.management;
09:
10: import org.huihoo.jfox.jmx.ExtendedMBeanServerDelegate;
11: import org.huihoo.jfox.jmx.MBeanServerSupport;
12:
13: /**
14: * <p>This class represents a builder that creates a default
15: * {@link javax.management.MBeanServer} implementation.
16: * The JMX {@link javax.management.MBeanServerFactory} allows
17: * applications to provide their custom MBeanServer
18: * implementation by providing a subclass of this class.</p>
19: *
20: * <p>By default in this reference implementation, this class
21: * instantiates implementations provided in the
22: * <b>com.sun.jmx.mbeanserver</b> package.</p>
23: *
24: * @see MBeanServer
25: * @see MBeanServerFactory
26: *
27: * @since JMX 1.2
28: *
29: * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
30: */
31:
32: public class MBeanServerBuilder {
33: /**
34: * Public default constructor.
35: **/
36: public MBeanServerBuilder() {
37: }
38:
39: /**
40: * This method creates a new MBeanServerDelegate for a new MBeanServer.
41: * When creating a new MBeanServer the
42: * {@link javax.management.MBeanServerFactory} first calls this method
43: * in order to doCreate a new MBeanServerDelegate.
44: * <br>Then it calls
45: * <code>newMBeanServer(defaultDomain,outer,delegate)</code>
46: * passing the <var>delegate</var> that should be used by the MBeanServer
47: * implementation.
48: * <p>Note that the passed <var>delegate</var> might not be directly the
49: * MBeanServerDelegate that was returned by this method. It could
50: * be, for instance, a new object wrapping the previously
51: * returned object.
52: *
53: * @return A new {@link javax.management.MBeanServerDelegate}.
54: **/
55: public MBeanServerDelegate newMBeanServerDelegate() {
56: return new ExtendedMBeanServerDelegate();
57: }
58:
59: /**
60: * This method creates a new MBeanServer implementation object.
61: * When creating a new MBeanServer the
62: * {@link javax.management.MBeanServerFactory} first calls
63: * <code>newMBeanServerDelegate()</code> in order to obtain a new
64: * {@link javax.management.MBeanServerDelegate} for the new
65: * MBeanServer. Then it calls
66: * <code>newMBeanServer(defaultDomain,outer,delegate)</code>
67: * passing the <var>delegate</var> that should be used by the MBeanServer
68: * implementation.
69: * <p>Note that the passed <var>delegate</var> might not be directly the
70: * MBeanServerDelegate that was returned by this implementation. It could
71: * be, for instance, a new object wrapping the previously
72: * returned delegate.
73: * <p>The <var>outer</var> parameter is a pointer to the MBeanServer that
74: * should be passed to the {@link javax.management.MBeanRegistration}
75: * interface when registering MBeans inside the MBeanServer.
76: * If <var>outer</var> is <code>null</code>, then the MBeanServer
77: * implementation must use its own <code>this</code> reference when
78: * invoking the {@link javax.management.MBeanRegistration} interface.
79: * <p>This makes it possible for a MBeanServer implementation to wrap
80: * another MBeanServer implementation, in order to implement, e.g,
81: * security checks, or to prevent access to the actual MBeanServer
82: * implementation by returning a pointer to a wrapping object.
83: *
84: * @param defaultDomain Default domain of the new MBeanServer.
85: * @param outer A pointer to the MBeanServer object that must be
86: * passed to the MBeans when invoking their
87: * {@link javax.management.MBeanRegistration} interface.
88: * @param delegate A pointer to the MBeanServerDelegate associated
89: * with the new MBeanServer. The new MBeanServer must register
90: * this MBean in its MBean repository.
91: *
92: * @return A new private implementation of an MBeanServer.
93: **/
94: public MBeanServer newMBeanServer(String defaultDomain,
95: MBeanServer outer, MBeanServerDelegate delegate) {
96: return new MBeanServerSupport(defaultDomain, outer, delegate);
97: }
98: }
|