Polishing
This commit is contained in:
@@ -24,7 +24,6 @@ import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
|
||||
/**
|
||||
* Shortcut for {@link HttpExchange} for HTTP DELETE requests.
|
||||
*
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
|
||||
/**
|
||||
* Shortcut for {@link HttpExchange} for HTTP GET requests.
|
||||
*
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
|
||||
/**
|
||||
* Shortcut for {@link HttpExchange} for HTTP HEAD requests.
|
||||
*
|
||||
|
||||
@@ -26,14 +26,13 @@ import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.web.bind.annotation.Mapping;
|
||||
import org.springframework.web.service.invoker.UrlArgumentResolver;
|
||||
|
||||
|
||||
/**
|
||||
* Annotation that declares an HTTP service method as an HTTP endpoint defined
|
||||
* through attributes of the annotation and method argument values.
|
||||
*
|
||||
* <p>The annotation may only be used at the type level for example to specify
|
||||
* a base URL path. At the method level, use one of the HTTP method specific,
|
||||
* shortcut annotations, each of which is <em>meta-annotated</em> with
|
||||
* <p>The annotation may only be used at the type level — for example to
|
||||
* specify a base URL path. At the method level, use one of the HTTP method
|
||||
* specific, shortcut annotations, each of which is <em>meta-annotated</em> with
|
||||
* {@link HttpExchange}:
|
||||
* <ul>
|
||||
* <li>{@link GetExchange}
|
||||
@@ -46,7 +45,7 @@ import org.springframework.web.service.invoker.UrlArgumentResolver;
|
||||
* </ul>
|
||||
*
|
||||
* <p>Supported method arguments:
|
||||
* <table>
|
||||
* <table border="1">
|
||||
* <tr>
|
||||
* <th>Method Argument</th>
|
||||
* <th>Description</th>
|
||||
@@ -54,14 +53,14 @@ import org.springframework.web.service.invoker.UrlArgumentResolver;
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link java.net.URI URI}</td>
|
||||
* <td>Dynamically set the URL for the request, overriding the annotation
|
||||
* <td>Dynamically set the URL for the request, overriding the annotation's
|
||||
* {@link #url()} attribute</td>
|
||||
* <td>{@link UrlArgumentResolver
|
||||
* HttpUrlArgumentResolver}</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link org.springframework.http.HttpMethod HttpMethod}</td>
|
||||
* <td>Dynamically set the HTTP method for the request, overriding the annotation
|
||||
* <td>Dynamically set the HTTP method for the request, overriding the annotation's
|
||||
* {@link #method()} attribute</td>
|
||||
* <td>{@link org.springframework.web.service.invoker.HttpMethodArgumentResolver
|
||||
* HttpMethodArgumentResolver}</td>
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
|
||||
/**
|
||||
* Shortcut for {@link HttpExchange} for HTTP OPTIONS requests.
|
||||
*
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
|
||||
/**
|
||||
* Shortcut for {@link HttpExchange} for HTTP PATCH requests.
|
||||
*
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
|
||||
/**
|
||||
* Shortcut for {@link HttpExchange} for HTTP POST requests.
|
||||
*
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
|
||||
/**
|
||||
* Shortcut for {@link HttpExchange} for HTTP PUT requests.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Annotations to declare HTTP service, request methods.
|
||||
* Annotations for declaring HTTP service request methods.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.ValueConstants;
|
||||
|
||||
|
||||
/**
|
||||
* Base class for arguments that resolve to a named request value such as a
|
||||
* request header, path variable, cookie, and others.
|
||||
@@ -52,7 +51,7 @@ public abstract class AbstractNamedValueArgumentResolver implements HttpServiceA
|
||||
/**
|
||||
* Create an instance.
|
||||
* @param conversionService the {@link ConversionService} to use to format
|
||||
* Object to String values.
|
||||
* Object to String values
|
||||
*/
|
||||
protected AbstractNamedValueArgumentResolver(ConversionService conversionService) {
|
||||
Assert.notNull(conversionService, "ConversionService is required");
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.web.bind.annotation.CookieValue;
|
||||
|
||||
|
||||
/**
|
||||
* {@link HttpServiceArgumentResolver} for {@link CookieValue @CookieValue}
|
||||
* annotated arguments.
|
||||
|
||||
@@ -23,10 +23,9 @@ import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
|
||||
/**
|
||||
* Contract to abstract the underlying HTTP client and decouple it from the
|
||||
* {@link HttpServiceProxyFactory#createClient(Class) HTTP Service proxy}.
|
||||
* {@linkplain HttpServiceProxyFactory#createClient(Class) HTTP service proxy}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 6.0
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* {@link HttpServiceArgumentResolver} that resolves the target
|
||||
* request's HTTP method from an {@link HttpMethod} argument.
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.service.invoker;
|
||||
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -42,7 +41,6 @@ import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
import org.springframework.web.util.UriUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Container for HTTP request values extracted from an
|
||||
* {@link org.springframework.web.service.annotation.HttpExchange @HttpExchange}-annotated
|
||||
@@ -121,7 +119,7 @@ public final class HttpRequestValues {
|
||||
|
||||
/**
|
||||
* Return the URL template for the request, if set.
|
||||
* <p>This is mutually exclusive with a {@link #getUri() full URL}.
|
||||
* <p>This is mutually exclusive with a {@linkplain #getUri() full URL}.
|
||||
* One of the two has a value but not both.
|
||||
*/
|
||||
@Nullable
|
||||
@@ -171,7 +169,7 @@ public final class HttpRequestValues {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the element type for a {@link #getBody() Publisher body}.
|
||||
* Return the element type for a {@linkplain #getBody() Publisher body}.
|
||||
*/
|
||||
@Nullable
|
||||
public ParameterizedTypeReference<?> getBodyElementType() {
|
||||
@@ -237,7 +235,8 @@ public final class HttpRequestValues {
|
||||
/**
|
||||
* Set the request URL as a full URL.
|
||||
* <p>This is mutually exclusive with, and resets any previously set
|
||||
* {@link #setUriTemplate(String)}.
|
||||
* {@linkplain #setUriTemplate(String) URI template} or
|
||||
* {@linkplain #setUriVariable(String, String) URI variables}.
|
||||
*/
|
||||
public Builder setUri(URI uri) {
|
||||
this.uri = uri;
|
||||
@@ -249,7 +248,7 @@ public final class HttpRequestValues {
|
||||
/**
|
||||
* Set the request URL as a String template.
|
||||
* <p>This is mutually exclusive with, and resets any previously set
|
||||
* {@link #setUri(URI) full URI}.
|
||||
* {@linkplain #setUri(URI) full URI}.
|
||||
*/
|
||||
public Builder setUriTemplate(String uriTemplate) {
|
||||
this.uriTemplate = uriTemplate;
|
||||
@@ -260,7 +259,7 @@ public final class HttpRequestValues {
|
||||
/**
|
||||
* Add a URI variable name-value pair.
|
||||
* <p>This is mutually exclusive with, and resets any previously set
|
||||
* {@link #setUri(URI) full URI}.
|
||||
* {@linkplain #setUri(URI) full URI}.
|
||||
*/
|
||||
public Builder setUriVariable(String name, String value) {
|
||||
this.uriVars = (this.uriVars != null ? this.uriVars : new LinkedHashMap<>());
|
||||
@@ -269,7 +268,6 @@ public final class HttpRequestValues {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the media types for the request {@code Accept} header.
|
||||
*/
|
||||
@@ -330,7 +328,7 @@ public final class HttpRequestValues {
|
||||
/**
|
||||
* Set the request body as a concrete value to be serialized.
|
||||
* <p>This is mutually exclusive with, and resets any previously set
|
||||
* {@link #setBody(Publisher, ParameterizedTypeReference) body Publisher}.
|
||||
* {@linkplain #setBody(Publisher, ParameterizedTypeReference) body Publisher}.
|
||||
*/
|
||||
public void setBodyValue(Object bodyValue) {
|
||||
this.bodyValue = bodyValue;
|
||||
@@ -341,7 +339,7 @@ public final class HttpRequestValues {
|
||||
/**
|
||||
* Set the request body as a concrete value to be serialized.
|
||||
* <p>This is mutually exclusive with, and resets any previously set
|
||||
* {@link #setBodyValue(Object) body value}.
|
||||
* {@linkplain #setBodyValue(Object) body value}.
|
||||
*/
|
||||
public <T, P extends Publisher<T>> void setBody(P body, ParameterizedTypeReference<T> elementTye) {
|
||||
this.body = body;
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.web.service.annotation.HttpExchange;
|
||||
|
||||
|
||||
/**
|
||||
* Resolve an argument from an {@link HttpExchange @HttpExchange}-annotated method
|
||||
* to one or more HTTP request values.
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.service.invoker;
|
||||
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
@@ -45,10 +44,9 @@ import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.service.annotation.HttpExchange;
|
||||
|
||||
|
||||
/**
|
||||
* Implements the invocation of an {@link HttpExchange @HttpExchange}-annotated,
|
||||
* {@link HttpServiceProxyFactory#createClient(Class) HTTP Service proxy} method
|
||||
* {@link HttpServiceProxyFactory#createClient(Class) HTTP service proxy} method
|
||||
* by delegating to an {@link HttpClientAdapter} to perform actual requests.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -128,8 +126,8 @@ final class HttpServiceMethod {
|
||||
|
||||
|
||||
/**
|
||||
* Factory for an {@link HttpRequestValues} with values extracted from
|
||||
* the type and method-level {@link HttpExchange @HttpRequest} annotations.
|
||||
* Factory for {@link HttpRequestValues} with values extracted from the type
|
||||
* and method-level {@link HttpExchange @HttpRequest} annotations.
|
||||
*/
|
||||
private record HttpRequestValuesInitializer(
|
||||
HttpMethod httpMethod, @Nullable String url,
|
||||
@@ -254,7 +252,7 @@ final class HttpServiceMethod {
|
||||
|
||||
/**
|
||||
* Function to execute a request, obtain a response, and adapt to the expected
|
||||
* return type blocking if necessary.
|
||||
* return type, blocking if necessary.
|
||||
*/
|
||||
private record ResponseFunction(
|
||||
Function<HttpRequestValues, Publisher<?>> responseFunction,
|
||||
@@ -288,7 +286,7 @@ final class HttpServiceMethod {
|
||||
|
||||
|
||||
/**
|
||||
* Create the {@code ResponseFunction} that matches method return type.
|
||||
* Create the {@code ResponseFunction} that matches the method's return type.
|
||||
*/
|
||||
public static ResponseFunction create(
|
||||
HttpClientAdapter client, Method method, ReactiveAdapterRegistry reactiveRegistry,
|
||||
|
||||
@@ -37,7 +37,6 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.service.annotation.HttpExchange;
|
||||
|
||||
|
||||
/**
|
||||
* Factory for creating a client proxy given an HTTP service interface with
|
||||
* {@link HttpExchange @HttpExchange} methods.
|
||||
@@ -69,7 +68,7 @@ public final class HttpServiceProxyFactory {
|
||||
|
||||
/**
|
||||
* Return a proxy that implements the given HTTP service interface to perform
|
||||
* HTTP requests and retrieves responses through an HTTP client.
|
||||
* HTTP requests and retrieve responses through an HTTP client.
|
||||
* @param serviceType the HTTP service to create a proxy for
|
||||
* @param <S> the HTTP service type
|
||||
* @return the created proxy
|
||||
@@ -147,7 +146,7 @@ public final class HttpServiceProxyFactory {
|
||||
|
||||
/**
|
||||
* Set the {@link ReactiveAdapterRegistry} to use to support different
|
||||
* asynchronous types for HTTP Service method return values.
|
||||
* asynchronous types for HTTP service method return values.
|
||||
* <p>By default this is {@link ReactiveAdapterRegistry#getSharedInstance()}.
|
||||
* @return the same builder instance
|
||||
*/
|
||||
@@ -157,7 +156,7 @@ public final class HttpServiceProxyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure how long to wait for a response for an HTTP Service method
|
||||
* Configure how long to wait for a response for an HTTP service method
|
||||
* with a synchronous (blocking) method signature.
|
||||
* <p>By default this is 5 seconds.
|
||||
* @param blockTimeout the timeout value
|
||||
|
||||
@@ -20,13 +20,12 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
|
||||
/**
|
||||
* {@link HttpServiceArgumentResolver} for {@link PathVariable @PathVariable}
|
||||
* annotated arguments.
|
||||
*
|
||||
* <p>The argument may be a single variable value or a {@code Map} with multiple
|
||||
* variable and values. Each value may be a String or an Object to be converted
|
||||
* variables and values. Each value may be a String or an Object to be converted
|
||||
* to a String through the configured {@link ConversionService}.
|
||||
*
|
||||
* <p>If the value is required but {@code null}, {@link IllegalArgumentException}
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
|
||||
/**
|
||||
* {@link HttpServiceArgumentResolver} for {@link RequestBody @RequestBody}
|
||||
* annotated arguments.
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
|
||||
/**
|
||||
* {@link HttpServiceArgumentResolver} for {@link RequestHeader @RequestHeader}
|
||||
* annotated arguments.
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
|
||||
/**
|
||||
* {@link HttpServiceArgumentResolver} for {@link RequestParam @RequestParam}
|
||||
* annotated arguments.
|
||||
|
||||
@@ -21,10 +21,9 @@ import java.net.URI;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* {@link HttpServiceArgumentResolver} that resolves the URL for the request
|
||||
* from an {@link URI} argument.
|
||||
* from a {@link URI} argument.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 6.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Support to create a client proxy for an HTTP service annotated with
|
||||
* Support for creating a client proxy for an HTTP service annotated with
|
||||
* {@link org.springframework.web.service.annotation.HttpExchange} methods.
|
||||
*/
|
||||
@NonNullApi
|
||||
|
||||
Reference in New Issue
Block a user