Polishing

This commit is contained in:
Sam Brannen 2022-05-03 15:46:07 +02:00
parent c68665980f
commit 365a18c9c2
34 changed files with 32 additions and 67 deletions

View File

@ -24,7 +24,6 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* Shortcut for {@link HttpExchange} for HTTP DELETE requests.
*

View File

@ -24,7 +24,6 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* Shortcut for {@link HttpExchange} for HTTP GET requests.
*

View File

@ -24,7 +24,6 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* Shortcut for {@link HttpExchange} for HTTP HEAD requests.
*

View File

@ -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 &mdash; 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>

View File

@ -24,7 +24,6 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* Shortcut for {@link HttpExchange} for HTTP OPTIONS requests.
*

View File

@ -24,7 +24,6 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* Shortcut for {@link HttpExchange} for HTTP PATCH requests.
*

View File

@ -24,7 +24,6 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* Shortcut for {@link HttpExchange} for HTTP POST requests.
*

View File

@ -24,7 +24,6 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* Shortcut for {@link HttpExchange} for HTTP PUT requests.
*

View File

@ -1,5 +1,5 @@
/**
* Annotations to declare HTTP service, request methods.
* Annotations for declaring HTTP service request methods.
*/
@NonNullApi
@NonNullFields

View File

@ -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");

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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;

View File

@ -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.

View File

@ -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,

View File

@ -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

View File

@ -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}

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -26,9 +26,8 @@ import org.springframework.web.service.annotation.GetExchange;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for {@link RequestHeaderArgumentResolver}.
* Unit tests for {@link CookieValueArgumentResolver}.
* <p>For base class functionality, see {@link NamedValueArgumentResolverTests}.
*
* @author Rossen Stoyanchev

View File

@ -24,7 +24,6 @@ import org.springframework.web.service.annotation.GetExchange;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
* Tests for {@link HttpMethodArgumentResolver}.
*

View File

@ -16,7 +16,6 @@
package org.springframework.web.service.invoker;
import java.net.URI;
import org.junit.jupiter.api.Test;
@ -30,7 +29,6 @@ import org.springframework.web.util.UriComponentsBuilder;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for {@link HttpRequestValues}.
*

View File

@ -16,7 +16,6 @@
package org.springframework.web.service.invoker;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.core.Single;
@ -40,12 +39,11 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.http.MediaType.APPLICATION_CBOR_VALUE;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
/**
* Tests for {@link HttpServiceMethod} with a test {@link TestHttpClientAdapter}
* that stubs the client invocations.
*
* <p>The tests do not create nor invoke {@code HttpServiceMethod} directly but
* <p>The tests do not create or invoke {@code HttpServiceMethod} directly but
* rather use {@link HttpServiceProxyFactory} to create a service proxy in order to
* use a strongly typed interface without the need for class casts.
*

View File

@ -41,7 +41,6 @@ import org.springframework.web.service.annotation.GetExchange;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* Unit tests for {@link AbstractNamedValueArgumentResolver} through a
* {@link TestValue @TestValue} annotation and {@link TestNamedValueArgumentResolver}.
@ -230,7 +229,7 @@ class NamedValueArgumentResolverTests {
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface TestValue {
@interface TestValue {
@AliasFor("name")
String value() default "";

View File

@ -24,7 +24,6 @@ import org.springframework.web.service.annotation.GetExchange;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link PathVariableArgumentResolver}.
* <p>For base class functionality, see {@link NamedValueArgumentResolverTests}.

View File

@ -30,7 +30,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
* Unit tests for {@link RequestBodyArgumentResolver}.
*
@ -63,6 +62,7 @@ public class RequestBodyArgumentResolverTests {
}
@Test
@SuppressWarnings("unchecked")
void singleBody() {
String bodyValue = "bodyValue";
this.service.executeSingle(Single.just(bodyValue));

View File

@ -26,7 +26,6 @@ import org.springframework.web.service.annotation.GetExchange;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for {@link RequestHeaderArgumentResolver}.
* <p>For base class functionality, see {@link NamedValueArgumentResolverTests}.

View File

@ -24,7 +24,6 @@ import org.springframework.web.service.annotation.PostExchange;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for {@link RequestParamArgumentResolver}.
*

View File

@ -26,7 +26,6 @@ import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
/**
* {@link HttpClientAdapter} with stubbed responses.
*

View File

@ -25,7 +25,6 @@ import org.springframework.web.service.annotation.GetExchange;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
* Unit tests for {@link UrlArgumentResolver}.
*