INT-1866 moved HeaderMapper building logic to parsers (part 2)

This commit is contained in:
Oleg Zhurakousky
2011-05-03 18:39:01 -04:00
parent 7ecd7c2490
commit 7622fd9112
7 changed files with 15 additions and 22 deletions

View File

@@ -33,6 +33,7 @@ import org.w3c.dom.Element;
* 'inbound-channel-adapter' and 'true' for the 'inbound-gateway'.
*
* @author Mark Fisher
* @author Oleg Zhurakousky
*/
public class HttpInboundEndpointParser extends AbstractSingleBeanDefinitionParser {

View File

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

View File

@@ -34,6 +34,7 @@ import org.springframework.util.xml.DomUtils;
* Parser for the 'outbound-gateway' element of the http namespace.
*
* @author Mark Fisher
* @author Oleg Zhurakousky
*/
public class HttpOutboundGatewayParser extends AbstractConsumerEndpointParser {
@@ -71,7 +72,7 @@ public class HttpOutboundGatewayParser extends AbstractConsumerEndpointParser {
}
builder.addPropertyReference("headerMapper", headerMapper);
}
else {//if (StringUtils.hasText(mappedRequestHeaders) || StringUtils.hasText(mappedResponseHeaders)) {
else {
BeanDefinitionBuilder headerMapperBuilder = BeanDefinitionBuilder.genericBeanDefinition(
"org.springframework.integration.http.support.DefaultHttpHeaderMapper");
headerMapperBuilder.setFactoryMethod("outboundMapper");

View File

@@ -44,6 +44,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.mapping.HeaderMapper;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
@@ -344,7 +345,8 @@ public class DefaultHttpHeaderMapper implements HeaderMapper<HttpHeaders>, BeanF
public void afterPropertiesSet() throws Exception {
if (this.beanFactory != null && this.beanFactory instanceof DefaultListableBeanFactory){
this.conversionService = ((DefaultListableBeanFactory)this.beanFactory).getConversionService();
this.conversionService = IntegrationContextUtils.getConversionService(this.beanFactory);
}
}