Class MBeanContainer

All Implemented Interfaces:
EventListener, Container.InheritedListener, Container.Listener, Destroyable, Dumpable

@ManagedObject("The component that registers beans as MBeans") public class MBeanContainer extends Object implements Container.InheritedListener, Dumpable, Destroyable
Container class for the MBean instances
  • Constructor Details

    • MBeanContainer

      public MBeanContainer(MBeanServer server)
      Constructs MBeanContainer
      server - instance of MBeanServer for use by container
    • MBeanContainer

      public MBeanContainer(MBeanServer server, boolean cacheOtherClassLoaders)
      Constructs MBeanContainer
      server - instance of MBeanServer for use by container
      cacheOtherClassLoaders - If true, MBeans from other classloaders (eg WebAppClassLoader) will be cached. The cache is never flushed, so this should be false if some classloaders do not live forever.
  • Method Details

    • getMBeanServer

      public MBeanServer getMBeanServer()
      Retrieve instance of MBeanServer used by container
      instance of MBeanServer
    • isUseCacheForOtherClassLoaders

      @ManagedAttribute(value="Whether to use the cache for MBeans loaded by other ClassLoaders", readonly=true) public boolean isUseCacheForOtherClassLoaders()
    • setDomain

      public void setDomain(String domain)
      Set domain to be used to add MBeans
      domain - domain name
    • getDomain

      @ManagedAttribute("The default ObjectName domain") public String getDomain()
      Retrieve domain name used to add MBeans
      domain name
    • mbeanFor

      public Object mbeanFor(Object o)

      Creates an ObjectMBean for the given object.

      Attempts to create an ObjectMBean for the object by searching the package and class name space. For example an object of the type:

       class com.acme.MyClass extends com.acme.util.BaseClass implements com.acme.Iface

      then this method would look for the following classes:

      • com.acme.jmx.MyClassMBean
      • com.acme.util.jmx.BaseClassMBean
      • org.eclipse.jetty.jmx.ObjectMBean
      o - The object
      A new instance of an MBean for the object or null.
    • findMBean

      public ObjectName findMBean(Object object)
      Lookup an object name by instance
      object - instance for which object name is looked up
      object name associated with specified instance, or null if not found
    • findBean

      public Object findBean(ObjectName objectName)
      Lookup an instance by object name
      objectName - object name of instance
      instance associated with specified object name, or null if not found
    • beanAdded

      public void beanAdded(Container parent, Object obj)
      Specified by:
      beanAdded in interface Container.Listener
    • beanRemoved

      public void beanRemoved(Container parent, Object obj)
      Specified by:
      beanRemoved in interface Container.Listener
    • makeName

      public String makeName(String basis)
      basis - name to strip of special characters.
      normalized name
    • dump

      public void dump(Appendable out, String indent) throws IOException
      Description copied from interface: Dumpable
      Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
      Specified by:
      dump in interface Dumpable
      out - The appendable to dump to
      indent - The indent to apply after any new lines.
      IOException - if unable to write to Appendable
    • dump

      public String dump()
      Specified by:
      dump in interface Dumpable
    • destroy

      public void destroy()
      Specified by:
      destroy in interface Destroyable