INT-1207 added support for the "http-method" attribute on <outbound-gateway> and <outbound-channel-adapter> elements in the http namespace
This commit is contained in:
@@ -40,6 +40,7 @@ public class HttpOutboundChannelAdapterParser extends AbstractOutboundChannelAda
|
||||
PACKAGE_PATH + ".HttpRequestExecutingMessageHandler");
|
||||
builder.addPropertyValue("expectReply", false);
|
||||
builder.addConstructorArgValue(element.getAttribute("url"));
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "http-method");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "charset");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-payload");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "request-factory");
|
||||
|
||||
@@ -43,6 +43,7 @@ public class HttpOutboundGatewayParser extends AbstractConsumerEndpointParser {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
PACKAGE_PATH + ".HttpRequestExecutingMessageHandler");
|
||||
builder.addConstructorArgValue(element.getAttribute("url"));
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "http-method");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "charset");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-request-payload", "extractPayload");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "request-timeout", "sendTimeout");
|
||||
|
||||
@@ -112,6 +112,16 @@
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="http-method">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The HTTP method to use when executing requests with this adapter.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:union memberTypes="httpMethodEnumeration xsd:string" />
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="channel" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
@@ -165,6 +175,16 @@
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="http-method">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The HTTP method to use when executing requests with this adapter.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:union memberTypes="httpMethodEnumeration xsd:string" />
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="extract-request-payload" type="xsd:string"/>
|
||||
<xsd:attribute name="charset" type="xsd:string"/>
|
||||
<xsd:attribute name="request-factory" type="xsd:string">
|
||||
@@ -189,6 +209,18 @@
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:simpleType name="httpMethodEnumeration">
|
||||
<xsd:restriction base="xsd:token">
|
||||
<xsd:enumeration value="GET" />
|
||||
<xsd:enumeration value="POST" />
|
||||
<xsd:enumeration value="HEAD" />
|
||||
<xsd:enumeration value="OPTIONS" />
|
||||
<xsd:enumeration value="PUT" />
|
||||
<xsd:enumeration value="DELETE" />
|
||||
<xsd:enumeration value="TRACE" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
|
||||
<xsd:complexType name="gatewayType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
<outbound-channel-adapter id="fullConfig"
|
||||
url="http://localhost/test2"
|
||||
http-method="GET"
|
||||
channel="requests"
|
||||
charset="UTF-8"
|
||||
extract-payload="false"
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
@@ -69,6 +70,7 @@ public class HttpOutboundChannelAdapterParserTests {
|
||||
assertTrue(requestFactory instanceof SimpleClientHttpRequestFactory);
|
||||
DirectFieldAccessor mapperAccessor = new DirectFieldAccessor(mapper);
|
||||
assertEquals("http://localhost/test1", handlerAccessor.getPropertyValue("uri"));
|
||||
assertEquals(HttpMethod.POST, handlerAccessor.getPropertyValue("httpMethod"));
|
||||
assertEquals("UTF-8", mapperAccessor.getPropertyValue("charset"));
|
||||
assertEquals(true, mapperAccessor.getPropertyValue("extractPayload"));
|
||||
}
|
||||
@@ -93,6 +95,7 @@ public class HttpOutboundChannelAdapterParserTests {
|
||||
assertEquals(requestFactoryBean, requestFactory);
|
||||
DirectFieldAccessor mapperAccessor = new DirectFieldAccessor(mapper);
|
||||
assertEquals("http://localhost/test2", handlerAccessor.getPropertyValue("uri"));
|
||||
assertEquals(HttpMethod.GET, handlerAccessor.getPropertyValue("httpMethod"));
|
||||
assertEquals("UTF-8", mapperAccessor.getPropertyValue("charset"));
|
||||
assertEquals(false, mapperAccessor.getPropertyValue("extractPayload"));
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
<outbound-gateway id="fullConfig"
|
||||
url="http://localhost/test2"
|
||||
http-method="PUT"
|
||||
request-channel="requests"
|
||||
request-factory="testRequestFactory"
|
||||
request-timeout="1234"
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -73,6 +74,7 @@ public class HttpOutboundGatewayParserTests {
|
||||
assertTrue(requestFactory instanceof SimpleClientHttpRequestFactory);
|
||||
DirectFieldAccessor mapperAccessor = new DirectFieldAccessor(mapper);
|
||||
assertEquals("http://localhost/test1", handlerAccessor.getPropertyValue("uri"));
|
||||
assertEquals(HttpMethod.POST, handlerAccessor.getPropertyValue("httpMethod"));
|
||||
assertEquals("UTF-8", mapperAccessor.getPropertyValue("charset"));
|
||||
assertEquals(true, mapperAccessor.getPropertyValue("extractPayload"));
|
||||
}
|
||||
@@ -98,6 +100,7 @@ public class HttpOutboundGatewayParserTests {
|
||||
assertTrue(requestFactory instanceof SimpleClientHttpRequestFactory);
|
||||
DirectFieldAccessor mapperAccessor = new DirectFieldAccessor(mapper);
|
||||
assertEquals("http://localhost/test2", handlerAccessor.getPropertyValue("uri"));
|
||||
assertEquals(HttpMethod.PUT, handlerAccessor.getPropertyValue("httpMethod"));
|
||||
assertEquals("UTF-8", mapperAccessor.getPropertyValue("charset"));
|
||||
assertEquals(false, mapperAccessor.getPropertyValue("extractPayload"));
|
||||
Object requestFactoryBean = this.applicationContext.getBean("testRequestFactory");
|
||||
|
||||
Reference in New Issue
Block a user