{
Object instance = instantiateByClassName(className, Handler.class, null);
Handler appender = (Handler) instance;
Properties beanProps = new Properties();
String name = subst(appenderElement.getAttribute(NAME_ATTR));
HandlerSkeleton handlerSkeleton = null;
if( appender instanceof HandlerSkeleton )
{
handlerSkeleton = (HandlerSkeleton) appender;
handlerSkeleton.setName(name);
}
NodeList children = appenderElement.getChildNodes();
final int length = children.getLength();
for (int loop = 0; loop < length; loop++)
{
Node currentNode = children.item(loop);
/* We're only interested in Elements */
if (currentNode.getNodeType() == Node.ELEMENT_NODE)
{
Element currentElement = (Element) currentNode;
// Parse appender parameters
if (currentElement.getTagName().equals(PARAM_TAG))
{
setParameter(currentElement, beanProps);
}
// Set appender layout
else if (currentElement.getTagName().equals(LAYOUT_TAG))
{
Formatter format = parseLayout(currentElement);
appender.setFormatter(format);
}
// Add filters
else if (currentElement.getTagName().equals(FILTER_TAG))
{
parseFilters(currentElement, appender);
}
else if (currentElement.getTagName().equals(ERROR_HANDLER_TAG))
{
parseErrorManager(currentElement, appender);
}
else if (currentElement.getTagName().equals(APPENDER_REF_TAG))
{
String refName = subst(currentElement.getAttribute(REF_ATTR));
errorLog.error("Requesting attachment of handler named [" +
refName + "] to handler named [" + appender +
"] which does not implement org.apache.jdk.spi.HandlerAttachable.",
null, ErrorManager.GENERIC_FAILURE);
}
}
}
PropertyEditors.mapJavaBeanProperties(appender, beanProps);
if( handlerSkeleton != null )
handlerSkeleton.activateOptions();
return appender;
}
/* Yes, it's ugly, but all of these exceptions point to the same
problem: we can't create an Handler
*/