Skip to content

Commit e26c61d

Browse files
artembilangaryrussell
authored andcommitted
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`
1 parent c570bee commit e26c61d

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxMessageHandlerSpec.java

+55
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717
package org.springframework.integration.webflux.dsl;
1818

1919
import java.net.URI;
20+
import java.util.function.Function;
2021

22+
import org.springframework.core.ParameterizedTypeReference;
2123
import org.springframework.expression.Expression;
2224
import org.springframework.expression.common.LiteralExpression;
2325
import org.springframework.http.client.reactive.ClientHttpResponse;
26+
import org.springframework.integration.expression.FunctionExpression;
2427
import org.springframework.integration.expression.ValueExpression;
2528
import org.springframework.integration.http.dsl.BaseHttpMessageHandlerSpec;
2629
import org.springframework.integration.webflux.outbound.WebFluxRequestExecutingMessageHandler;
30+
import org.springframework.messaging.Message;
2731
import org.springframework.web.reactive.function.BodyExtractor;
2832
import org.springframework.web.reactive.function.client.WebClient;
2933

@@ -89,6 +93,57 @@ public WebFluxMessageHandlerSpec bodyExtractor(BodyExtractor<?, ClientHttpRespon
8993
return this;
9094
}
9195

96+
/**
97+
* Configure a type for a request {@link org.reactivestreams.Publisher} elements.
98+
* @param publisherElementType the type of the request {@link org.reactivestreams.Publisher} elements.
99+
* @return the spec
100+
* @since 5.2
101+
* @see WebFluxRequestExecutingMessageHandler#setPublisherElementType
102+
*/
103+
public WebFluxMessageHandlerSpec publisherElementType(Class<?> publisherElementType) {
104+
this.target.setPublisherElementType(publisherElementType);
105+
return this;
106+
}
107+
108+
/**
109+
* Configure a {@link ParameterizedTypeReference} for a request {@link org.reactivestreams.Publisher} elements.
110+
* @param publisherElementType the type of the request {@link org.reactivestreams.Publisher} elements.
111+
* @return the spec
112+
* @since 5.2
113+
* @see WebFluxRequestExecutingMessageHandler#setPublisherElementType
114+
*/
115+
public WebFluxMessageHandlerSpec publisherElementType(ParameterizedTypeReference<?> publisherElementType) {
116+
return publisherElementTypeExpression(new ValueExpression<>(publisherElementType));
117+
}
118+
119+
/**
120+
* Configure a {@link Function} to evaluate a request {@link org.reactivestreams.Publisher}
121+
* elements type at runtime against a request message.
122+
* @param typeFunction the {@link Function} to evaluate a type for the request
123+
* {@link org.reactivestreams.Publisher} elements.
124+
* @param <P> the expected payload type.
125+
* @return the spec
126+
* @since 5.2
127+
* @see WebFluxRequestExecutingMessageHandler#setPublisherElementTypeExpression(Expression)
128+
*/
129+
public <P> WebFluxMessageHandlerSpec publisherElementTypeFunction(Function<Message<P>, ?> typeFunction) {
130+
return publisherElementTypeExpression(new FunctionExpression<>(typeFunction));
131+
}
132+
133+
/**
134+
* Configure a SpEL expression to evaluate a request {@link org.reactivestreams.Publisher}
135+
* elements type at runtime against a request message.
136+
* @param publisherElementTypeExpression the expression to evaluate a type for the request
137+
* {@link org.reactivestreams.Publisher} elements.
138+
* @return the spec
139+
* @since 5.2
140+
* @see WebFluxRequestExecutingMessageHandler#setPublisherElementTypeExpression(Expression)
141+
*/
142+
public WebFluxMessageHandlerSpec publisherElementTypeExpression(Expression publisherElementTypeExpression) {
143+
this.target.setPublisherElementTypeExpression(publisherElementTypeExpression);
144+
return this;
145+
}
146+
92147
@Override
93148
protected boolean isClientSet() {
94149
return this.webClient != null;

0 commit comments

Comments
 (0)