diff --git a/spring-web/src/main/java/org/springframework/web/service/annotation/GetRequest.java b/spring-web/src/main/java/org/springframework/web/service/annotation/GetExchange.java
similarity index 75%
rename from spring-web/src/main/java/org/springframework/web/service/annotation/GetRequest.java
rename to spring-web/src/main/java/org/springframework/web/service/annotation/GetExchange.java
index 3160bd364c..323f6b16db 100644
--- a/spring-web/src/main/java/org/springframework/web/service/annotation/GetRequest.java
+++ b/spring-web/src/main/java/org/springframework/web/service/annotation/GetExchange.java
@@ -26,7 +26,7 @@ import org.springframework.core.annotation.AliasFor;
/**
- * Shortcut for {@link HttpRequest} for HTTP GET requests.
+ * Shortcut for {@link HttpExchange} for HTTP GET requests.
*
* @author Rossen Stoyanchev
* @since 6.0
@@ -34,25 +34,25 @@ import org.springframework.core.annotation.AliasFor;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
-@HttpRequest(method = "GET")
-public @interface GetRequest {
+@HttpExchange(method = "GET")
+public @interface GetExchange {
/**
- * Alias for {@link HttpRequest#value}.
+ * Alias for {@link HttpExchange#value}.
*/
- @AliasFor(annotation = HttpRequest.class)
+ @AliasFor(annotation = HttpExchange.class)
String value() default "";
/**
- * Alias for {@link HttpRequest#url()}.
+ * Alias for {@link HttpExchange#url()}.
*/
- @AliasFor(annotation = HttpRequest.class)
+ @AliasFor(annotation = HttpExchange.class)
String url() default "";
/**
- * Alias for {@link HttpRequest#accept()}.
+ * Alias for {@link HttpExchange#accept()}.
*/
- @AliasFor(annotation = HttpRequest.class)
+ @AliasFor(annotation = HttpExchange.class)
String[] accept() default {};
}
diff --git a/spring-web/src/main/java/org/springframework/web/service/annotation/HttpRequest.java b/spring-web/src/main/java/org/springframework/web/service/annotation/HttpExchange.java
similarity index 95%
rename from spring-web/src/main/java/org/springframework/web/service/annotation/HttpRequest.java
rename to spring-web/src/main/java/org/springframework/web/service/annotation/HttpExchange.java
index 388f0761a5..4fc74c4304 100644
--- a/spring-web/src/main/java/org/springframework/web/service/annotation/HttpRequest.java
+++ b/spring-web/src/main/java/org/springframework/web/service/annotation/HttpExchange.java
@@ -42,7 +42,7 @@ import org.springframework.web.bind.annotation.Mapping;
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Mapping
-public @interface HttpRequest {
+public @interface HttpExchange {
/**
* This is an alias for {@link #url}.
@@ -52,7 +52,7 @@ public @interface HttpRequest {
/**
* The URL for the request, either a full URL or a path only that is relative
- * to a URL declared in a type-level {@code @HttpRequest}, and/or a globally
+ * to a URL declared in a type-level {@code @HttpExchange}, and/or a globally
* configured base URL.
*
By default, this is empty.
*/
@@ -67,7 +67,6 @@ public @interface HttpRequest {
*/
String method() default "";
-
/**
* The media type for the {@code "Content-Type"} header.
*
Supported at the type level as well as at the method level, in which
diff --git a/spring-web/src/main/java/org/springframework/web/service/annotation/PostRequest.java b/spring-web/src/main/java/org/springframework/web/service/annotation/PostExchange.java
similarity index 71%
rename from spring-web/src/main/java/org/springframework/web/service/annotation/PostRequest.java
rename to spring-web/src/main/java/org/springframework/web/service/annotation/PostExchange.java
index 7a824a4df4..1f948e5309 100644
--- a/spring-web/src/main/java/org/springframework/web/service/annotation/PostRequest.java
+++ b/spring-web/src/main/java/org/springframework/web/service/annotation/PostExchange.java
@@ -24,8 +24,9 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
+
/**
- * Shortcut for {@link HttpRequest} for HTTP POST requests.
+ * Shortcut for {@link HttpExchange} for HTTP POST requests.
*
* @author Rossen Stoyanchev
* @since 6.0
@@ -33,31 +34,31 @@ import org.springframework.core.annotation.AliasFor;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
-@HttpRequest(method = "POST")
-public @interface PostRequest {
+@HttpExchange(method = "POST")
+public @interface PostExchange {
/**
- * Alias for {@link HttpRequest#value}.
+ * Alias for {@link HttpExchange#value}.
*/
- @AliasFor(annotation = HttpRequest.class)
+ @AliasFor(annotation = HttpExchange.class)
String value() default "";
/**
- * Alias for {@link HttpRequest#url()}.
+ * Alias for {@link HttpExchange#url()}.
*/
- @AliasFor(annotation = HttpRequest.class)
+ @AliasFor(annotation = HttpExchange.class)
String url() default "";
/**
- * Alias for {@link HttpRequest#contentType()}.
+ * Alias for {@link HttpExchange#contentType()}.
*/
- @AliasFor(annotation = HttpRequest.class)
+ @AliasFor(annotation = HttpExchange.class)
String contentType() default "";
/**
- * Alias for {@link HttpRequest#accept()}.
+ * Alias for {@link HttpExchange#accept()}.
*/
- @AliasFor(annotation = HttpRequest.class)
+ @AliasFor(annotation = HttpExchange.class)
String[] accept() default {};
}
diff --git a/spring-web/src/main/java/org/springframework/web/service/annotation/PutRequest.java b/spring-web/src/main/java/org/springframework/web/service/annotation/PutExchange.java
similarity index 75%
rename from spring-web/src/main/java/org/springframework/web/service/annotation/PutRequest.java
rename to spring-web/src/main/java/org/springframework/web/service/annotation/PutExchange.java
index f553497f6d..c17c031b23 100644
--- a/spring-web/src/main/java/org/springframework/web/service/annotation/PutRequest.java
+++ b/spring-web/src/main/java/org/springframework/web/service/annotation/PutExchange.java
@@ -24,8 +24,9 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
+
/**
- * Shortcut for {@link HttpRequest} for HTTP PUT requests.
+ * Shortcut for {@link HttpExchange} for HTTP PUT requests.
*
* @author Rossen Stoyanchev
* @since 6.0
@@ -33,25 +34,25 @@ import org.springframework.core.annotation.AliasFor;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
-@HttpRequest(method = "PUT")
-public @interface PutRequest {
+@HttpExchange(method = "PUT")
+public @interface PutExchange {
/**
- * Alias for {@link HttpRequest#value}.
+ * Alias for {@link HttpExchange#value}.
*/
- @AliasFor(annotation = HttpRequest.class)
+ @AliasFor(annotation = HttpExchange.class)
String[] value() default {};
/**
- * Alias for {@link HttpRequest#url()}.
+ * Alias for {@link HttpExchange#url()}.
*/
- @AliasFor(annotation = HttpRequest.class)
+ @AliasFor(annotation = HttpExchange.class)
String[] url() default {};
/**
- * Alias for {@link HttpRequest#contentType()}.
+ * Alias for {@link HttpExchange#contentType()}.
*/
- @AliasFor(annotation = HttpRequest.class)
+ @AliasFor(annotation = HttpExchange.class)
String contentType() default "";
}
diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpClientAdapter.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpClientAdapter.java
index fba817a677..58033379d0 100644
--- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpClientAdapter.java
+++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpClientAdapter.java
@@ -25,26 +25,26 @@ import org.springframework.http.ResponseEntity;
/**
- * Decouple an {@link HttpServiceProxyFactory#createService(Class) HTTP Service proxy}
- * from the underlying HTTP client.
+ * Contract to abstract the underlying HTTP client and decouple it from the
+ * {@link HttpServiceProxyFactory#createClient(Class) HTTP Service proxy}.
*
* @author Rossen Stoyanchev
* @since 6.0
*/
public interface HttpClientAdapter {
- Mono requestToVoid(HttpRequestDefinition requestDefinition);
+ Mono requestToVoid(HttpRequestSpec spec);
- Mono requestToHeaders(HttpRequestDefinition requestDefinition);
+ Mono requestToHeaders(HttpRequestSpec spec);
- Mono requestToBody(HttpRequestDefinition requestDefinition, ParameterizedTypeReference bodyType);
+ Mono requestToBody(HttpRequestSpec spec, ParameterizedTypeReference bodyType);
- Flux requestToBodyFlux(HttpRequestDefinition requestDefinition, ParameterizedTypeReference bodyType);
+ Flux requestToBodyFlux(HttpRequestSpec spec, ParameterizedTypeReference bodyType);
- Mono> requestToBodilessEntity(HttpRequestDefinition requestDefinition);
+ Mono> requestToBodilessEntity(HttpRequestSpec spec);
- Mono> requestToEntity(HttpRequestDefinition requestDefinition, ParameterizedTypeReference bodyType);
+ Mono> requestToEntity(HttpRequestSpec spec, ParameterizedTypeReference bodyType);
- Mono>> requestToEntityFlux(HttpRequestDefinition requestDefinition, ParameterizedTypeReference bodyType);
+ Mono>> requestToEntityFlux(HttpRequestSpec spec, ParameterizedTypeReference bodyType);
}
diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpMethodArgumentResolver.java
index 6f3e1c2f76..9a4fe47b3d 100644
--- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpMethodArgumentResolver.java
+++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpMethodArgumentResolver.java
@@ -25,20 +25,20 @@ import org.springframework.lang.Nullable;
/**
- * {@link HttpServiceMethodArgumentResolver} that resolves the target
+ * {@link HttpServiceArgumentResolver} that resolves the target
* request's HTTP method from an {@link HttpMethod} argument.
*
* @author Olga Maciaszek-Sharma
* @since 6.0
*/
-public class HttpMethodArgumentResolver implements HttpServiceMethodArgumentResolver {
+public class HttpMethodArgumentResolver implements HttpServiceArgumentResolver {
private static final Log logger = LogFactory.getLog(HttpMethodArgumentResolver.class);
@Override
public void resolve(
- @Nullable Object argument, MethodParameter parameter, HttpRequestDefinition requestDefinition) {
+ @Nullable Object argument, MethodParameter parameter, HttpRequestSpec requestSpec) {
if (argument == null) {
return;
@@ -47,7 +47,7 @@ public class HttpMethodArgumentResolver implements HttpServiceMethodArgumentReso
if (logger.isTraceEnabled()) {
logger.trace("Resolved HTTP method to: " + httpMethod.name());
}
- requestDefinition.setHttpMethod(httpMethod);
+ requestSpec.setHttpMethod(httpMethod);
}
}
diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestDefinition.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestSpec.java
similarity index 92%
rename from spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestDefinition.java
rename to spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestSpec.java
index ee6a266a2a..1801e9afee 100644
--- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestDefinition.java
+++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestSpec.java
@@ -30,7 +30,6 @@ import org.springframework.core.MethodParameter;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpRequest;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -39,15 +38,15 @@ import org.springframework.util.MultiValueMap;
/**
- * Container for HTTP request values accumulated from an
- * {@link HttpRequest @HttpRequest}-annotated method and arguments passed to it.
- * This allows an {@link HttpClientAdapter} adapt these inputs as it sees fit
- * to the API of the underlying client.
+ * Container for HTTP request values extracted from an
+ * {@link org.springframework.web.service.annotation.HttpExchange @HttpExchange}-annotated
+ * method and argument values passed to it. This is then given to
+ * {@link HttpClientAdapter} to adapt to the underlying HTTP client.
*
* @author Rossen Stoyanchev
* @since 6.0
*/
-public class HttpRequestDefinition {
+public class HttpRequestSpec {
private static final MultiValueMap EMPTY_COOKIES_MAP =
CollectionUtils.toMultiValueMap(Collections.emptyMap());
@@ -86,6 +85,10 @@ public class HttpRequestDefinition {
private boolean complete;
+ public HttpRequestSpec() {
+ }
+
+
public void setUri(URI uri) {
checkComplete();
this.uri = uri;
@@ -175,6 +178,8 @@ public class HttpRequestDefinition {
void setComplete() {
+ this.complete = true;
+
this.uriVariables = (this.uriVariables != null ?
Collections.unmodifiableMap(this.uriVariables) : Collections.emptyMap());
diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceArgumentResolver.java
similarity index 77%
rename from spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethodArgumentResolver.java
rename to spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceArgumentResolver.java
index f46b40e311..c041e78d7e 100644
--- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethodArgumentResolver.java
+++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceArgumentResolver.java
@@ -18,24 +18,24 @@ package org.springframework.web.service.invoker;
import org.springframework.core.MethodParameter;
import org.springframework.lang.Nullable;
-import org.springframework.web.service.annotation.HttpRequest;
+import org.springframework.web.service.annotation.HttpExchange;
/**
- * Resolve an argument from an {@link HttpRequest @HttpRequest} annotated method
+ * Resolve an argument from an {@link HttpExchange @HttpExchange}-annotated method
* to one or more HTTP request values.
*
* @author Rossen Stoyanchev
* @since 6.0
*/
-public interface HttpServiceMethodArgumentResolver {
+public interface HttpServiceArgumentResolver {
/**
* Resolve the argument value.
* @param argument the argument value
* @param parameter the method parameter for the argument
- * @param requestDefinition container to add HTTP request values to
+ * @param requestSpec container to add HTTP request values to
*/
- void resolve(@Nullable Object argument, MethodParameter parameter, HttpRequestDefinition requestDefinition);
+ void resolve(@Nullable Object argument, MethodParameter parameter, HttpRequestSpec requestSpec);
}
diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java
index 96133b697a..1a1793bc05 100644
--- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java
+++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java
@@ -43,12 +43,12 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
-import org.springframework.web.service.annotation.HttpRequest;
+import org.springframework.web.service.annotation.HttpExchange;
/**
- * Implements the invocation of an {@link HttpRequest @HttpRequest} annotated,
- * {@link HttpServiceProxyFactory#createService(Class) HTTP Service proxy} method
+ * Implements the invocation of an {@link HttpExchange @HttpExchange}-annotated,
+ * {@link HttpServiceProxyFactory#createClient(Class) HTTP Service proxy} method
* by delegating to an {@link HttpClientAdapter} to perform actual requests.
*
* @author Rossen Stoyanchev
@@ -60,22 +60,22 @@ final class HttpServiceMethod {
private final MethodParameter[] parameters;
- private final List argumentResolvers;
+ private final List argumentResolvers;
- private final HttpRequestDefinitionFactory requestDefinitionFactory;
+ private final HttpRequestSpecFactory requestSpecFactory;
private final ResponseFunction responseFunction;
HttpServiceMethod(
- Method method, Class> containingClass, List argumentResolvers,
+ Method method, Class> containingClass, List argumentResolvers,
HttpClientAdapter client, ReactiveAdapterRegistry reactiveRegistry,
Duration blockTimeout) {
this.method = method;
this.parameters = initMethodParameters(method);
this.argumentResolvers = argumentResolvers;
- this.requestDefinitionFactory = HttpRequestDefinitionFactory.create(method, containingClass);
+ this.requestSpecFactory = HttpRequestSpecFactory.create(method, containingClass);
this.responseFunction = ResponseFunction.create(client, method, reactiveRegistry, blockTimeout);
}
@@ -96,34 +96,34 @@ final class HttpServiceMethod {
@Nullable
public Object invoke(Object[] arguments) {
- HttpRequestDefinition requestDefinition = this.requestDefinitionFactory.initializeRequest();
- applyArguments(requestDefinition, arguments);
- requestDefinition.setComplete();
- return this.responseFunction.execute(requestDefinition);
+ HttpRequestSpec requestSpec = this.requestSpecFactory.initializeRequestSpec();
+ applyArguments(requestSpec, arguments);
+ requestSpec.setComplete();
+ return this.responseFunction.execute(requestSpec);
}
- private void applyArguments(HttpRequestDefinition requestDefinition, Object[] arguments) {
+ private void applyArguments(HttpRequestSpec requestSpec, Object[] arguments) {
Assert.isTrue(arguments.length == this.parameters.length, "Method argument mismatch");
for (int i = 0; i < this.parameters.length; i++) {
Object argumentValue = arguments[i];
ParameterNameDiscoverer nameDiscoverer = new DefaultParameterNameDiscoverer();
this.parameters[i].initParameterNameDiscovery(nameDiscoverer);
- for (HttpServiceMethodArgumentResolver resolver : this.argumentResolvers) {
- resolver.resolve(argumentValue, this.parameters[i], requestDefinition);
+ for (HttpServiceArgumentResolver resolver : this.argumentResolvers) {
+ resolver.resolve(argumentValue, this.parameters[i], requestSpec);
}
}
}
/**
- * Factory for an {@link HttpRequestDefinition} with values extracted from
- * the type and method-level {@link HttpRequest @HttpRequest} annotations.
+ * Factory for an {@link HttpRequestSpec} with values extracted from
+ * the type and method-level {@link HttpExchange @HttpRequest} annotations.
*/
- private record HttpRequestDefinitionFactory(
+ private record HttpRequestSpecFactory(
@Nullable HttpMethod httpMethod, @Nullable String url,
@Nullable MediaType contentType, @Nullable List acceptMediaTypes) {
- private HttpRequestDefinitionFactory(
+ private HttpRequestSpecFactory(
@Nullable HttpMethod httpMethod, @Nullable String url,
@Nullable MediaType contentType, @Nullable List acceptMediaTypes) {
@@ -133,31 +133,31 @@ final class HttpServiceMethod {
this.acceptMediaTypes = acceptMediaTypes;
}
- public HttpRequestDefinition initializeRequest() {
- HttpRequestDefinition requestDefinition = new HttpRequestDefinition();
+ public HttpRequestSpec initializeRequestSpec() {
+ HttpRequestSpec requestSpec = new HttpRequestSpec();
if (this.httpMethod != null) {
- requestDefinition.setHttpMethod(this.httpMethod);
+ requestSpec.setHttpMethod(this.httpMethod);
}
if (this.url != null) {
- requestDefinition.setUriTemplate(this.url);
+ requestSpec.setUriTemplate(this.url);
}
if (this.contentType != null) {
- requestDefinition.getHeaders().setContentType(this.contentType);
+ requestSpec.getHeaders().setContentType(this.contentType);
}
if (this.acceptMediaTypes != null) {
- requestDefinition.getHeaders().setAccept(this.acceptMediaTypes);
+ requestSpec.getHeaders().setAccept(this.acceptMediaTypes);
}
- return requestDefinition;
+ return requestSpec;
}
/**
* Introspect the method and create the request factory for it.
*/
- public static HttpRequestDefinitionFactory create(Method method, Class> containingClass) {
+ public static HttpRequestSpecFactory create(Method method, Class> containingClass) {
- HttpRequest annot1 = AnnotatedElementUtils.findMergedAnnotation(containingClass, HttpRequest.class);
- HttpRequest annot2 = AnnotatedElementUtils.findMergedAnnotation(method, HttpRequest.class);
+ HttpExchange annot1 = AnnotatedElementUtils.findMergedAnnotation(containingClass, HttpExchange.class);
+ HttpExchange annot2 = AnnotatedElementUtils.findMergedAnnotation(method, HttpExchange.class);
Assert.notNull(annot2, "Expected HttpRequest annotation");
@@ -166,12 +166,12 @@ final class HttpServiceMethod {
MediaType contentType = initContentType(annot1, annot2);
List acceptableMediaTypes = initAccept(annot1, annot2);
- return new HttpRequestDefinitionFactory(httpMethod, url, contentType, acceptableMediaTypes);
+ return new HttpRequestSpecFactory(httpMethod, url, contentType, acceptableMediaTypes);
}
@Nullable
- private static HttpMethod initHttpMethod(@Nullable HttpRequest typeAnnot, HttpRequest annot) {
+ private static HttpMethod initHttpMethod(@Nullable HttpExchange typeAnnot, HttpExchange annot) {
String value1 = (typeAnnot != null ? typeAnnot.method() : null);
String value2 = annot.method();
@@ -188,7 +188,7 @@ final class HttpServiceMethod {
}
@Nullable
- private static String initUrl(@Nullable HttpRequest typeAnnot, HttpRequest annot) {
+ private static String initUrl(@Nullable HttpExchange typeAnnot, HttpExchange annot) {
String url1 = (typeAnnot != null ? typeAnnot.url() : null);
String url2 = annot.url();
@@ -208,7 +208,7 @@ final class HttpServiceMethod {
}
@Nullable
- private static MediaType initContentType(@Nullable HttpRequest typeAnnot, HttpRequest annot) {
+ private static MediaType initContentType(@Nullable HttpExchange typeAnnot, HttpExchange annot) {
String value1 = (typeAnnot != null ? typeAnnot.contentType() : null);
String value2 = annot.contentType();
@@ -225,7 +225,7 @@ final class HttpServiceMethod {
}
@Nullable
- private static List initAccept(@Nullable HttpRequest typeAnnot, HttpRequest annot) {
+ private static List initAccept(@Nullable HttpExchange typeAnnot, HttpExchange annot) {
String[] value1 = (typeAnnot != null ? typeAnnot.accept() : null);
String[] value2 = annot.accept();
@@ -249,12 +249,12 @@ final class HttpServiceMethod {
* return type blocking if necessary.
*/
private record ResponseFunction(
- Function> responseFunction,
+ Function> responseFunction,
@Nullable ReactiveAdapter returnTypeAdapter,
boolean blockForOptional, Duration blockTimeout) {
private ResponseFunction(
- Function> responseFunction,
+ Function> responseFunction,
@Nullable ReactiveAdapter returnTypeAdapter,
boolean blockForOptional, Duration blockTimeout) {
@@ -265,9 +265,9 @@ final class HttpServiceMethod {
}
@Nullable
- public Object execute(HttpRequestDefinition requestDefinition) {
+ public Object execute(HttpRequestSpec requestSpec) {
- Publisher> responsePublisher = this.responseFunction.apply(requestDefinition);
+ Publisher> responsePublisher = this.responseFunction.apply(requestSpec);
if (this.returnTypeAdapter != null) {
return this.returnTypeAdapter.fromPublisher(responsePublisher);
@@ -293,7 +293,7 @@ final class HttpServiceMethod {
MethodParameter actualParam = (reactiveAdapter != null ? returnParam.nested() : returnParam.nestedIfOptional());
Class> actualType = actualParam.getNestedParameterType();
- Function> responseFunction;
+ Function> responseFunction;
if (actualType.equals(void.class) || actualType.equals(Void.class)) {
responseFunction = client::requestToVoid;
}
@@ -323,7 +323,7 @@ final class HttpServiceMethod {
}
@SuppressWarnings("ConstantConditions")
- private static Function> initResponseEntityFunction(
+ private static Function> initResponseEntityFunction(
HttpClientAdapter client, MethodParameter methodParam, @Nullable ReactiveAdapter reactiveAdapter) {
if (reactiveAdapter == null) {
@@ -349,7 +349,7 @@ final class HttpServiceMethod {
});
}
- private static Function> initBodyFunction(
+ private static Function> initBodyFunction(
HttpClientAdapter client, MethodParameter methodParam, @Nullable ReactiveAdapter reactiveAdapter) {
ParameterizedTypeReference> bodyType =
diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java
index 2817db212f..1ffc105149 100644
--- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java
+++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java
@@ -29,18 +29,18 @@ import org.springframework.aop.framework.ProxyFactory;
import org.springframework.core.MethodIntrospector;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.core.annotation.AnnotatedElementUtils;
-import org.springframework.web.service.annotation.HttpRequest;
+import org.springframework.web.service.annotation.HttpExchange;
/**
- * Factory to create a proxy for an HTTP service with {@link HttpRequest} methods.
+ * Factory to create a proxy for an HTTP service with {@link HttpExchange} methods.
*
* @author Rossen Stoyanchev
* @since 6.0
*/
public class HttpServiceProxyFactory {
- private final List argumentResolvers;
+ private final List argumentResolvers;
private final HttpClientAdapter clientAdapter;
@@ -50,7 +50,7 @@ public class HttpServiceProxyFactory {
public HttpServiceProxyFactory(
- List argumentResolvers, HttpClientAdapter clientAdapter,
+ List argumentResolvers, HttpClientAdapter clientAdapter,
ReactiveAdapterRegistry reactiveAdapterRegistry, Duration blockTimeout) {
this.argumentResolvers = argumentResolvers;
@@ -66,7 +66,7 @@ public class HttpServiceProxyFactory {
* @param the service type
* @return the created proxy
*/
- public S createService(Class serviceType) {
+ public S createClient(Class serviceType) {
List methods =
MethodIntrospector.selectMethods(serviceType, this::isHttpRequestMethod)
@@ -78,7 +78,7 @@ public class HttpServiceProxyFactory {
}
private boolean isHttpRequestMethod(Method method) {
- return AnnotatedElementUtils.hasAnnotation(method, HttpRequest.class);
+ return AnnotatedElementUtils.hasAnnotation(method, HttpExchange.class);
}
private HttpServiceMethod initServiceMethod(Method method, Class> serviceType) {
@@ -93,16 +93,16 @@ public class HttpServiceProxyFactory {
*/
private static final class HttpServiceMethodInterceptor implements MethodInterceptor {
- private final Map serviceMethodMap = new HashMap<>();
+ private final Map httpServiceMethods = new HashMap<>();
private HttpServiceMethodInterceptor(List methods) {
- methods.forEach(serviceMethod -> this.serviceMethodMap.put(serviceMethod.getMethod(), serviceMethod));
+ methods.forEach(serviceMethod -> this.httpServiceMethods.put(serviceMethod.getMethod(), serviceMethod));
}
@Override
- public Object invoke(MethodInvocation invocation) throws Throwable {
+ public Object invoke(MethodInvocation invocation) {
Method method = invocation.getMethod();
- HttpServiceMethod httpServiceMethod = this.serviceMethodMap.get(method);
+ HttpServiceMethod httpServiceMethod = this.httpServiceMethods.get(method);
return httpServiceMethod.invoke(invocation.getArguments());
}
diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/PathVariableArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/service/invoker/PathVariableArgumentResolver.java
index 34332d31ae..4ab0e17ce3 100644
--- a/spring-web/src/main/java/org/springframework/web/service/invoker/PathVariableArgumentResolver.java
+++ b/spring-web/src/main/java/org/springframework/web/service/invoker/PathVariableArgumentResolver.java
@@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.PathVariable;
/**
- * An implementation of {@link HttpServiceMethodArgumentResolver} that resolves
+ * An implementation of {@link HttpServiceArgumentResolver} that resolves
* request path variables based on method arguments annotated
* with {@link PathVariable}. {@code null} values are allowed only
* if {@link PathVariable#required()} is {@code true}.
@@ -39,7 +39,7 @@ import org.springframework.web.bind.annotation.PathVariable;
* @author Olga Maciaszek-Sharma
* @since 6.0
*/
-public class PathVariableArgumentResolver implements HttpServiceMethodArgumentResolver {
+public class PathVariableArgumentResolver implements HttpServiceArgumentResolver {
private static final Log logger = LogFactory.getLog(PathVariableArgumentResolver.class);
@@ -56,7 +56,7 @@ public class PathVariableArgumentResolver implements HttpServiceMethodArgumentRe
@SuppressWarnings("unchecked")
@Override
public void resolve(
- @Nullable Object argument, MethodParameter parameter, HttpRequestDefinition requestDefinition) {
+ @Nullable Object argument, MethodParameter parameter, HttpRequestSpec requestSpec) {
PathVariable annotation = parameter.getParameterAnnotation(PathVariable.class);
if (annotation == null) {
@@ -67,19 +67,19 @@ public class PathVariableArgumentResolver implements HttpServiceMethodArgumentRe
if (argument != null) {
Assert.isInstanceOf(Map.class, argument);
((Map) argument).forEach((key, value) ->
- addUriParameter(key, value, annotation.required(), requestDefinition));
+ addUriParameter(key, value, annotation.required(), requestSpec));
}
}
else {
String name = StringUtils.hasText(annotation.value()) ? annotation.value() : annotation.name();
name = StringUtils.hasText(name) ? name : parameter.getParameterName();
Assert.notNull(name, "Failed to determine path variable name for parameter: " + parameter);
- addUriParameter(name, argument, annotation.required(), requestDefinition);
+ addUriParameter(name, argument, annotation.required(), requestSpec);
}
}
private void addUriParameter(
- String name, @Nullable Object value, boolean required, HttpRequestDefinition requestDefinition) {
+ String name, @Nullable Object value, boolean required, HttpRequestSpec requestSpec) {
if (value instanceof Optional) {
value = ((Optional>) value).orElse(null);
@@ -98,7 +98,7 @@ public class PathVariableArgumentResolver implements HttpServiceMethodArgumentRe
logger.trace("Resolved path variable '" + name + "' to " + value);
}
- requestDefinition.getUriVariables().put(name, (String) value);
+ requestSpec.getUriVariables().put(name, (String) value);
}
}
diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/package-info.java b/spring-web/src/main/java/org/springframework/web/service/invoker/package-info.java
index 9c5adc46e8..13bdc08b71 100644
--- a/spring-web/src/main/java/org/springframework/web/service/invoker/package-info.java
+++ b/spring-web/src/main/java/org/springframework/web/service/invoker/package-info.java
@@ -1,6 +1,6 @@
/**
* Support to create a client proxy for an HTTP service annotated with
- * {@link org.springframework.web.service.annotation.HttpRequest} methods.
+ * {@link org.springframework.web.service.annotation.HttpExchange} methods.
*/
@NonNullApi
@NonNullFields
diff --git a/spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java
index b2f5a4f79b..f7042f1a8a 100644
--- a/spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java
+++ b/spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java
@@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.http.HttpMethod;
import org.springframework.lang.Nullable;
-import org.springframework.web.service.annotation.GetRequest;
-import org.springframework.web.service.annotation.HttpRequest;
+import org.springframework.web.service.annotation.GetExchange;
+import org.springframework.web.service.annotation.HttpExchange;
import static org.assertj.core.api.Assertions.assertThat;
@@ -64,25 +64,25 @@ public class HttpMethodArgumentResolverTests {
@Nullable
private HttpMethod getActualMethod() {
- return this.clientAdapter.getRequestDefinition().getHttpMethod();
+ return this.clientAdapter.getRequestSpec().getHttpMethod();
}
private interface Service {
- @HttpRequest
+ @HttpExchange
void execute(HttpMethod method);
- @GetRequest
+ @GetExchange
void executeGet(HttpMethod method);
- @HttpRequest
+ @HttpExchange
void execute(String test);
- @HttpRequest
+ @HttpExchange
void execute(HttpMethod firstMethod, HttpMethod secondMethod);
- @HttpRequest
+ @HttpExchange
void executeForNull(@Nullable HttpMethod method);
}
diff --git a/spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java b/spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java
index 791b450f26..5bdcf6109d 100644
--- a/spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java
+++ b/spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java
@@ -32,9 +32,9 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.lang.Nullable;
-import org.springframework.web.service.annotation.GetRequest;
-import org.springframework.web.service.annotation.HttpRequest;
-import org.springframework.web.service.annotation.PostRequest;
+import org.springframework.web.service.annotation.GetExchange;
+import org.springframework.web.service.annotation.HttpExchange;
+import org.springframework.web.service.annotation.PostExchange;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.http.MediaType.APPLICATION_CBOR_VALUE;
@@ -145,7 +145,7 @@ public class HttpServiceMethodTests {
service.performGet();
- HttpRequestDefinition request = this.clientAdapter.getRequestDefinition();
+ HttpRequestSpec request = this.clientAdapter.getRequestSpec();
assertThat(request.getHttpMethod()).isEqualTo(HttpMethod.GET);
assertThat(request.getUriTemplate()).isNull();
assertThat(request.getHeaders().getContentType()).isNull();
@@ -153,7 +153,7 @@ public class HttpServiceMethodTests {
service.performPost();
- request = this.clientAdapter.getRequestDefinition();
+ request = this.clientAdapter.getRequestSpec();
assertThat(request.getHttpMethod()).isEqualTo(HttpMethod.POST);
assertThat(request.getUriTemplate()).isEqualTo("/url");
assertThat(request.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_JSON);
@@ -167,7 +167,7 @@ public class HttpServiceMethodTests {
service.performGet();
- HttpRequestDefinition request = this.clientAdapter.getRequestDefinition();
+ HttpRequestSpec request = this.clientAdapter.getRequestSpec();
assertThat(request.getHttpMethod()).isEqualTo(HttpMethod.GET);
assertThat(request.getUriTemplate()).isEqualTo("/base");
assertThat(request.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_CBOR);
@@ -175,7 +175,7 @@ public class HttpServiceMethodTests {
service.performPost();
- request = this.clientAdapter.getRequestDefinition();
+ request = this.clientAdapter.getRequestSpec();
assertThat(request.getHttpMethod()).isEqualTo(HttpMethod.POST);
assertThat(request.getUriTemplate()).isEqualTo("/base/url");
assertThat(request.getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_JSON);
@@ -191,25 +191,25 @@ public class HttpServiceMethodTests {
@SuppressWarnings("unused")
private interface ReactorService {
- @HttpRequest
+ @HttpExchange
Mono execute();
- @GetRequest
+ @GetExchange
Mono getHeaders();
- @GetRequest
+ @GetExchange
Mono getBody();
- @GetRequest
+ @GetExchange
Flux getFluxBody();
- @GetRequest
+ @GetExchange
Mono> getVoidEntity();
- @GetRequest
+ @GetExchange
Mono> getEntity();
- @GetRequest
+ @GetExchange
Mono>> getFluxEntity();
}
@@ -217,25 +217,25 @@ public class HttpServiceMethodTests {
@SuppressWarnings("unused")
private interface RxJavaService {
- @HttpRequest
+ @HttpExchange
Completable execute();
- @GetRequest
+ @GetExchange
Single getHeaders();
- @GetRequest
+ @GetExchange
Single getBody();
- @GetRequest
+ @GetExchange
Flowable getFlowableBody();
- @GetRequest
+ @GetExchange
Single> getVoidEntity();
- @GetRequest
+ @GetExchange
Single> getEntity();
- @GetRequest
+ @GetExchange
Single>> getFlowableEntity();
}
@@ -243,19 +243,19 @@ public class HttpServiceMethodTests {
@SuppressWarnings("unused")
private interface BlockingService {
- @HttpRequest
+ @HttpExchange
void execute();
- @GetRequest
+ @GetExchange
HttpHeaders getHeaders();
- @GetRequest
+ @GetExchange
String getBody();
- @GetRequest
+ @GetExchange
ResponseEntity getVoidEntity();
- @GetRequest
+ @GetExchange
ResponseEntity getEntity();
}
@@ -263,17 +263,17 @@ public class HttpServiceMethodTests {
@SuppressWarnings("unused")
private interface MethodAnnotatedService {
- @GetRequest
+ @GetExchange
void performGet();
- @PostRequest(url = "/url", contentType = APPLICATION_JSON_VALUE, accept = APPLICATION_JSON_VALUE)
+ @PostExchange(url = "/url", contentType = APPLICATION_JSON_VALUE, accept = APPLICATION_JSON_VALUE)
void performPost();
}
@SuppressWarnings("unused")
- @HttpRequest(url = "/base", contentType = APPLICATION_CBOR_VALUE, accept = APPLICATION_CBOR_VALUE)
+ @HttpExchange(url = "/base", contentType = APPLICATION_CBOR_VALUE, accept = APPLICATION_CBOR_VALUE)
private interface TypeAndMethodAnnotatedService extends MethodAnnotatedService {
}
diff --git a/spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java
index 0d7e041e2e..f920345cf0 100644
--- a/spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java
+++ b/spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.service.annotation.HttpRequest;
+import org.springframework.web.service.annotation.HttpExchange;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@@ -143,44 +143,44 @@ class PathVariableArgumentResolverTests {
}
private Map getActualUriVariables() {
- return this.clientAdapter.getRequestDefinition().getUriVariables();
+ return this.clientAdapter.getRequestSpec().getUriVariables();
}
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
private interface Service {
- @HttpRequest
+ @HttpExchange
void execute(@PathVariable String id);
- @HttpRequest
+ @HttpExchange
void executeNotRequired(@Nullable @PathVariable(required = false) String id);
- @HttpRequest
+ @HttpExchange
void executeOptional(@PathVariable Optional id);
- @HttpRequest
+ @HttpExchange
void executeOptionalNotRequired(@PathVariable(required = false) Optional id);
- @HttpRequest
+ @HttpExchange
void executeNamedWithValue(@Nullable @PathVariable(name = "test", value = "id") String employeeId);
- @HttpRequest
+ @HttpExchange
void executeNamed(@PathVariable(name = "id") String employeeId);
- @HttpRequest
+ @HttpExchange
void executeValueNamed(@PathVariable("id") String employeeId);
- @HttpRequest
+ @HttpExchange
void execute(@PathVariable Object id);
- @HttpRequest
+ @HttpExchange
void execute(@PathVariable Boolean id);
- @HttpRequest
+ @HttpExchange
void executeValueMap(@Nullable @PathVariable Map map);
- @HttpRequest
+ @HttpExchange
void executeOptionalValueMap(@PathVariable Map> map);
}
diff --git a/spring-web/src/test/java/org/springframework/web/service/invoker/TestHttpClientAdapter.java b/spring-web/src/test/java/org/springframework/web/service/invoker/TestHttpClientAdapter.java
index 06abeb90c3..591503d734 100644
--- a/spring-web/src/test/java/org/springframework/web/service/invoker/TestHttpClientAdapter.java
+++ b/spring-web/src/test/java/org/springframework/web/service/invoker/TestHttpClientAdapter.java
@@ -44,7 +44,7 @@ class TestHttpClientAdapter implements HttpClientAdapter {
private String invokedMethodName;
@Nullable
- private HttpRequestDefinition requestDefinition;
+ private HttpRequestSpec requestSpec;
@Nullable
private ParameterizedTypeReference> bodyType;
@@ -53,12 +53,12 @@ class TestHttpClientAdapter implements HttpClientAdapter {
/**
* Create the proxy for the give service type.
*/
- public S createService(Class serviceType, HttpServiceMethodArgumentResolver... resolvers) {
+ public S createService(Class serviceType, HttpServiceArgumentResolver... resolvers) {
HttpServiceProxyFactory factory = new HttpServiceProxyFactory(
Arrays.asList(resolvers), this, ReactiveAdapterRegistry.getSharedInstance(), Duration.ofSeconds(5));
- return factory.createService(serviceType);
+ return factory.createClient(serviceType);
}
@@ -67,9 +67,9 @@ class TestHttpClientAdapter implements HttpClientAdapter {
return this.invokedMethodName;
}
- public HttpRequestDefinition getRequestDefinition() {
- assertThat(this.requestDefinition).isNotNull();
- return this.requestDefinition;
+ public HttpRequestSpec getRequestSpec() {
+ assertThat(this.requestSpec).isNotNull();
+ return this.requestSpec;
}
@Nullable
@@ -81,56 +81,56 @@ class TestHttpClientAdapter implements HttpClientAdapter {
// HttpClientAdapter implementation
@Override
- public Mono requestToVoid(HttpRequestDefinition definition) {
- saveInput("requestToVoid", definition, null);
+ public Mono requestToVoid(HttpRequestSpec requestSpec) {
+ saveInput("requestToVoid", requestSpec, null);
return Mono.empty();
}
@Override
- public Mono requestToHeaders(HttpRequestDefinition definition) {
- saveInput("requestToHeaders", definition, null);
+ public Mono requestToHeaders(HttpRequestSpec requestSpec) {
+ saveInput("requestToHeaders", requestSpec, null);
return Mono.just(new HttpHeaders());
}
@Override
- public Mono requestToBody(HttpRequestDefinition definition, ParameterizedTypeReference bodyType) {
- saveInput("requestToBody", definition, bodyType);
+ public Mono requestToBody(HttpRequestSpec requestSpec, ParameterizedTypeReference bodyType) {
+ saveInput("requestToBody", requestSpec, bodyType);
return (Mono) Mono.just(getInvokedMethodName());
}
@Override
- public Flux requestToBodyFlux(HttpRequestDefinition definition, ParameterizedTypeReference bodyType) {
- saveInput("requestToBodyFlux", definition, bodyType);
+ public Flux requestToBodyFlux(HttpRequestSpec requestSpec, ParameterizedTypeReference bodyType) {
+ saveInput("requestToBodyFlux", requestSpec, bodyType);
return (Flux) Flux.just("request", "To", "Body", "Flux");
}
@Override
- public Mono> requestToBodilessEntity(HttpRequestDefinition definition) {
- saveInput("requestToBodilessEntity", definition, null);
+ public Mono> requestToBodilessEntity(HttpRequestSpec requestSpec) {
+ saveInput("requestToBodilessEntity", requestSpec, null);
return Mono.just(ResponseEntity.ok().build());
}
@Override
public Mono> requestToEntity(
- HttpRequestDefinition definition, ParameterizedTypeReference type) {
+ HttpRequestSpec requestSpec, ParameterizedTypeReference type) {
- saveInput("requestToEntity", definition, type);
+ saveInput("requestToEntity", requestSpec, type);
return Mono.just((ResponseEntity) ResponseEntity.ok("requestToEntity"));
}
@Override
public Mono>> requestToEntityFlux(
- HttpRequestDefinition definition, ParameterizedTypeReference bodyType) {
+ HttpRequestSpec requestSpec, ParameterizedTypeReference bodyType) {
- saveInput("requestToEntityFlux", definition, bodyType);
+ saveInput("requestToEntityFlux", requestSpec, bodyType);
return Mono.just(ResponseEntity.ok((Flux) Flux.just("request", "To", "Entity", "Flux")));
}
private void saveInput(
- String methodName, HttpRequestDefinition definition, @Nullable ParameterizedTypeReference bodyType) {
+ String methodName, HttpRequestSpec requestSpec, @Nullable ParameterizedTypeReference bodyType) {
this.invokedMethodName = methodName;
- this.requestDefinition = definition;
+ this.requestSpec = requestSpec;
this.bodyType = bodyType;
}
diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/WebClientAdapter.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/WebClientAdapter.java
index c76f4132df..59c5b29041 100644
--- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/WebClientAdapter.java
+++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/WebClientAdapter.java
@@ -27,7 +27,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.service.invoker.HttpClientAdapter;
-import org.springframework.web.service.invoker.HttpRequestDefinition;
+import org.springframework.web.service.invoker.HttpRequestSpec;
/**
@@ -47,67 +47,67 @@ public class WebClientAdapter implements HttpClientAdapter {
@Override
- public Mono requestToVoid(HttpRequestDefinition request) {
- return toBodySpec(request).exchangeToMono(ClientResponse::releaseBody);
+ public Mono requestToVoid(HttpRequestSpec requestSpec) {
+ return toBodySpec(requestSpec).exchangeToMono(ClientResponse::releaseBody);
}
@Override
- public Mono requestToHeaders(HttpRequestDefinition request) {
- return toBodySpec(request).retrieve().toBodilessEntity().map(ResponseEntity::getHeaders);
+ public Mono requestToHeaders(HttpRequestSpec requestSpec) {
+ return toBodySpec(requestSpec).retrieve().toBodilessEntity().map(ResponseEntity::getHeaders);
}
@Override
- public Mono requestToBody(HttpRequestDefinition request, ParameterizedTypeReference bodyType) {
- return toBodySpec(request).retrieve().bodyToMono(bodyType);
+ public Mono requestToBody(HttpRequestSpec reqrequestSpecest, ParameterizedTypeReference bodyType) {
+ return toBodySpec(reqrequestSpecest).retrieve().bodyToMono(bodyType);
}
@Override
- public Flux requestToBodyFlux(HttpRequestDefinition request, ParameterizedTypeReference bodyType) {
- return toBodySpec(request).retrieve().bodyToFlux(bodyType);
+ public Flux requestToBodyFlux(HttpRequestSpec requestSpec, ParameterizedTypeReference bodyType) {
+ return toBodySpec(requestSpec).retrieve().bodyToFlux(bodyType);
}
@Override
- public Mono> requestToBodilessEntity(HttpRequestDefinition request) {
- return toBodySpec(request).retrieve().toBodilessEntity();
+ public Mono> requestToBodilessEntity(HttpRequestSpec requestSpec) {
+ return toBodySpec(requestSpec).retrieve().toBodilessEntity();
}
@Override
- public Mono> requestToEntity(HttpRequestDefinition request, ParameterizedTypeReference bodyType) {
- return toBodySpec(request).retrieve().toEntity(bodyType);
+ public Mono> requestToEntity(HttpRequestSpec spec, ParameterizedTypeReference bodyType) {
+ return toBodySpec(spec).retrieve().toEntity(bodyType);
}
@Override
- public Mono>> requestToEntityFlux(HttpRequestDefinition request, ParameterizedTypeReference bodyType) {
- return toBodySpec(request).retrieve().toEntityFlux(bodyType);
+ public Mono>> requestToEntityFlux(HttpRequestSpec spec, ParameterizedTypeReference bodyType) {
+ return toBodySpec(spec).retrieve().toEntityFlux(bodyType);
}
@SuppressWarnings("ReactiveStreamsUnusedPublisher")
- private WebClient.RequestBodySpec toBodySpec(HttpRequestDefinition request) {
+ private WebClient.RequestBodySpec toBodySpec(HttpRequestSpec requestSpec) {
- HttpMethod httpMethod = request.getHttpMethodRequired();
+ HttpMethod httpMethod = requestSpec.getHttpMethodRequired();
WebClient.RequestBodyUriSpec uriSpec = this.webClient.method(httpMethod);
WebClient.RequestBodySpec bodySpec;
- if (request.getUri() != null) {
- bodySpec = uriSpec.uri(request.getUri());
+ if (requestSpec.getUri() != null) {
+ bodySpec = uriSpec.uri(requestSpec.getUri());
}
- else if (request.getUriTemplate() != null) {
- bodySpec = (!request.getUriVariables().isEmpty() ?
- uriSpec.uri(request.getUriTemplate(), request.getUriVariables()) :
- uriSpec.uri(request.getUriTemplate(), request.getUriVariableValues()));
+ else if (requestSpec.getUriTemplate() != null) {
+ bodySpec = (!requestSpec.getUriVariables().isEmpty() ?
+ uriSpec.uri(requestSpec.getUriTemplate(), requestSpec.getUriVariables()) :
+ uriSpec.uri(requestSpec.getUriTemplate(), requestSpec.getUriVariableValues()));
}
else {
bodySpec = uriSpec.uri("");
}
- bodySpec.headers(headers -> headers.putAll(request.getHeaders()));
- bodySpec.cookies(cookies -> cookies.putAll(request.getCookies()));
+ bodySpec.headers(headers -> headers.putAll(requestSpec.getHeaders()));
+ bodySpec.cookies(cookies -> cookies.putAll(requestSpec.getCookies()));
- if (request.getBodyValue() != null) {
- bodySpec.bodyValue(request.getBodyValue());
+ if (requestSpec.getBodyValue() != null) {
+ bodySpec.bodyValue(requestSpec.getBodyValue());
}
- else if (request.getBodyPublisher() != null) {
- bodySpec.body(request.getBodyPublisher(), request.getBodyPublisherElementType());
+ else if (requestSpec.getBodyPublisher() != null) {
+ bodySpec.body(requestSpec.getBodyPublisher(), requestSpec.getBodyPublisherElementType());
}
return bodySpec;
diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/WebClientHttpServiceProxyTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/WebClientHttpServiceProxyTests.java
index 709ac7383e..44a33ca138 100644
--- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/WebClientHttpServiceProxyTests.java
+++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/WebClientHttpServiceProxyTests.java
@@ -33,7 +33,7 @@ import reactor.test.StepVerifier;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.web.reactive.function.client.WebClient;
-import org.springframework.web.service.annotation.GetRequest;
+import org.springframework.web.service.annotation.GetExchange;
import org.springframework.web.service.invoker.HttpServiceProxyFactory;
@@ -65,7 +65,7 @@ public class WebClientHttpServiceProxyTests {
Collections.emptyList(), webClientAdapter, ReactiveAdapterRegistry.getSharedInstance(),
Duration.ofSeconds(5));
- this.httpService = proxyFactory.createService(TestHttpService.class);
+ this.httpService = proxyFactory.createClient(TestHttpService.class);
}
@SuppressWarnings("ConstantConditions")
@@ -98,7 +98,7 @@ public class WebClientHttpServiceProxyTests {
private interface TestHttpService {
- @GetRequest("/greeting")
+ @GetExchange("/greeting")
Mono getGreeting();
}