01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package javax.management;
10:
11: import mx4j.server.MX4JMBeanServerBuilder;
12:
13: /**
14: * <p>This class is used by the {@link javax.management.MBeanServerFactory} to delegate the
15: * creation of new instances of {@link javax.management.MBeanServerDelegate} and
16: * {@link javax.management.MBeanServer}.
17: * This implementation further delegates the work to {@link mx4j.server.MX4JMBeanServerBuilder}
18: * to return implementations in the <code>mx4j.server</code> package.</p>
19: * <p/>
20: * <p>The {@link javax.management.MBeanServerFactory} creates the delegate before
21: * creating the MBeanServer itself and providing a reference to the created delegate.
22: * Note that the delegate passed to the MBeanServer might not be the instance returned
23: * by this builder; for example, it could be a wrapper around it.</p>
24: *
25: * @version $Revision: 1.10 $
26: * @see MBeanServer
27: * @see MBeanServerFactory
28: */
29:
30: public class MBeanServerBuilder {
31: /**
32: * The builder to which this implementation delegates all operations.
33: */
34: private MBeanServerBuilder builder;
35:
36: /**
37: * This method creates a new MBeanServerDelegate for a new MBeanServer.
38: *
39: * @return A new {@link javax.management.MBeanServerDelegate}.
40: */
41: public MBeanServerDelegate newMBeanServerDelegate() {
42: return builderDelegate().newMBeanServerDelegate();
43: }
44:
45: /**
46: * Returns a new MBeanServer instance.
47: *
48: * @return A new private implementation of an MBeanServer.
49: */
50: public MBeanServer newMBeanServer(String defaultDomain,
51: MBeanServer outer, MBeanServerDelegate delegate) {
52: return builderDelegate().newMBeanServer(defaultDomain, outer,
53: delegate);
54: }
55:
56: /**
57: * Returns the delegate builder.
58: *
59: * @return the delegate builder.
60: */
61: private synchronized MBeanServerBuilder builderDelegate() {
62: if (builder == null)
63: builder = new MX4JMBeanServerBuilder();
64: return builder;
65: }
66: }
|