Browse Source

Polishing

pull/1916/head
Juergen Hoeller 8 years ago
parent
commit
93ef169c5c
  1. 3
      spring-test/src/main/java/org/springframework/test/web/servlet/ResultMatcher.java
  2. 2
      spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java
  3. 4
      spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java
  4. 11
      spring-webflux/src/main/java/org/springframework/web/reactive/config/WebFluxConfigurationSupport.java
  5. 42
      spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java
  6. 20
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java
  7. 9
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
  8. 16
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java

3
spring-test/src/main/java/org/springframework/test/web/servlet/ResultMatcher.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -51,7 +51,6 @@ public interface ResultMatcher { @@ -51,7 +51,6 @@ public interface ResultMatcher {
/**
* Assert the result of an executed request.
*
* @param result the result of the executed request
* @throws Exception if a failure occurs
*/

2
spring-web/src/main/java/org/springframework/http/codec/support/BaseDefaultCodecs.java

@ -233,7 +233,7 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs { @@ -233,7 +233,7 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs {
}
// Accessors for use in sub-classes...
// Accessors for use in subclasses...
protected Decoder<?> getJackson2JsonDecoder() {
return (this.jackson2JsonDecoder != null ? this.jackson2JsonDecoder : new Jackson2JsonDecoder());

4
spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java

@ -54,7 +54,8 @@ import static org.mockito.Mockito.*; @@ -54,7 +54,8 @@ import static org.mockito.Mockito.*;
import static org.springframework.core.ResolvableType.forClass;
/**
* Unit tests for {@link BaseCodecConfigurer}.
* Unit tests for {@link BaseDefaultCodecs}.
*
* @author Rossen Stoyanchev
*/
public class CodecConfigurerTests {
@ -294,7 +295,6 @@ public class CodecConfigurerTests { @@ -294,7 +295,6 @@ public class CodecConfigurerTests {
}
private static class TestDefaultCodecs extends BaseDefaultCodecs {
}
}

11
spring-webflux/src/main/java/org/springframework/web/reactive/config/WebFluxConfigurationSupport.java

@ -120,13 +120,14 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware { @@ -120,13 +120,14 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
PathMatchConfigurer configurer = getPathMatchConfigurer();
Boolean useTrailingSlashMatch = configurer.isUseTrailingSlashMatch();
Boolean useCaseSensitiveMatch = configurer.isUseCaseSensitiveMatch();
if (useTrailingSlashMatch != null) {
mapping.setUseTrailingSlashMatch(useTrailingSlashMatch);
}
Boolean useCaseSensitiveMatch = configurer.isUseCaseSensitiveMatch();
if (useCaseSensitiveMatch != null) {
mapping.setUseCaseSensitiveMatch(useCaseSensitiveMatch);
}
return mapping;
}
@ -316,6 +317,10 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware { @@ -316,6 +317,10 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
return initializer;
}
/**
* Return a {@link FormattingConversionService} for use with annotated controllers.
* <p>See {@link #addFormatters} as an alternative to overriding this method.
*/
@Bean
public FormattingConversionService webFluxConversionService() {
FormattingConversionService service = new DefaultFormattingConversionService();
@ -324,7 +329,9 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware { @@ -324,7 +329,9 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
}
/**
* Override to add custom {@link Converter}s and {@link Formatter}s.
* Override this method to add custom {@link Converter} and/or {@link Formatter}
* delegates to the common {@link FormattingConversionService}.
* @see #webFluxConversionService()
*/
protected void addFormatters(FormatterRegistry registry) {
}

42
spring-webflux/src/main/java/org/springframework/web/reactive/function/server/RequestPredicates.java

@ -76,8 +76,9 @@ public abstract class RequestPredicates { @@ -76,8 +76,9 @@ public abstract class RequestPredicates {
/**
* Return a {@code RequestPredicate} that tests against the given HTTP method.
* @param httpMethod the HTTP method to match to
* Return a {@code RequestPredicate} that matches if the request's
* HTTP method is equal to the given method.
* @param httpMethod the HTTP method to match against
* @return a predicate that tests against the given HTTP method
*/
public static RequestPredicate method(HttpMethod httpMethod) {
@ -85,7 +86,8 @@ public abstract class RequestPredicates { @@ -85,7 +86,8 @@ public abstract class RequestPredicates {
}
/**
* Return a {@code RequestPredicate} that tests the request path against the given path pattern.
* Return a {@code RequestPredicate} that tests the request path
* against the given path pattern.
* @param pattern the pattern to match to
* @return a predicate that tests against the given path pattern
*/
@ -95,20 +97,22 @@ public abstract class RequestPredicates { @@ -95,20 +97,22 @@ public abstract class RequestPredicates {
}
/**
* Return a function that creates new path-matching {@code RequestPredicates} from pattern
* Strings using the given {@link PathPatternParser}. This method can be used to specify a
* non-default, customized {@code PathPatternParser} when resolving path patterns.
* Return a function that creates new path-matching {@code RequestPredicates}
* from pattern Strings using the given {@link PathPatternParser}.
* <p>This method can be used to specify a non-default, customized
* {@code PathPatternParser} when resolving path patterns.
* @param patternParser the parser used to parse patterns given to the returned function
* @return a function that resolves patterns Strings into path-matching
* {@code RequestPredicate}s
* @return a function that resolves a pattern String into a path-matching
* {@code RequestPredicates} instance
*/
public static Function<String, RequestPredicate> pathPredicates(PathPatternParser patternParser) {
Assert.notNull(patternParser, "'patternParser' must not be null");
Assert.notNull(patternParser, "PathPatternParser must not be null");
return pattern -> new PathPatternPredicate(patternParser.parse(pattern));
}
/**
* Return a {@code RequestPredicate} that tests the request's headers against the given headers predicate.
* Return a {@code RequestPredicate} that tests the request's headers
* against the given headers predicate.
* @param headersPredicate a predicate that tests against the request headers
* @return a predicate that tests against the given header predicate
*/
@ -290,12 +294,12 @@ public abstract class RequestPredicates { @@ -290,12 +294,12 @@ public abstract class RequestPredicates {
/**
* Return a {@code RequestPredicate} that matches if the request's query parameter of the given name
* has the given value
* has the given value.
* @param name the name of the query parameter to test against
* @param value the value of the query parameter to test against
* @return a predicate that matches if the query parameter has the given value
* @see ServerRequest#queryParam(String)
* @since 5.0.7
* @see ServerRequest#queryParam(String)
*/
public static RequestPredicate queryParam(String name, String value) {
return queryParam(name, new Predicate<String>() {
@ -303,7 +307,6 @@ public abstract class RequestPredicates { @@ -303,7 +307,6 @@ public abstract class RequestPredicates {
public boolean test(String s) {
return s.equals(value);
}
@Override
public String toString() {
return String.format("== %s", value);
@ -326,9 +329,8 @@ public abstract class RequestPredicates { @@ -326,9 +329,8 @@ public abstract class RequestPredicates {
private static void traceMatch(String prefix, Object desired, @Nullable Object actual, boolean match) {
if (logger.isTraceEnabled()) {
String message = String.format("%s \"%s\" %s against value \"%s\"",
prefix, desired, match ? "matches" : "does not match", actual);
logger.trace(message);
logger.trace(String.format("%s \"%s\" %s against value \"%s\"",
prefix, desired, match ? "matches" : "does not match", actual));
}
}
@ -472,6 +474,10 @@ public abstract class RequestPredicates { @@ -472,6 +474,10 @@ public abstract class RequestPredicates {
}
/**
* {@link RequestPredicate} for where both {@code left} and {@code right} predicates
* must match.
*/
static class AndRequestPredicate implements RequestPredicate {
private final RequestPredicate left;
@ -502,6 +508,10 @@ public abstract class RequestPredicates { @@ -502,6 +508,10 @@ public abstract class RequestPredicates {
}
/**
* {@link RequestPredicate} for where either {@code left} or {@code right} predicates
* may match.
*/
static class OrRequestPredicate implements RequestPredicate {
private final RequestPredicate left;

20
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMapping.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -57,14 +57,21 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi @@ -57,14 +57,21 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
/**
* Set the {@link RequestedContentTypeResolver} to use to determine requested media types.
* If not set, the default constructor is used.
* Set the {@link RequestedContentTypeResolver} to use to determine requested
* media types. If not set, the default constructor is used.
*/
public void setContentTypeResolver(RequestedContentTypeResolver contentTypeResolver) {
Assert.notNull(contentTypeResolver, "'contentTypeResolver' must not be null");
this.contentTypeResolver = contentTypeResolver;
}
/**
* Return the configured {@link RequestedContentTypeResolver}.
*/
public RequestedContentTypeResolver getContentTypeResolver() {
return this.contentTypeResolver;
}
@Override
public void setEmbeddedValueResolver(StringValueResolver resolver) {
this.embeddedValueResolver = resolver;
@ -80,13 +87,6 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi @@ -80,13 +87,6 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
}
/**
* Return the configured {@link RequestedContentTypeResolver}.
*/
public RequestedContentTypeResolver getContentTypeResolver() {
return this.contentTypeResolver;
}
/**
* {@inheritDoc}
* Expects a handler to have a type-level @{@link Controller} annotation.

9
spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java

@ -624,9 +624,8 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv @@ -624,9 +624,8 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
}
/**
* Return a {@link FormattingConversionService} for use with annotated
* controller methods and the {@code spring:eval} JSP tag.
* Also see {@link #addFormatters} as an alternative to overriding this method.
* Return a {@link FormattingConversionService} for use with annotated controllers.
* <p>See {@link #addFormatters} as an alternative to overriding this method.
*/
@Bean
public FormattingConversionService mvcConversionService() {
@ -636,7 +635,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv @@ -636,7 +635,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
}
/**
* Override this method to add custom {@link Converter}s and {@link Formatter}s.
* Override this method to add custom {@link Converter} and/or {@link Formatter}
* delegates to the common {@link FormattingConversionService}.
* @see #mvcConversionService()
*/
protected void addFormatters(FormatterRegistry registry) {
}

16
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -111,6 +111,13 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi @@ -111,6 +111,13 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
this.contentNegotiationManager = contentNegotiationManager;
}
/**
* Return the configured {@link ContentNegotiationManager}.
*/
public ContentNegotiationManager getContentNegotiationManager() {
return this.contentNegotiationManager;
}
@Override
public void setEmbeddedValueResolver(StringValueResolver resolver) {
this.embeddedValueResolver = resolver;
@ -151,13 +158,6 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi @@ -151,13 +158,6 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
return this.useTrailingSlashMatch;
}
/**
* Return the configured {@link ContentNegotiationManager}.
*/
public ContentNegotiationManager getContentNegotiationManager() {
return this.contentNegotiationManager;
}
/**
* Return the file extensions to use for suffix pattern matching.
*/

Loading…
Cancel
Save