Skip to content

Commit 564f8ba

Browse files
committed
Update after review
See gh-28386
1 parent bb44c0e commit 564f8ba

File tree

18 files changed

+224
-218
lines changed

18 files changed

+224
-218
lines changed

spring-web/src/main/java/org/springframework/web/service/annotation/GetRequest.java renamed to spring-web/src/main/java/org/springframework/web/service/annotation/GetExchange.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,33 @@
2626

2727

2828
/**
29-
* Shortcut for {@link HttpRequest} for HTTP GET requests.
29+
* Shortcut for {@link HttpExchange} for HTTP GET requests.
3030
*
3131
* @author Rossen Stoyanchev
3232
* @since 6.0
3333
*/
3434
@Target(ElementType.METHOD)
3535
@Retention(RetentionPolicy.RUNTIME)
3636
@Documented
37-
@HttpRequest(method = "GET")
38-
public @interface GetRequest {
37+
@HttpExchange(method = "GET")
38+
public @interface GetExchange {
3939

4040
/**
41-
* Alias for {@link HttpRequest#value}.
41+
* Alias for {@link HttpExchange#value}.
4242
*/
43-
@AliasFor(annotation = HttpRequest.class)
43+
@AliasFor(annotation = HttpExchange.class)
4444
String value() default "";
4545

4646
/**
47-
* Alias for {@link HttpRequest#url()}.
47+
* Alias for {@link HttpExchange#url()}.
4848
*/
49-
@AliasFor(annotation = HttpRequest.class)
49+
@AliasFor(annotation = HttpExchange.class)
5050
String url() default "";
5151

5252
/**
53-
* Alias for {@link HttpRequest#accept()}.
53+
* Alias for {@link HttpExchange#accept()}.
5454
*/
55-
@AliasFor(annotation = HttpRequest.class)
55+
@AliasFor(annotation = HttpExchange.class)
5656
String[] accept() default {};
5757

5858
}

spring-web/src/main/java/org/springframework/web/service/annotation/HttpRequest.java renamed to spring-web/src/main/java/org/springframework/web/service/annotation/HttpExchange.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
@Retention(RetentionPolicy.RUNTIME)
4343
@Documented
4444
@Mapping
45-
public @interface HttpRequest {
45+
public @interface HttpExchange {
4646

4747
/**
4848
* This is an alias for {@link #url}.
@@ -52,7 +52,7 @@
5252

5353
/**
5454
* The URL for the request, either a full URL or a path only that is relative
55-
* to a URL declared in a type-level {@code @HttpRequest}, and/or a globally
55+
* to a URL declared in a type-level {@code @HttpExchange}, and/or a globally
5656
* configured base URL.
5757
* <p>By default, this is empty.
5858
*/
@@ -67,7 +67,6 @@
6767
*/
6868
String method() default "";
6969

70-
7170
/**
7271
* The media type for the {@code "Content-Type"} header.
7372
* <p>Supported at the type level as well as at the method level, in which

spring-web/src/main/java/org/springframework/web/service/annotation/PostRequest.java renamed to spring-web/src/main/java/org/springframework/web/service/annotation/PostExchange.java

+12-11
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,41 @@
2424

2525
import org.springframework.core.annotation.AliasFor;
2626

27+
2728
/**
28-
* Shortcut for {@link HttpRequest} for HTTP POST requests.
29+
* Shortcut for {@link HttpExchange} for HTTP POST requests.
2930
*
3031
* @author Rossen Stoyanchev
3132
* @since 6.0
3233
*/
3334
@Target(ElementType.METHOD)
3435
@Retention(RetentionPolicy.RUNTIME)
3536
@Documented
36-
@HttpRequest(method = "POST")
37-
public @interface PostRequest {
37+
@HttpExchange(method = "POST")
38+
public @interface PostExchange {
3839

3940
/**
40-
* Alias for {@link HttpRequest#value}.
41+
* Alias for {@link HttpExchange#value}.
4142
*/
42-
@AliasFor(annotation = HttpRequest.class)
43+
@AliasFor(annotation = HttpExchange.class)
4344
String value() default "";
4445

4546
/**
46-
* Alias for {@link HttpRequest#url()}.
47+
* Alias for {@link HttpExchange#url()}.
4748
*/
48-
@AliasFor(annotation = HttpRequest.class)
49+
@AliasFor(annotation = HttpExchange.class)
4950
String url() default "";
5051

5152
/**
52-
* Alias for {@link HttpRequest#contentType()}.
53+
* Alias for {@link HttpExchange#contentType()}.
5354
*/
54-
@AliasFor(annotation = HttpRequest.class)
55+
@AliasFor(annotation = HttpExchange.class)
5556
String contentType() default "";
5657

5758
/**
58-
* Alias for {@link HttpRequest#accept()}.
59+
* Alias for {@link HttpExchange#accept()}.
5960
*/
60-
@AliasFor(annotation = HttpRequest.class)
61+
@AliasFor(annotation = HttpExchange.class)
6162
String[] accept() default {};
6263

6364
}

spring-web/src/main/java/org/springframework/web/service/annotation/PutRequest.java renamed to spring-web/src/main/java/org/springframework/web/service/annotation/PutExchange.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,35 @@
2424

2525
import org.springframework.core.annotation.AliasFor;
2626

27+
2728
/**
28-
* Shortcut for {@link HttpRequest} for HTTP PUT requests.
29+
* Shortcut for {@link HttpExchange} for HTTP PUT requests.
2930
*
3031
* @author Rossen Stoyanchev
3132
* @since 6.0
3233
*/
3334
@Target(ElementType.METHOD)
3435
@Retention(RetentionPolicy.RUNTIME)
3536
@Documented
36-
@HttpRequest(method = "PUT")
37-
public @interface PutRequest {
37+
@HttpExchange(method = "PUT")
38+
public @interface PutExchange {
3839

3940
/**
40-
* Alias for {@link HttpRequest#value}.
41+
* Alias for {@link HttpExchange#value}.
4142
*/
42-
@AliasFor(annotation = HttpRequest.class)
43+
@AliasFor(annotation = HttpExchange.class)
4344
String[] value() default {};
4445

4546
/**
46-
* Alias for {@link HttpRequest#url()}.
47+
* Alias for {@link HttpExchange#url()}.
4748
*/
48-
@AliasFor(annotation = HttpRequest.class)
49+
@AliasFor(annotation = HttpExchange.class)
4950
String[] url() default {};
5051

5152
/**
52-
* Alias for {@link HttpRequest#contentType()}.
53+
* Alias for {@link HttpExchange#contentType()}.
5354
*/
54-
@AliasFor(annotation = HttpRequest.class)
55+
@AliasFor(annotation = HttpExchange.class)
5556
String contentType() default "";
5657

5758
}

spring-web/src/main/java/org/springframework/web/service/invoker/HttpClientAdapter.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,26 @@
2525

2626

2727
/**
28-
* Decouple an {@link HttpServiceProxyFactory#createService(Class) HTTP Service proxy}
29-
* from the underlying HTTP client.
28+
* Contract to abstract the underlying HTTP client and decouple it from the
29+
* {@link HttpServiceProxyFactory#createClient(Class) HTTP Service proxy}.
3030
*
3131
* @author Rossen Stoyanchev
3232
* @since 6.0
3333
*/
3434
public interface HttpClientAdapter {
3535

36-
Mono<Void> requestToVoid(HttpRequestDefinition requestDefinition);
36+
Mono<Void> requestToVoid(HttpRequestSpec spec);
3737

38-
Mono<HttpHeaders> requestToHeaders(HttpRequestDefinition requestDefinition);
38+
Mono<HttpHeaders> requestToHeaders(HttpRequestSpec spec);
3939

40-
<T> Mono<T> requestToBody(HttpRequestDefinition requestDefinition, ParameterizedTypeReference<T> bodyType);
40+
<T> Mono<T> requestToBody(HttpRequestSpec spec, ParameterizedTypeReference<T> bodyType);
4141

42-
<T> Flux<T> requestToBodyFlux(HttpRequestDefinition requestDefinition, ParameterizedTypeReference<T> bodyType);
42+
<T> Flux<T> requestToBodyFlux(HttpRequestSpec spec, ParameterizedTypeReference<T> bodyType);
4343

44-
Mono<ResponseEntity<Void>> requestToBodilessEntity(HttpRequestDefinition requestDefinition);
44+
Mono<ResponseEntity<Void>> requestToBodilessEntity(HttpRequestSpec spec);
4545

46-
<T> Mono<ResponseEntity<T>> requestToEntity(HttpRequestDefinition requestDefinition, ParameterizedTypeReference<T> bodyType);
46+
<T> Mono<ResponseEntity<T>> requestToEntity(HttpRequestSpec spec, ParameterizedTypeReference<T> bodyType);
4747

48-
<T> Mono<ResponseEntity<Flux<T>>> requestToEntityFlux(HttpRequestDefinition requestDefinition, ParameterizedTypeReference<T> bodyType);
48+
<T> Mono<ResponseEntity<Flux<T>>> requestToEntityFlux(HttpRequestSpec spec, ParameterizedTypeReference<T> bodyType);
4949

5050
}

spring-web/src/main/java/org/springframework/web/service/invoker/HttpMethodArgumentResolver.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@
2525

2626

2727
/**
28-
* {@link HttpServiceMethodArgumentResolver} that resolves the target
28+
* {@link HttpServiceArgumentResolver} that resolves the target
2929
* request's HTTP method from an {@link HttpMethod} argument.
3030
*
3131
* @author Olga Maciaszek-Sharma
3232
* @since 6.0
3333
*/
34-
public class HttpMethodArgumentResolver implements HttpServiceMethodArgumentResolver {
34+
public class HttpMethodArgumentResolver implements HttpServiceArgumentResolver {
3535

3636
private static final Log logger = LogFactory.getLog(HttpMethodArgumentResolver.class);
3737

3838

3939
@Override
4040
public void resolve(
41-
@Nullable Object argument, MethodParameter parameter, HttpRequestDefinition requestDefinition) {
41+
@Nullable Object argument, MethodParameter parameter, HttpRequestSpec requestSpec) {
4242

4343
if (argument == null) {
4444
return;
@@ -47,7 +47,7 @@ public void resolve(
4747
if (logger.isTraceEnabled()) {
4848
logger.trace("Resolved HTTP method to: " + httpMethod.name());
4949
}
50-
requestDefinition.setHttpMethod(httpMethod);
50+
requestSpec.setHttpMethod(httpMethod);
5151
}
5252
}
5353

spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestDefinition.java renamed to spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestSpec.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.springframework.core.ParameterizedTypeReference;
3131
import org.springframework.http.HttpHeaders;
3232
import org.springframework.http.HttpMethod;
33-
import org.springframework.http.HttpRequest;
3433
import org.springframework.lang.Nullable;
3534
import org.springframework.util.Assert;
3635
import org.springframework.util.CollectionUtils;
@@ -39,15 +38,15 @@
3938

4039

4140
/**
42-
* Container for HTTP request values accumulated from an
43-
* {@link HttpRequest @HttpRequest}-annotated method and arguments passed to it.
44-
* This allows an {@link HttpClientAdapter} adapt these inputs as it sees fit
45-
* to the API of the underlying client.
41+
* Container for HTTP request values extracted from an
42+
* {@link org.springframework.web.service.annotation.HttpExchange @HttpExchange}-annotated
43+
* method and argument values passed to it. This is then given to
44+
* {@link HttpClientAdapter} to adapt to the underlying HTTP client.
4645
*
4746
* @author Rossen Stoyanchev
4847
* @since 6.0
4948
*/
50-
public class HttpRequestDefinition {
49+
public class HttpRequestSpec {
5150

5251
private static final MultiValueMap<String, String> EMPTY_COOKIES_MAP =
5352
CollectionUtils.toMultiValueMap(Collections.emptyMap());
@@ -86,6 +85,10 @@ public class HttpRequestDefinition {
8685
private boolean complete;
8786

8887

88+
public HttpRequestSpec() {
89+
}
90+
91+
8992
public void setUri(URI uri) {
9093
checkComplete();
9194
this.uri = uri;
@@ -175,6 +178,8 @@ private void checkComplete() {
175178

176179
void setComplete() {
177180

181+
this.complete = true;
182+
178183
this.uriVariables = (this.uriVariables != null ?
179184
Collections.unmodifiableMap(this.uriVariables) : Collections.emptyMap());
180185

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@
1818

1919
import org.springframework.core.MethodParameter;
2020
import org.springframework.lang.Nullable;
21-
import org.springframework.web.service.annotation.HttpRequest;
21+
import org.springframework.web.service.annotation.HttpExchange;
2222

2323

2424
/**
25-
* Resolve an argument from an {@link HttpRequest @HttpRequest} annotated method
25+
* Resolve an argument from an {@link HttpExchange @HttpExchange}-annotated method
2626
* to one or more HTTP request values.
2727
*
2828
* @author Rossen Stoyanchev
2929
* @since 6.0
3030
*/
31-
public interface HttpServiceMethodArgumentResolver {
31+
public interface HttpServiceArgumentResolver {
3232

3333
/**
3434
* Resolve the argument value.
3535
* @param argument the argument value
3636
* @param parameter the method parameter for the argument
37-
* @param requestDefinition container to add HTTP request values to
37+
* @param requestSpec container to add HTTP request values to
3838
*/
39-
void resolve(@Nullable Object argument, MethodParameter parameter, HttpRequestDefinition requestDefinition);
39+
void resolve(@Nullable Object argument, MethodParameter parameter, HttpRequestSpec requestSpec);
4040

4141
}

0 commit comments

Comments
 (0)