INT-1866 moved HeaderMapper building logic to parsers

This commit is contained in:
Oleg Zhurakousky
2011-05-03 18:26:18 -04:00
parent 832ff4358a
commit 7ecd7c2490
5 changed files with 94 additions and 12 deletions

View File

@@ -98,6 +98,8 @@ public class HttpInboundEndpointParser extends AbstractSingleBeanDefinitionParse
String headerMapper = element.getAttribute("header-mapper");
String mappedRequestHeaders = element.getAttribute("mapped-request-headers");
String mappedResponseHeaders = element.getAttribute("mapped-response-headers");
if (StringUtils.hasText(headerMapper)) {
if (StringUtils.hasText(mappedRequestHeaders) || StringUtils.hasText(mappedResponseHeaders)) {
parserContext.getReaderContext().error("Neither 'mappped-request-headers' or 'mapped-response-headers' " +
@@ -105,9 +107,11 @@ public class HttpInboundEndpointParser extends AbstractSingleBeanDefinitionParse
}
builder.addPropertyReference("headerMapper", headerMapper);
}
else if (StringUtils.hasText(mappedRequestHeaders) || StringUtils.hasText(mappedResponseHeaders)) {
else {
BeanDefinitionBuilder headerMapperBuilder = BeanDefinitionBuilder.genericBeanDefinition(
"org.springframework.integration.http.support.DefaultHttpHeaderMapper");
"org.springframework.integration.http.support.DefaultHttpHeaderMapper");
headerMapperBuilder.setFactoryMethod("inboundMapper");
IntegrationNamespaceUtils.setValueIfAttributeDefined(headerMapperBuilder, element, "mapped-request-headers", "inboundHeaderNames");
IntegrationNamespaceUtils.setValueIfAttributeDefined(headerMapperBuilder, element, "mapped-response-headers", "outboundHeaderNames");
builder.addPropertyValue("headerMapper", headerMapperBuilder.getBeanDefinition());

View File

@@ -72,7 +72,9 @@ public class HttpOutboundChannelAdapterParser extends AbstractOutboundChannelAda
else if (StringUtils.hasText(mappedRequestHeaders)) {
BeanDefinitionBuilder headerMapperBuilder = BeanDefinitionBuilder.genericBeanDefinition(
"org.springframework.integration.http.support.DefaultHttpHeaderMapper");
IntegrationNamespaceUtils.setValueIfAttributeDefined(headerMapperBuilder, element, "mapped-request-headers", "outboundHeaderNames");
if (StringUtils.hasText(mappedRequestHeaders)) {
IntegrationNamespaceUtils.setValueIfAttributeDefined(headerMapperBuilder, element, "mapped-request-headers", "outboundHeaderNames");
}
builder.addPropertyValue("headerMapper", headerMapperBuilder.getBeanDefinition());
}
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "charset");

View File

@@ -71,9 +71,10 @@ public class HttpOutboundGatewayParser extends AbstractConsumerEndpointParser {
}
builder.addPropertyReference("headerMapper", headerMapper);
}
else if (StringUtils.hasText(mappedRequestHeaders) || StringUtils.hasText(mappedResponseHeaders)) {
else {//if (StringUtils.hasText(mappedRequestHeaders) || StringUtils.hasText(mappedResponseHeaders)) {
BeanDefinitionBuilder headerMapperBuilder = BeanDefinitionBuilder.genericBeanDefinition(
"org.springframework.integration.http.support.DefaultHttpHeaderMapper");
headerMapperBuilder.setFactoryMethod("outboundMapper");
IntegrationNamespaceUtils.setValueIfAttributeDefined(headerMapperBuilder, element, "mapped-request-headers", "outboundHeaderNames");
IntegrationNamespaceUtils.setValueIfAttributeDefined(headerMapperBuilder, element, "mapped-response-headers", "inboundHeaderNames");
builder.addPropertyValue("headerMapper", headerMapperBuilder.getBeanDefinition());