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`
This commit is contained in:
Artem Bilan
2019-04-25 15:58:06 -04:00
committed by Gary Russell
parent c570bee197
commit e26c61d7f4

View File

@@ -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 <P> the expected payload type.
* @return the spec
* @since 5.2
* @see WebFluxRequestExecutingMessageHandler#setPublisherElementTypeExpression(Expression)
*/
public <P> WebFluxMessageHandlerSpec publisherElementTypeFunction(Function<Message<P>, ?> 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;