Class MBeanLoader

All Implemented Interfaces:
DynamicMBean, MBeanRegistration, NotificationBroadcaster, NotificationEmitter, BaseObjectNamed, MBeanLoaderMBean, SelfEmailingMBean

public final class MBeanLoader extends SelfAwareMBean implements MBeanLoaderMBean, NotificationEmitter
This MBean provides XMLEncoder/XMLDecoder based persistence to/from files for MBeans and other objects.

Supported API: true

Extendable: false
  • Method Details

    • createAndRegisterMBeanLoader

      public static MBeanLoader createAndRegisterMBeanLoader(String mbeanConfigFileRef)
      Create, register, and generally start up a new MBeanLoader instance, setting MBeanConfigFileCheckInterval to a reasonable default value and BaseObjectName to null.

      Supported API: true
      Parameters:
      mbeanConfigFileRef - Reference (URL, file path, or resource path) of file from which MBeans will be loaded
    • createAndRegisterMBeanLoader

      public static MBeanLoader createAndRegisterMBeanLoader(String mbeanConfigFileRef, int mbeanConfigFileCheckInterval)
      Create, register, and generally start up a new MBeanLoader instance, setting MBeanConfigFileCheckInterval to a reasonable default value.

      Supported API: true
      Parameters:
      mbeanConfigFileRef - Reference (URL, file path, or resource path) of file from which MBeans will be loaded
      mbeanConfigFileCheckInterval - Interval (in seconds) at which MBeanConfigFileRef will be checked for updates; disabled if non-positive
    • createAndRegisterMBeanLoader

      public static MBeanLoader createAndRegisterMBeanLoader(String mbeanConfigFileRef, int mbeanConfigFileCheckInterval, ObjectName baseObjectName)
      Create, register, and generally start up a new MBeanLoader instance

      Supported API: true
      Parameters:
      mbeanConfigFileRef - Reference (URL, file path, or resource path) of file from which MBeans will be loaded
      mbeanConfigFileCheckInterval - Interval (in seconds) at which MBeanConfigFileRef will be checked for updates; disabled if non-positive
      baseObjectName - Object name under which loaded (non-loader) objects will be located
    • createAndRegisterMBeanLoader

      public static MBeanLoader createAndRegisterMBeanLoader(String mbeanConfigFileRef, int mbeanConfigFileCheckInterval, ObjectName baseObjectName, boolean registerDestroyOnShutdownHook)
      Create, register, and generally start up a new MBeanLoader instance and optionally register a shutdown hook to destroy the loader

      Supported API: true
      Parameters:
      mbeanConfigFileRef - Reference (URL, file path, or resource path) of file from which MBeans will be loaded
      mbeanConfigFileCheckInterval - Interval (in seconds) at which MBeanConfigFileRef will be checked for updates; disabled if non-positive
      baseObjectName - Object name under which loaded (non-loader) objects will be located
      registerDestroyOnShutdownHook - Whether shutdown hook to destroy this loader should be registered with the JVM runtime
    • createAndRegisterMBeanLoader

      public static MBeanLoader createAndRegisterMBeanLoader(String mbeanConfigFileRef, int mbeanConfigFileCheckInterval, boolean registerDestroyOnShutdownHook, BaseObjectNamed baseObjectNamed)
      Create, register, and generally start up a new MBeanLoader instance and optionally register a shutdown hook to destroy the loader

      Supported API: true
      Parameters:
      mbeanConfigFileRef - Reference (URL, file path, or resource path) of file from which MBeans will be loaded
      mbeanConfigFileCheckInterval - Interval (in seconds) at which MBeanConfigFileRef will be checked for updates; disabled if non-positive
      registerDestroyOnShutdownHook - Whether shutdown hook to destroy this loader should be registered with the JVM runtime
      baseObjectNamed - BaseObjectNamed object under which loaded (non-loader) objects will be located
    • getLoader

      public static MBeanLoader getLoader(SelfAwareMBean mbean)
      Walk owner chain for 'mbean' and get most direct loader. Returns null if no such loader is found.

      Supported API: true
    • getRootLoader

      public static MBeanLoader getRootLoader(SelfAwareMBean mbean)
      Walk owner chain for 'mbean' and get most top-most (root) loader. Returns null if no such loader is found.

      Supported API: true
    • getLoader

      public static MBeanLoader getLoader()
      Get a root loader without any starting context. Returns null if none found.

      Supported API: true
    • getInstanceOf

      public <T> T getInstanceOf(Class<T> objectClass)
      Get first (by depth-first traversal ) instance of 'objectClass' found in loader or its children

      Supported API: true
    • addAllInstancesOf

      public <T> void addAllInstancesOf(Class<T> objectClass, Collection<T> instances)
      Add all instances of 'objectClass' found in loader or its children to 'instances'.

      Supported API: true
    • getRelatedInstance

      public static <T> T getRelatedInstance(SelfAwareMBean mbeanContext, Class<T> objectClass)
      Get first instance of 'objectClass' found in the root loader that loaded 'mbeanContext'.

      Supported API: true