wt.jmx.core.mbeans
Class MBeanLoader

java.lang.Object
  extended by wt.jmx.core.StandardMBeanFix
      extended by wt.jmx.core.StandardMBean
          extended by wt.jmx.core.SelfAwareMBean
              extended by wt.jmx.core.mbeans.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


Nested Class Summary
static class wt.jmx.core.mbeans.MBeanLoader.NamedMBean
          Class and currently public methods must be public (and class must be static) for use by Bean persistence mechanism.
static class wt.jmx.core.mbeans.MBeanLoader.ObjectNameAndAttrs
          Class and currently public methods must be public (and class must be static) for use by Bean persistence mechanism.
 
Field Summary
 
Fields inherited from interface wt.jmx.core.mbeans.MBeanLoaderMBean
LOAD_FINISHED_NOTIF_TYPE, LOAD_STARTED_NOTIF_TYPE, START_NOTIF_TYPE, STOP_NOTIF_TYPE, UNLOAD_FINISHED_NOTIF_TYPE, UNLOAD_STARTED_NOTIF_TYPE
 
Method Summary
<T> void
addAllInstancesOf(Class<T> objectClass, Collection<T> instances)
          Add all instances of 'objectClass' found in loader or its children to 'instances'.
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.
static MBeanLoader createAndRegisterMBeanLoader(String mbeanConfigFileRef, int mbeanConfigFileCheckInterval)
          Create, register, and generally start up a new MBeanLoader instance, setting MBeanConfigFileCheckInterval to a reasonable default value.
static MBeanLoader createAndRegisterMBeanLoader(String mbeanConfigFileRef, int mbeanConfigFileCheckInterval, ObjectName baseObjectName)
          Create, register, and generally start up a new MBeanLoader instance

Supported API: true
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
<T> T
getInstanceOf(Class<T> objectClass)
          Get first (by depth-first traversal ) instance of 'objectClass' found in loader or its children

Supported API: true
static MBeanLoader getLoader(SelfAwareMBean mbean)
          Walk owner chain for 'mbean' and get most direct loader.
static
<T> T
getRelatedInstance(SelfAwareMBean mbeanContext, Class<T> objectClass)
          Get first instance of 'objectClass' found in the root loader that loaded 'mbeanContext'.
static MBeanLoader getRootLoader(SelfAwareMBean mbean)
          Walk owner chain for 'mbean' and get most top-most (root) loader.
 
Methods inherited from class wt.jmx.core.SelfAwareMBean
deregister, destroy, getObjectName, getObjectNameOnPreRegister, getOwnerMBean, getSelfAwareMBean, init, isInited, isRegistered, isStarted, postDeregister, postRegister, preDeregister, preRegister, register, register, register, resetObjectName, setOwnerMBean, start, stop
 
Methods inherited from class wt.jmx.core.StandardMBean
cacheMBeanInfo, cacheMBeanInfoInInstance, createMBeanInfo, emailThisMBean, getCachedInstanceMBeanInfo, getCachedMBeanInfo, getDescription, getDescription, getDescription, getDescription, getImpact, getMBeanInfo, getParameterName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface wt.jmx.core.mbeans.MBeanLoaderMBean
isStarted, start, stop
 
Methods inherited from interface wt.jmx.core.mbeans.SelfEmailingMBean
emailThisMBean
 

Method Detail

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

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


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