Class NamedChildSupport<T>
- Type Parameters:
T- Type of child
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 Summary
ConstructorsConstructorDescriptionNamedChildSupport(SelfAwareMBean parentMBean, Class<?> requiredClass) Construct NamedChildSupport for specified parentMBean and requiring that all children be instances of a specified class.NamedChildSupport(SelfAwareMBean parentMBean, Class<?> requiredClass, int initialSize) Construct NamedChildSupport for specified parentMBean and requiring that all children be instances of a specified class. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a child of the specified class and give it the specified name.Provide name and class information on children asTabularData.Expose data type returned by getChildData().Obtains contents of internal child map.String[]Returns sorted list of child names.Provide access to unmodifiable collection of children.voidShould be called from parent MBean's onDestroy() before calling super.voidonInit()Should be called from parent MBean's onInit() after calling super.voidonStart()Should be called from parent MBean's onStart() after calling super.voidonStop()Should be called from parent MBean's onStop() before calling super.voidremoveChild(String childName) Remove the child with the specified name.voidsetChildMap(Map<String, T> newChildMap) Sets the contents of the internal child map.
-
Constructor Details
-
NamedChildSupport
Construct NamedChildSupport for specified parentMBean and requiring that all children be instances of a specified class.
Supported API: true- Parameters:
parentMBean- Parent MBeanrequiredClass- Class all children must be instances of, or null
-
NamedChildSupport
Construct NamedChildSupport for specified parentMBean and requiring that all children be instances of a specified class.
Supported API: true- Parameters:
parentMBean- Parent MBeanrequiredClass- Class all children must be instances of, or nullinitialSize- Initial size of child map
-
-
Method Details
-
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 theXMLEncodermechanism. This getter must also have a corresponding setter that calls setChildMap().
Supported API: true -
setChildMap
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 theXMLEncodermechanism. This setter must also have a corresponding getter that returns the result of getChildMap().
Supported API: true- Parameters:
newChildMap- Map containing new children
-
getChildNames
Returns sorted list of child names.
Supported API: true -
getChildren
Provide access to unmodifiable collection of children.
Supported API: true -
getChildDataType
Expose data type returned by getChildData().
Supported API: true -
getChildData
- 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 childchildClassname- Classname to instantiate- Throws:
ClassNotFoundExceptionInstantiationExceptionIllegalAccessException
-
removeChild
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
-