Template Monitors
Use
There are cases when some of the parameters specified in the installation part of the monitor-configuration.xml (<monitor-tree> element) are not known beforehand and have to be supplied dynamically. For instance, it may not be clear what the display name of the monitor must be, what attribute have to be monitored on the resource side, and so on.
In such cases, the monitoring framework provides a means of installing sub-trees (can be one monitor only) of nodes in the monitoring tree, based on a common template. The sub-trees that are installed have a common structure and differ only in some parameters (for instance, the name). The responsibility of the monitored resource is to provide a method in the resource MBean or to emit JMX notifications that give the missing dynamic data to be filled in in the templates. In the example above, the resource MBean can have a method public int[] listVIPClientIDs() that returns the list of unique identifiers of all clients who have performed transactions over 10,000 EUR.
Upon receiving dynamic data for a certain template, the monitoring framework first checks if there are some instances missing from the previous installation and, if so, removes them from the monitoring tree. For example, a client with ID 666 may have performed a transaction over 10,000 EUR in the past, but after that he/she has stopped working with this bank. Therefore, the second time the dynamic data is retrieved, this ID is missing in the list of IDs and the sub-tree that was installed for it in the previous retrieval is removed from the tree.
After removing the sub-trees for the missing entities, the monitoring framework iterates over the array of dynamically supplied data and, for each of the entities in this array, installs a sub-tree following the template filled with the information from the entity.
For more information about the template monitors, see Using Template Monitors .