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. package javax.management;
  8. import com.sun.jmx.mbeanserver.JmxMBeanServer;
  9. /**
  10. * <p>This class represents a builder that creates a default
  11. * {@link javax.management.MBeanServer} implementation.
  12. * The JMX {@link javax.management.MBeanServerFactory} allows
  13. * applications to provide their custom MBeanServer
  14. * implementation by providing a subclass of this class.</p>
  15. *
  16. * @see MBeanServer
  17. * @see MBeanServerFactory
  18. *
  19. * @since 1.5
  20. * @since.unbundled JMX 1.2
  21. */
  22. public class MBeanServerBuilder {
  23. /**
  24. * Public default constructor.
  25. **/
  26. public MBeanServerBuilder() {
  27. }
  28. /**
  29. * This method creates a new MBeanServerDelegate for a new MBeanServer.
  30. * When creating a new MBeanServer the
  31. * {@link javax.management.MBeanServerFactory} first calls this method
  32. * in order to create a new MBeanServerDelegate.
  33. * <br>Then it calls
  34. * <code>newMBeanServer(defaultDomain,outer,delegate)</code>
  35. * passing the <var>delegate</var> that should be used by the MBeanServer
  36. * implementation.
  37. * <p>Note that the passed <var>delegate</var> might not be directly the
  38. * MBeanServerDelegate that was returned by this method. It could
  39. * be, for instance, a new object wrapping the previously
  40. * returned object.
  41. *
  42. * @return A new {@link javax.management.MBeanServerDelegate}.
  43. **/
  44. public MBeanServerDelegate newMBeanServerDelegate() {
  45. return JmxMBeanServer.newMBeanServerDelegate();
  46. }
  47. /**
  48. * This method creates a new MBeanServer implementation object.
  49. * When creating a new MBeanServer the
  50. * {@link javax.management.MBeanServerFactory} first calls
  51. * <code>newMBeanServerDelegate()</code> in order to obtain a new
  52. * {@link javax.management.MBeanServerDelegate} for the new
  53. * MBeanServer. Then it calls
  54. * <code>newMBeanServer(defaultDomain,outer,delegate)</code>
  55. * passing the <var>delegate</var> that should be used by the MBeanServer
  56. * implementation.
  57. * <p>Note that the passed <var>delegate</var> might not be directly the
  58. * MBeanServerDelegate that was returned by this implementation. It could
  59. * be, for instance, a new object wrapping the previously
  60. * returned delegate.
  61. * <p>The <var>outer</var> parameter is a pointer to the MBeanServer that
  62. * should be passed to the {@link javax.management.MBeanRegistration}
  63. * interface when registering MBeans inside the MBeanServer.
  64. * If <var>outer</var> is <code>null</code>, then the MBeanServer
  65. * implementation must use its own <code>this</code> reference when
  66. * invoking the {@link javax.management.MBeanRegistration} interface.
  67. * <p>This makes it possible for a MBeanServer implementation to wrap
  68. * another MBeanServer implementation, in order to implement, e.g,
  69. * security checks, or to prevent access to the actual MBeanServer
  70. * implementation by returning a pointer to a wrapping object.
  71. *
  72. * @param defaultDomain Default domain of the new MBeanServer.
  73. * @param outer A pointer to the MBeanServer object that must be
  74. * passed to the MBeans when invoking their
  75. * {@link javax.management.MBeanRegistration} interface.
  76. * @param delegate A pointer to the MBeanServerDelegate associated
  77. * with the new MBeanServer. The new MBeanServer must register
  78. * this MBean in its MBean repository.
  79. *
  80. * @return A new private implementation of an MBeanServer.
  81. **/
  82. public MBeanServer newMBeanServer(String defaultDomain,
  83. MBeanServer outer,
  84. MBeanServerDelegate delegate) {
  85. // By default, MBeanServerInterceptors are disabled.
  86. // Use com.sun.jmx.mbeanserver.MBeanServerBuilder to obtain
  87. // MBeanServers on which MBeanServerInterceptors are enabled.
  88. return JmxMBeanServer.newMBeanServer(defaultDomain,outer,delegate,
  89. false);
  90. }
  91. }