|
17 | 17 | package org.springframework.integration.webflux.dsl;
|
18 | 18 |
|
19 | 19 | import java.net.URI;
|
| 20 | +import java.util.function.Function; |
20 | 21 |
|
| 22 | +import org.springframework.core.ParameterizedTypeReference; |
21 | 23 | import org.springframework.expression.Expression;
|
22 | 24 | import org.springframework.expression.common.LiteralExpression;
|
23 | 25 | import org.springframework.http.client.reactive.ClientHttpResponse;
|
| 26 | +import org.springframework.integration.expression.FunctionExpression; |
24 | 27 | import org.springframework.integration.expression.ValueExpression;
|
25 | 28 | import org.springframework.integration.http.dsl.BaseHttpMessageHandlerSpec;
|
26 | 29 | import org.springframework.integration.webflux.outbound.WebFluxRequestExecutingMessageHandler;
|
| 30 | +import org.springframework.messaging.Message; |
27 | 31 | import org.springframework.web.reactive.function.BodyExtractor;
|
28 | 32 | import org.springframework.web.reactive.function.client.WebClient;
|
29 | 33 |
|
@@ -89,6 +93,57 @@ public WebFluxMessageHandlerSpec bodyExtractor(BodyExtractor<?, ClientHttpRespon
|
89 | 93 | return this;
|
90 | 94 | }
|
91 | 95 |
|
| 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 | + |
92 | 147 | @Override
|
93 | 148 | protected boolean isClientSet() {
|
94 | 149 | return this.webClient != null;
|
|
0 commit comments