Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.integration.config.ExpressionFactoryBean;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
Expand All @@ -37,6 +38,7 @@
* @author Artem Bilan
* @author Shiliang Li
* @author Arun Sethumadhavan
* @author Burak Kalayci
*
* @since 2.0.2
*/
Expand All @@ -52,6 +54,19 @@ final class HttpAdapterParsingUtils {
private static final LocalClientKind REST_CLIENT_KIND =
new LocalClientKind("rest-client", "the provided client", "RestClient.Builder.uriBuilderFactory");

static void configureLocalClientAttributes(BeanDefinitionBuilder builder, Element element) {
for (String referenceAttributeName : LOCAL_CLIENT_REFERENCE_ATTRIBUTES) {
if ("error-handler".equals(referenceAttributeName)) {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, referenceAttributeName,
"defaultStatusHandler");
}
else {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, referenceAttributeName);
}
}
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "encoding-mode");
}

static void verifyNoRestTemplateAttributes(Element element, ParserContext parserContext) {
verifyNoLocalClientAttributes(element, parserContext, REST_TEMPLATE_KIND);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* @author Artem Bilan
* @author Shiliang Li
* @author Arun Sethumadhavan
* @author Burak Kalayci
*
* @since 2.0
*/
Expand Down Expand Up @@ -100,10 +101,7 @@ else if (StringUtils.hasText(restClientRef)) {
.addIndexedArgumentValue(1, new RuntimeBeanReference(restClientRef));
}
else {
for (String referenceAttributeName : HttpAdapterParsingUtils.LOCAL_CLIENT_REFERENCE_ATTRIBUTES) {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, referenceAttributeName);
}
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "encoding-mode");
HttpAdapterParsingUtils.configureLocalClientAttributes(builder, element);
}
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* @author Artem Bilan
* @author Shiliang Li
* @author Arun Sethumadhavan
* @author Burak Kalayci
*/
public class HttpOutboundGatewayParser extends AbstractConsumerEndpointParser {

Expand Down Expand Up @@ -113,10 +114,7 @@ else if (StringUtils.hasText(restClientRef)) {
.addIndexedArgumentValue(1, new RuntimeBeanReference(restClientRef));
}
else {
for (String referenceAttributeName : HttpAdapterParsingUtils.LOCAL_CLIENT_REFERENCE_ATTRIBUTES) {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, referenceAttributeName);
}
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "encoding-mode");
HttpAdapterParsingUtils.configureLocalClientAttributes(builder, element);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add your name to all of these new classes you have improved.

}
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestTemplate;

