INT-1232: renamed ParameterExtractor
This commit is contained in:
@@ -29,9 +29,9 @@ import org.springframework.integration.core.Message;
|
||||
* @since 2.0
|
||||
*
|
||||
*/
|
||||
public class DefaultParameterMapper implements ParameterMapper {
|
||||
public class DefaultParameterExtractor implements ParameterExtractor {
|
||||
|
||||
private static Log logger = LogFactory.getLog(DefaultParameterMapper.class);
|
||||
private static Log logger = LogFactory.getLog(DefaultParameterExtractor.class);
|
||||
|
||||
private SpelExpressionParser parser = new SpelExpressionParser();
|
||||
|
||||
@@ -56,7 +56,7 @@ public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMe
|
||||
|
||||
private final RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
private ParameterMapper parameterMapper = new DefaultParameterMapper();
|
||||
private ParameterExtractor parameterExtractor = new DefaultParameterExtractor();
|
||||
|
||||
/**
|
||||
* Create a handler that will send requests to the provided URI.
|
||||
@@ -144,19 +144,19 @@ public class HttpRequestExecutingMessageHandler extends AbstractReplyProducingMe
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link ParameterMapper} for creating URI parameters from the outbound message.
|
||||
* Set the {@link ParameterExtractor} for creating URI parameters from the outbound message.
|
||||
*
|
||||
* @param parameterMapper the parameter mapper to set
|
||||
* @param parameterExtractor the parameter extractor to set
|
||||
*/
|
||||
public void setParameterMapper(ParameterMapper parameterMapper) {
|
||||
this.parameterMapper = parameterMapper;
|
||||
public void setParameterExtractor(ParameterExtractor parameterExtractor) {
|
||||
this.parameterExtractor = parameterExtractor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object handleRequestMessage(Message<?> requestMessage) {
|
||||
try {
|
||||
// TODO: allow a boolean flag for treating Map as queryParams vs. uriVariables?
|
||||
Map<String, ?> uriVariables = this.parameterMapper.fromMessage(requestMessage);
|
||||
Map<String, ?> uriVariables = this.parameterExtractor.fromMessage(requestMessage);
|
||||
HttpEntity<?> httpRequest = this.requestMapper.fromMessage(requestMessage);
|
||||
ResponseEntity<?> httpResponse = this.restTemplate.exchange(this.uri, this.httpMethod, httpRequest, this.expectedResponseType, uriVariables);
|
||||
if (this.expectReply) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.integration.core.Message;
|
||||
* @since 2.0
|
||||
*
|
||||
*/
|
||||
public interface ParameterMapper {
|
||||
public interface ParameterExtractor {
|
||||
|
||||
/**
|
||||
* @param requestMessage
|
||||
@@ -42,7 +42,7 @@ public class HttpOutboundChannelAdapterParser extends AbstractOutboundChannelAda
|
||||
builder.addConstructorArgValue(element.getAttribute("url"));
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "http-method");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "message-converters");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "parameter-mapper");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "parameter-extractor");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "charset");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-payload");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "expected-response-type");
|
||||
|
||||
@@ -45,7 +45,7 @@ public class HttpOutboundGatewayParser extends AbstractConsumerEndpointParser {
|
||||
builder.addConstructorArgValue(element.getAttribute("url"));
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "http-method");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "message-converters");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "parameter-mapper");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "parameter-extractor");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "charset");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "extract-request-payload", "extractPayload");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "expected-response-type");
|
||||
|
||||
@@ -112,11 +112,11 @@
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="parameter-mapper" type="xsd:string">
|
||||
<xsd:attribute name="parameter-extractor" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.http.ParameterMapper"/>
|
||||
<tool:expected-type type="org.springframework.integration.http.ParameterExtractor"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
@@ -204,11 +204,11 @@
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="parameter-mapper" type="xsd:string">
|
||||
<xsd:attribute name="parameter-extractor" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.http.ParameterMapper"/>
|
||||
<tool:expected-type type="org.springframework.integration.http.ParameterExtractor"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
|
||||
@@ -28,11 +28,11 @@ import org.springframework.integration.message.GenericMessage;
|
||||
* @since 2.0
|
||||
*
|
||||
*/
|
||||
public class DefaultParameterMapperTests {
|
||||
public class DefaultParameterExtractorTests {
|
||||
|
||||
@Test
|
||||
public void testFromMessage() throws Exception {
|
||||
DefaultParameterMapper mapper = new DefaultParameterMapper();
|
||||
DefaultParameterExtractor mapper = new DefaultParameterExtractor();
|
||||
Map<String, ?> params = mapper.fromMessage(new GenericMessage<Object>(Collections.singletonMap("foo", "bar")));
|
||||
assertEquals(1, params.size());
|
||||
assertEquals("bar", params.get("foo"));
|
||||
@@ -40,7 +40,7 @@ public class DefaultParameterMapperTests {
|
||||
|
||||
@Test
|
||||
public void testFromMessageWithExpressions() throws Exception {
|
||||
DefaultParameterMapper mapper = new DefaultParameterMapper();
|
||||
DefaultParameterExtractor mapper = new DefaultParameterExtractor();
|
||||
mapper.setDynamicParameterExpressions(Collections.singletonMap("foo", "payload"));
|
||||
Map<String, ?> params = mapper.fromMessage(new GenericMessage<Object>("bar"));
|
||||
assertEquals(1, params.size());
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<outbound-channel-adapter id="fullConfig"
|
||||
url="http://localhost/test2"
|
||||
parameter-mapper="testParameterMapper"
|
||||
parameter-extractor="testParameterMapper"
|
||||
http-method="GET"
|
||||
channel="requests"
|
||||
charset="UTF-8"
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<beans:bean id="testRequestFactory" class="org.springframework.http.client.SimpleClientHttpRequestFactory"/>
|
||||
|
||||
<beans:bean id="testParameterMapper" class="org.springframework.integration.http.DefaultParameterMapper"/>
|
||||
<beans:bean id="testParameterMapper" class="org.springframework.integration.http.DefaultParameterExtractor"/>
|
||||
|
||||
<util:list id="converterList">
|
||||
<beans:bean class="org.springframework.integration.http.config.StubHttpMessageConverter"/>
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.http.DefaultOutboundRequestMapper;
|
||||
import org.springframework.integration.http.HttpRequestExecutingMessageHandler;
|
||||
import org.springframework.integration.http.OutboundRequestMapper;
|
||||
import org.springframework.integration.http.ParameterMapper;
|
||||
import org.springframework.integration.http.ParameterExtractor;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class HttpOutboundChannelAdapterParserTests {
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
private ParameterMapper parameterMapper;
|
||||
private ParameterExtractor parameterExtractor;
|
||||
|
||||
|
||||
@Test
|
||||
@@ -105,7 +105,7 @@ public class HttpOutboundChannelAdapterParserTests {
|
||||
assertEquals(HttpMethod.GET, handlerAccessor.getPropertyValue("httpMethod"));
|
||||
assertEquals("UTF-8", mapperAccessor.getPropertyValue("charset"));
|
||||
assertEquals(false, mapperAccessor.getPropertyValue("extractPayload"));
|
||||
assertEquals(parameterMapper, handlerAccessor.getPropertyValue("parameterMapper"));
|
||||
assertEquals(parameterExtractor, handlerAccessor.getPropertyValue("parameterExtractor"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<outbound-gateway id="fullConfig"
|
||||
url="http://localhost/test2"
|
||||
parameter-mapper="testParameterMapper"
|
||||
parameter-extractor="testParameterMapper"
|
||||
http-method="PUT"
|
||||
request-channel="requests"
|
||||
request-factory="testRequestFactory"
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
<beans:bean id="testRequestFactory" class="org.springframework.http.client.SimpleClientHttpRequestFactory"/>
|
||||
|
||||
<beans:bean id="testParameterMapper" class="org.springframework.integration.http.DefaultParameterMapper"/>
|
||||
<beans:bean id="testParameterMapper" class="org.springframework.integration.http.DefaultParameterExtractor"/>
|
||||
|
||||
<util:list id="converterList">
|
||||
<beans:bean class="org.springframework.integration.http.config.StubHttpMessageConverter"/>
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.http.DefaultOutboundRequestMapper;
|
||||
import org.springframework.integration.http.HttpRequestExecutingMessageHandler;
|
||||
import org.springframework.integration.http.OutboundRequestMapper;
|
||||
import org.springframework.integration.http.ParameterMapper;
|
||||
import org.springframework.integration.http.ParameterExtractor;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class HttpOutboundGatewayParserTests {
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
private ParameterMapper parameterMapper;
|
||||
private ParameterExtractor parameterExtractor;
|
||||
|
||||
@Test
|
||||
public void minimalConfig() {
|
||||
@@ -114,7 +114,7 @@ public class HttpOutboundGatewayParserTests {
|
||||
Object sendTimeout = new DirectFieldAccessor(
|
||||
handlerAccessor.getPropertyValue("channelTemplate")).getPropertyValue("sendTimeout");
|
||||
assertEquals(new Long("1234"), sendTimeout);
|
||||
assertEquals(parameterMapper, handlerAccessor.getPropertyValue("parameterMapper"));
|
||||
assertEquals(parameterExtractor, handlerAccessor.getPropertyValue("parameterExtractor"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user