I am trying to create a custom XSD based configuration. I have custom tag which has another custom tag in turn. When parsing the inner tag, I get namespace handler not found. It could not locate handler class for http://ift.tt/GArMu6 schema.
Sample XML:
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:or="http://ift.tt/1BuRdW2"
xsi:schemaLocation="http://ift.tt/GArMu6 http://ift.tt/1cnl1uo
http://ift.tt/1Cu8JPd http://ift.tt/1Cu8Lqj">
<or:springRestTemplate id="customTemplateTest" >
<or:basicAuth id="templateCreds" userName="restUser" password="restPassword" />
<or:httpHeaders >
<map>
<entry key="headerName" value="headerValue" />
</map>
</or:httpHeaders>
</or:springRestTemplate>
</beans>
Parser code:
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
BeanDefinitionBuilder restTemplate = BeanDefinitionBuilder.rootBeanDefinition(SpringRestTemplateWithInterceptorsFactoryBean.class);
List<Element> credentials = DomUtils.getChildElementsByTagName(element, AUTH_CHILD_ELEMENT);
if (credentials != null && !credentials.isEmpty()) {
restTemplate.addPropertyValue("basicAuth", parserContext.getDelegate().parseCustomElement(credentials.get(0)));
}
List<Element> httpHeadersElements = DomUtils.getChildElementsByTagName(element, HTTP_HEADER_CHILD_ELEMENT);
if (httpHeadersElements != null && !httpHeadersElements.isEmpty()) {
httpHeadersElements = DomUtils.getChildElementsByTagName(httpHeadersElements.get(0), "map");
}
if (httpHeadersElements != null && !httpHeadersElements.isEmpty()) {
restTemplate.addPropertyValue("httpHeaders", parserContext.getDelegate().parseCustomElement(httpHeadersElements.get(0)));
}
return restTemplate.getBeanDefinition();
}
I get error on this line:
restTemplate.addPropertyValue("httpHeaders", parserContext.getDelegate().parseCustomElement(httpHeadersElements.get(0)));
I tried to debug the issue. I see that parserContext has all Spring schema handlers loaded, expect for the beans schema.
Aucun commentaire:
Enregistrer un commentaire