*/
public NotificationFilter createNotificationFilter(Element filterConfig)
throws Exception
{
// start off with a filter that does not allow any type/objectname
MBeanServerNotificationFilter filter = new MBeanServerNotificationFilter();
// filterConfig should point to the <filter factory="..."> element,
// we are interested in its 'enable' children to configure the filter
NodeList filterChildren = filterConfig.getChildNodes();
for (int i = 0; i < filterChildren.getLength(); i++)
{
Node filterChildNode = filterChildren.item(i);
// check if this is an 'enable' element, ignore everything else
if (filterChildNode.getNodeName().equals(ENABLE_ELEMENT))
{
// look for 'type' attribute
if (((Element)filterChildNode).hasAttribute(ENABLE_TYPE_ATTRIBUTE))
{
String type = ((Element)filterChildNode).getAttribute(ENABLE_TYPE_ATTRIBUTE);
// enable this type in the filter
filter.enableType(type);
}
else if (((Element)filterChildNode).hasAttribute(ENABLE_OBJECTNAME_ATTRIBUTE))
{
String objectName = ((Element)filterChildNode).getAttribute(ENABLE_OBJECTNAME_ATTRIBUTE);
// enable this objectName in the filter
// may throw MalformedObjectNameException
filter.enableObjectName(new ObjectName(objectName));
}
else
{
throw new Exception("'" + ENABLE_ELEMENT + "' element must have a '"
+ ENABLE_TYPE_ATTRIBUTE + "' or a '" + ENABLE_OBJECTNAME_ATTRIBUTE + "' attribute");