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