return handleSpringElements(element, parent);
}
else
{
String namespaceUri = element.getNamespaceURI();
NamespaceHandler handler = getReaderContext().getNamespaceHandlerResolver().resolve(namespaceUri);
if (handler == null)
{
getReaderContext().error("Unable to locate NamespaceHandler for namespace [" + namespaceUri + "]", element);
return null;
}
boolean noRecurse = false;
boolean forceRecurse = false;
BeanDefinition finalChild;
do {
ParserContext parserContext = new ParserContext(getReaderContext(), this, parent);
finalChild = handler.parse(element, parserContext);
registerBean(element, finalChild);
noRecurse = noRecurse || testFlag(finalChild, MULE_NO_RECURSE);
forceRecurse = forceRecurse || testFlag(finalChild, MULE_FORCE_RECURSE);
} while (null != finalChild && testFlag(finalChild, MULE_REPEAT_PARSE));
// Only iterate and parse child mule name-spaced elements. Spring does not do
// hierarchical parsing by default so we need to maintain this behavior
// for non-mule elements to ensure that we don't break the parsing of any
// other custom name-spaces e.g spring-jee.
// We also avoid parsing inside elements that have constructed a factory bean
// because that means we're dealing with (something like) ChildMapDefinitionParser,
// which handles iteration internally (this is a hack needed because Spring doesn't
// expose the DP for "<spring:entry>" elements directly).
boolean isRecurse;
if (noRecurse)
{
// no recursion takes precedence, as recursion is set by default
isRecurse = false;
}
else
{
if (forceRecurse)
{
isRecurse = true;
}
else
{
// default behaviour if no control specified
isRecurse = SpringXMLUtils.isMuleNamespace(element);
}
}
if (isRecurse)
{
NodeList list = element.getChildNodes();
for (int i = 0; i < list.getLength(); i++)
{
if (list.item(i) instanceof Element)
{
parseCustomElement((Element) list.item(i), finalChild);
}
}
}
// If a parser requests post-processing we call again after children called
if (testFlag(finalChild, MULE_POST_CHILDREN))
{
ParserContext parserContext = new ParserContext(getReaderContext(), this, parent);
finalChild = handler.parse(element, parserContext);
}
return finalChild;
}
}