/**
* The HTTP components Factory.
*
* @author Artem Bilan
* @author Shiliang Li
* @author Arun Sethumadhavan
* @author Burak Kalayci
*
* @since 5.0
*/
Expand Down Expand Up @@ -83,14 +83,16 @@ public static HttpMessageHandlerSpec outboundChannelAdapter(Expression uriExpres

/**
* Create an {@link HttpMessageHandlerSpec} builder for one-way adapter
* based on provided {@link URI} and {@link RestTemplate}.
* based on provided {@link URI} and {@link org.springframework.web.client.RestTemplate}.
* @param uri the {@link URI} to send requests.
* @param restTemplate {@link RestTemplate} to use.
* @param restTemplate {@link org.springframework.web.client.RestTemplate} to use.
* @return the HttpMessageHandlerSpec instance
* @deprecated Since 7.1 in favor of {@link RestClient}-based configuration.
*/
@Deprecated(since = "7.1", forRemoval = true)
public static HttpMessageHandlerSpec outboundChannelAdapter(URI uri, @Nullable RestTemplate restTemplate) {
@SuppressWarnings("removal")
public static HttpMessageHandlerSpec outboundChannelAdapter(URI uri,
org.springframework.web.client.@Nullable RestTemplate restTemplate) {
return outboundChannelAdapter(uri, toRestClient(restTemplate));
}

Expand All @@ -108,14 +110,16 @@ public static HttpMessageHandlerSpec outboundChannelAdapter(URI uri, @Nullable R

/**
* Create an {@link HttpMessageHandlerSpec} builder for one-way adapter
* based on provided {@code uri} and {@link RestTemplate}.
* based on provided {@code uri} and {@link org.springframework.web.client.RestTemplate}.
* @param uri the {@code uri} to send requests.
* @param restTemplate {@link RestTemplate} to use.
* @param restTemplate {@link org.springframework.web.client.RestTemplate} to use.
* @return the HttpMessageHandlerSpec instance
* @deprecated Since 7.1 in favor of {@link RestClient}-based configuration.
*/
@Deprecated(since = "7.1", forRemoval = true)
public static HttpMessageHandlerSpec outboundChannelAdapter(String uri, @Nullable RestTemplate restTemplate) {
@SuppressWarnings("removal")
public static HttpMessageHandlerSpec outboundChannelAdapter(String uri,
org.springframework.web.client.@Nullable RestTemplate restTemplate) {
return outboundChannelAdapter(uri, toRestClient(restTemplate));
}

Expand All @@ -134,16 +138,17 @@ public static HttpMessageHandlerSpec outboundChannelAdapter(String uri, @Nullabl
/**
* Create an {@link HttpMessageHandlerSpec} builder for one-way adapter
* based on provided {@code Function} to evaluate target {@code uri} against request message
* and {@link RestTemplate} for HTTP exchanges.
* and {@link org.springframework.web.client.RestTemplate} for HTTP exchanges.
* @param uriFunction the {@code Function} to evaluate {@code uri} at runtime.
* @param restTemplate {@link RestTemplate} to use.
* @param restTemplate {@link org.springframework.web.client.RestTemplate} to use.
* @param <P> the expected payload type.
* @return the HttpMessageHandlerSpec instance
* @deprecated Since 7.1 in favor of {@link RestClient}-based configuration.
*/
@Deprecated(since = "7.1", forRemoval = true)
@SuppressWarnings("removal")
public static <P> HttpMessageHandlerSpec outboundChannelAdapter(Function<Message<P>, ?> uriFunction,
RestTemplate restTemplate) {
org.springframework.web.client.RestTemplate restTemplate) {

return outboundChannelAdapter(new FunctionExpression<>(uriFunction), toRestClient(restTemplate));
}
Expand All @@ -167,15 +172,16 @@ public static <P> HttpMessageHandlerSpec outboundChannelAdapter(Function<Message
/**
* Create an {@link HttpMessageHandlerSpec} builder for one-way adapter
* based on provided SpEL {@link Expression} to evaluate target {@code uri}
* against request message and {@link RestTemplate} for HTTP exchanges.
* against request message and {@link org.springframework.web.client.RestTemplate} for HTTP exchanges.
* @param uriExpression the SpEL {@link Expression} to evaluate {@code uri} at runtime.
* @param restTemplate {@link RestTemplate} to use.
* @param restTemplate {@link org.springframework.web.client.RestTemplate} to use.
* @return the HttpMessageHandlerSpec instance
* @deprecated Since 7.1 in favor of {@link RestClient}-based configuration.
*/
@Deprecated(since = "7.1", forRemoval = true)
@SuppressWarnings("removal")
public static HttpMessageHandlerSpec outboundChannelAdapter(Expression uriExpression,
@Nullable RestTemplate restTemplate) {
org.springframework.web.client.@Nullable RestTemplate restTemplate) {

return outboundChannelAdapter(uriExpression, toRestClient(restTemplate));
}
Expand Down Expand Up @@ -236,14 +242,16 @@ public static HttpMessageHandlerSpec outboundGateway(Expression uriExpression) {

/**
* Create an {@link HttpMessageHandlerSpec} builder for request-reply gateway
* based on provided {@link URI} and {@link RestTemplate}.
* based on provided {@link URI} and {@link org.springframework.web.client.RestTemplate}.
* @param uri the {@link URI} to send requests.
* @param restTemplate {@link RestTemplate} to use.
* @param restTemplate {@link org.springframework.web.client.RestTemplate} to use.
* @return the HttpMessageHandlerSpec instance
* @deprecated Since 7.1 in favor of {@link RestClient}-based configuration.
*/
@Deprecated(since = "7.1", forRemoval = true)
public static HttpMessageHandlerSpec outboundGateway(URI uri, @Nullable RestTemplate restTemplate) {
@SuppressWarnings("removal")
public static HttpMessageHandlerSpec outboundGateway(URI uri,
org.springframework.web.client.@Nullable RestTemplate restTemplate) {
return outboundGateway(uri, toRestClient(restTemplate));
}

Expand All @@ -261,14 +269,16 @@ public static HttpMessageHandlerSpec outboundGateway(URI uri, @Nullable RestClie

/**
* Create an {@link HttpMessageHandlerSpec} builder for request-reply gateway
* based on provided {@code uri} and {@link RestTemplate}.
* based on provided {@code uri} and {@link org.springframework.web.client.RestTemplate}.
* @param uri the {@code uri} to send requests.
* @param restTemplate {@link RestTemplate} to use.
* @param restTemplate {@link org.springframework.web.client.RestTemplate} to use.
* @return the HttpMessageHandlerSpec instance
* @deprecated Since 7.1 in favor of {@link RestClient}-based configuration.
*/
@Deprecated(since = "7.1", forRemoval = true)
public static HttpMessageHandlerSpec outboundGateway(String uri, @Nullable RestTemplate restTemplate) {
@SuppressWarnings("removal")
public static HttpMessageHandlerSpec outboundGateway(String uri,
org.springframework.web.client.@Nullable RestTemplate restTemplate) {
return outboundGateway(uri, toRestClient(restTemplate));
}

Expand All @@ -287,16 +297,17 @@ public static HttpMessageHandlerSpec outboundGateway(String uri, @Nullable RestC
/**
* Create an {@link HttpMessageHandlerSpec} builder for request-reply gateway
* based on provided {@code Function} to evaluate target {@code uri} against request message
* and {@link RestTemplate} for HTTP exchanges.
* and {@link org.springframework.web.client.RestTemplate} for HTTP exchanges.
* @param uriFunction the {@code Function} to evaluate {@code uri} at runtime.
* @param restTemplate {@link RestTemplate} to use.
* @param restTemplate {@link org.springframework.web.client.RestTemplate} to use.
* @param <P> the expected payload type.
* @return the HttpMessageHandlerSpec instance
* @deprecated Since 7.1 in favor of {@link RestClient}-based configuration.
*/
@Deprecated(since = "7.1", forRemoval = true)
@SuppressWarnings("removal")
public static <P> HttpMessageHandlerSpec outboundGateway(Function<Message<P>, ?> uriFunction,
RestTemplate restTemplate) {
org.springframework.web.client.RestTemplate restTemplate) {

return outboundGateway(new FunctionExpression<>(uriFunction), toRestClient(restTemplate));
}
Expand All @@ -320,15 +331,16 @@ public static <P> HttpMessageHandlerSpec outboundGateway(Function<Message<P>, ?>
/**
* Create an {@link HttpMessageHandlerSpec} builder for request-reply gateway
* based on provided SpEL {@link Expression} to evaluate target {@code uri}
* against request message and {@link RestTemplate} for HTTP exchanges.
* against request message and {@link org.springframework.web.client.RestTemplate} for HTTP exchanges.
* @param uriExpression the SpEL {@link Expression} to evaluate {@code uri} at runtime.
* @param restTemplate {@link RestTemplate} to use.
* @param restTemplate {@link org.springframework.web.client.RestTemplate} to use.
* @return the HttpMessageHandlerSpec instance
* @deprecated Since 7.1 in favor of {@link RestClient}-based configuration.
*/
@Deprecated(since = "7.1", forRemoval = true)
@SuppressWarnings("removal")
public static HttpMessageHandlerSpec outboundGateway(Expression uriExpression,
@Nullable RestTemplate restTemplate) {
org.springframework.web.client.@Nullable RestTemplate restTemplate) {

return outboundGateway(uriExpression, toRestClient(restTemplate));
}
Expand Down Expand Up @@ -360,7 +372,9 @@ private static HttpMessageHandlerSpec outboundGatewaySpec(Expression uriExpressi
return new HttpMessageHandlerSpec(uriExpression, restClient);
}

private static @Nullable RestClient toRestClient(@Nullable RestTemplate restTemplate) {
@SuppressWarnings("removal")
private static @Nullable RestClient toRestClient(
org.springframework.web.client.@Nullable RestTemplate restTemplate) {
return restTemplate != null ? RestClient.create(restTemplate) : null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
import org.springframework.integration.expression.ValueExpression;
import org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler;
import org.springframework.util.Assert;
import org.springframework.web.client.ResponseErrorHandler;
import org.springframework.web.client.RestClient;
import org.springframework.web.client.RestTemplate;

/**
* The {@link BaseHttpMessageHandlerSpec} implementation for the {@link HttpRequestExecutingMessageHandler}.
Expand All @@ -42,6 +40,7 @@
* @author Oleksii Komlyk
* @author Arun Sethumadhavan
* @author Glenn Renfro
* @author Burak Kalayci
*
* @since 5.0
*
Expand All @@ -56,23 +55,27 @@ public class HttpMessageHandlerSpec
* @deprecated Since 7.1 in favor of {@link RestClient}-based configuration.
*/
@Deprecated(since = "7.1", forRemoval = true)
protected HttpMessageHandlerSpec(URI uri, @Nullable RestTemplate restTemplate) {
@SuppressWarnings("removal")
protected HttpMessageHandlerSpec(URI uri, org.springframework.web.client.@Nullable RestTemplate restTemplate) {
this(new ValueExpression<>(uri), restTemplate != null ? RestClient.create(restTemplate) : null);
}

/**
* @deprecated Since 7.1 in favor of {@link RestClient}-based configuration.
*/
@Deprecated(since = "7.1", forRemoval = true)
protected HttpMessageHandlerSpec(String uri, @Nullable RestTemplate restTemplate) {
@SuppressWarnings("removal")
protected HttpMessageHandlerSpec(String uri, org.springframework.web.client.@Nullable RestTemplate restTemplate) {
this(new LiteralExpression(uri), restTemplate != null ? RestClient.create(restTemplate) : null);
}

/**
* @deprecated Since 7.1 in favor of {@link RestClient}-based configuration.
*/
@Deprecated(since = "7.1", forRemoval = true)
protected HttpMessageHandlerSpec(Expression uriExpression, @Nullable RestTemplate restTemplate) {
@SuppressWarnings("removal")
protected HttpMessageHandlerSpec(Expression uriExpression,
org.springframework.web.client.@Nullable RestTemplate restTemplate) {
this(uriExpression, restTemplate != null ? RestClient.create(restTemplate) : null);
}

Expand All @@ -90,7 +93,8 @@ protected HttpMessageHandlerSpec(Expression uriExpression, @Nullable RestClient
}

/**
* Set the {@link ClientHttpRequestFactory} for the underlying {@link RestTemplate}.
* Set the {@link ClientHttpRequestFactory} for the underlying
* {@link org.springframework.web.client.RestTemplate}.
* @param requestFactory The request factory.
* @return the spec
* @deprecated Since 7.2 in favor of {@link RestClient}-based configuration.
Expand All @@ -103,13 +107,16 @@ public HttpMessageHandlerSpec requestFactory(ClientHttpRequestFactory requestFac
}

/**
* Set the {@link ResponseErrorHandler} for the underlying {@link RestTemplate}.
* Set the {@link org.springframework.web.client.ResponseErrorHandler} for the underlying
* {@link org.springframework.web.client.RestTemplate}.
* @param errorHandler The error handler.
* @return the spec
* @deprecated Since 7.2 in favor of {@link RestClient.ResponseSpec.ErrorHandler}.
*/
@Deprecated(since = "7.2", forRemoval = true)
public HttpMessageHandlerSpec errorHandler(ResponseErrorHandler errorHandler) {
@SuppressWarnings("removal")
public HttpMessageHandlerSpec errorHandler(
org.springframework.web.client.ResponseErrorHandler errorHandler) {
Assert.isTrue(!isClientSet(), "the 'errorHandler' must be specified on the provided client");
this.target.setErrorHandler(errorHandler);
return _this();
Expand Down
Loading