Class NamedChildSupport<T>

java.lang.Object
wt.jmx.core.mbeans.NamedChildSupport<T>
Type Parameters:
T - Type of child

public final class NamedChildSupport<T> extends Object
Provides support for management of a map of named children by an MBean. When a child is an instanceof SelfAwareMBean, the child is registered as a child MBean. Proper use of this utility class will allow the parent MBean to persist the managed children via XMLEncoder.

Supported API: true

Extendable: false
  • Constructor Details

    • NamedChildSupport

      public NamedChildSupport(SelfAwareMBean parentMBean, Class<?> requiredClass)
      Construct NamedChildSupport for specified parentMBean and requiring that all children be instances of a specified class.

      Supported API: true
      Parameters:
      parentMBean - Parent MBean
      requiredClass - Class all children must be instances of, or null
    • NamedChildSupport

      public NamedChildSupport(SelfAwareMBean parentMBean, Class<?> requiredClass, int initialSize)
      Construct NamedChildSupport for specified parentMBean and requiring that all children be instances of a specified class.

      Supported API: true
      Parameters:
      parentMBean - Parent MBean
      requiredClass - Class all children must be instances of, or null
      initialSize - Initial size of child map
  • Method Details

    • getChildMap

      public Map<String,T> getChildMap()
      Obtains contents of internal child map. A corresponding public getter that returns the result of this method should be exposed by the parentMBean to enable persistence via the XMLEncoder mechanism. This getter must also have a corresponding setter that calls setChildMap().

      Supported API: true
    • setChildMap

      public void setChildMap(Map<String,T> newChildMap)
      Sets the contents of the internal child map. A corresponding public setter that calls this method should be exposed by the parentMBean to enable persistence via the XMLEncoder mechanism. This setter must also have a corresponding getter that returns the result of getChildMap().

      Supported API: true
      Parameters:
      newChildMap - Map containing new children
    • getChildNames

      public String[] getChildNames()
      Returns sorted list of child names.

      Supported API: true
    • getChildren

      public Collection<T> getChildren()
      Provide access to unmodifiable collection of children.

      Supported API: true
    • getChildDataType

      public TabularType getChildDataType()
      Expose data type returned by getChildData().

      Supported API: true
    • getChildData

      public TabularData getChildData() throws OpenDataException
      Provide name and class information on children as TabularData.

      Supported API: true
      Throws:
      OpenDataException
    • addChild

      public void addChild(String childName, String childClassname) throws ClassNotFoundException, InstantiationException, IllegalAccessException
      Add a child of the specified class and give it the specified name.

      An attempt is made to find a constructor in the specified class taking a single String argument and call this constructor passing the specified listener name. If this fails, the no-arg constructor (which must be public) is used instead and an attempt is also made to call setName(String) on the instance. An attempt is also made to call setOwnerMBean(BaseObjectNamed) on the instance, passing it the parent MBean, so that any interested listeners can obtain this information.

      If the instance is a SelfAwareMBean, then it is registered as a child MBean of the parent MBean.

      The instance class must extend or implement T. The factory class should also override equals() to return 'true' for logically equivalent instances.

      Supported API: true

      Parameters:
      childName - Name to give child
      childClassname - Classname to instantiate
      Throws:
      ClassNotFoundException
      InstantiationException
      IllegalAccessException
    • removeChild

      public void removeChild(String childName)
      Remove the child with the specified name.

      Supported API: true
    • onInit

      public void onInit()
      Should be called from parent MBean's onInit() after calling super.

      Supported API: true
    • onStart

      public void onStart()
      Should be called from parent MBean's onStart() after calling super.

      Supported API: true
    • onStop

      public void onStop()
      Should be called from parent MBean's onStop() before calling super.

      Supported API: true
    • onDestroy

      public void onDestroy()
      Should be called from parent MBean's onDestroy() before calling super.

      Supported API: true