From e26c61d7f4c2fc7ae29eb36daac166f565dc23d5 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 25 Apr 2019 15:58:06 -0400 Subject: [PATCH] Add missed options into WebFluxMessageHandlerSpec (#2904) The recently introduced `setPublisherElementType()` and `setPublisherElementTypeExpression()` in the `WebFluxRequestExecutingMessageHandler` are missed in the `WebFluxMessageHandlerSpec` as delegation options * Add `@Nullable` for `WebClient` ctor arg in the `WebFluxRequestExecutingMessageHandler` --- .../dsl/WebFluxMessageHandlerSpec.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxMessageHandlerSpec.java b/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxMessageHandlerSpec.java index 6ccbc832e2..48c1437c37 100644 --- a/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxMessageHandlerSpec.java +++ b/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxMessageHandlerSpec.java @@ -17,13 +17,17 @@ package org.springframework.integration.webflux.dsl; import java.net.URI; +import java.util.function.Function; +import org.springframework.core.ParameterizedTypeReference; import org.springframework.expression.Expression; import org.springframework.expression.common.LiteralExpression; import org.springframework.http.client.reactive.ClientHttpResponse; +import org.springframework.integration.expression.FunctionExpression; import org.springframework.integration.expression.ValueExpression; import org.springframework.integration.http.dsl.BaseHttpMessageHandlerSpec; import org.springframework.integration.webflux.outbound.WebFluxRequestExecutingMessageHandler; +import org.springframework.messaging.Message; import org.springframework.web.reactive.function.BodyExtractor; import org.springframework.web.reactive.function.client.WebClient; @@ -89,6 +93,57 @@ public class WebFluxMessageHandlerSpec return this; } + /** + * Configure a type for a request {@link org.reactivestreams.Publisher} elements. + * @param publisherElementType the type of the request {@link org.reactivestreams.Publisher} elements. + * @return the spec + * @since 5.2 + * @see WebFluxRequestExecutingMessageHandler#setPublisherElementType + */ + public WebFluxMessageHandlerSpec publisherElementType(Class publisherElementType) { + this.target.setPublisherElementType(publisherElementType); + return this; + } + + /** + * Configure a {@link ParameterizedTypeReference} for a request {@link org.reactivestreams.Publisher} elements. + * @param publisherElementType the type of the request {@link org.reactivestreams.Publisher} elements. + * @return the spec + * @since 5.2 + * @see WebFluxRequestExecutingMessageHandler#setPublisherElementType + */ + public WebFluxMessageHandlerSpec publisherElementType(ParameterizedTypeReference publisherElementType) { + return publisherElementTypeExpression(new ValueExpression<>(publisherElementType)); + } + + /** + * Configure a {@link Function} to evaluate a request {@link org.reactivestreams.Publisher} + * elements type at runtime against a request message. + * @param typeFunction the {@link Function} to evaluate a type for the request + * {@link org.reactivestreams.Publisher} elements. + * @param

the expected payload type. + * @return the spec + * @since 5.2 + * @see WebFluxRequestExecutingMessageHandler#setPublisherElementTypeExpression(Expression) + */ + public

WebFluxMessageHandlerSpec publisherElementTypeFunction(Function, ?> typeFunction) { + return publisherElementTypeExpression(new FunctionExpression<>(typeFunction)); + } + + /** + * Configure a SpEL expression to evaluate a request {@link org.reactivestreams.Publisher} + * elements type at runtime against a request message. + * @param publisherElementTypeExpression the expression to evaluate a type for the request + * {@link org.reactivestreams.Publisher} elements. + * @return the spec + * @since 5.2 + * @see WebFluxRequestExecutingMessageHandler#setPublisherElementTypeExpression(Expression) + */ + public WebFluxMessageHandlerSpec publisherElementTypeExpression(Expression publisherElementTypeExpression) { + this.target.setPublisherElementTypeExpression(publisherElementTypeExpression); + return this; + } + @Override protected boolean isClientSet() { return this.webClient != null;