Removed hardcoded "restTemplate" references.
This commit is contained in:
@@ -26,12 +26,12 @@ import org.springframework.beans.factory.xml.ParserContext;
|
||||
*/
|
||||
abstract class HttpAdapterParsingUtils {
|
||||
|
||||
private static final String[] REST_TEMPLATE_ATTRIBUTES = {
|
||||
static final String[] REST_TEMPLATE_REFERENCE_ATTRIBUTES = {
|
||||
"request-factory", "error-handler", "message-converters"
|
||||
};
|
||||
|
||||
static void verifyNoRestTemplateAttributes(Element element, ParserContext parserContext) {
|
||||
for (String attributeName : REST_TEMPLATE_ATTRIBUTES) {
|
||||
for (String attributeName : REST_TEMPLATE_REFERENCE_ATTRIBUTES) {
|
||||
if (element.hasAttribute(attributeName)) {
|
||||
parserContext.getReaderContext().error("When providing a 'rest-template' reference, the '"
|
||||
+ attributeName + "' attribute is not allowed.",
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,14 +49,14 @@ public class HttpOutboundChannelAdapterParser extends AbstractOutboundChannelAda
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "http-method");
|
||||
|
||||
String restTemplate = element.getAttribute("rest-template");
|
||||
if (StringUtils.hasText(restTemplate)){
|
||||
if (StringUtils.hasText(restTemplate)) {
|
||||
HttpAdapterParsingUtils.verifyNoRestTemplateAttributes(element, parserContext);
|
||||
builder.addConstructorArgReference("restTemplate");
|
||||
builder.addConstructorArgReference(restTemplate);
|
||||
}
|
||||
else {
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "message-converters");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "error-handler");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "request-factory");
|
||||
for (String referenceAttributeName : HttpAdapterParsingUtils.REST_TEMPLATE_REFERENCE_ATTRIBUTES) {
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, referenceAttributeName);
|
||||
}
|
||||
}
|
||||
|
||||
String headerMapper = element.getAttribute("header-mapper");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,14 +51,14 @@ public class HttpOutboundGatewayParser extends AbstractConsumerEndpointParser {
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "http-method");
|
||||
|
||||
String restTemplate = element.getAttribute("rest-template");
|
||||
if (StringUtils.hasText(restTemplate)){
|
||||
if (StringUtils.hasText(restTemplate)) {
|
||||
HttpAdapterParsingUtils.verifyNoRestTemplateAttributes(element, parserContext);
|
||||
builder.addConstructorArgReference("restTemplate");
|
||||
builder.addConstructorArgReference(restTemplate);
|
||||
}
|
||||
else {
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "message-converters");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "error-handler");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "request-factory");
|
||||
for (String referenceAttributeName : HttpAdapterParsingUtils.REST_TEMPLATE_REFERENCE_ATTRIBUTES) {
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, referenceAttributeName);
|
||||
}
|
||||
}
|
||||
|
||||
String headerMapper = element.getAttribute("header-mapper");
|
||||
|
||||
Reference in New Issue
Block a user