Browse Source

Polishing

pull/1641/merge
Juergen Hoeller 8 years ago
parent
commit
61579ffe7b
  1. 3
      spring-test/src/main/java/org/springframework/test/context/web/AbstractGenericWebContextLoader.java
  2. 6
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/SyncHandlerMethodArgumentResolver.java
  3. 11
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueSyncArgumentResolver.java
  4. 7
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/MatrixVariableMapMethodArgumentResolver.java
  5. 12
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/MatrixVariableMethodArgumentResolver.java
  6. 7
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelArgumentResolver.java
  7. 8
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolver.java
  8. 12
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolver.java
  9. 11
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolver.java
  10. 7
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeArgumentResolver.java
  11. 8
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/SessionStatusMethodArgumentResolver.java
  12. 5
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMapMethodArgumentResolver.java

3
spring-test/src/main/java/org/springframework/test/context/web/AbstractGenericWebContextLoader.java

@ -190,7 +190,6 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa @@ -190,7 +190,6 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa
}
else {
ServletContext servletContext = null;
// Find the root WebApplicationContext
while (parent != null) {
if (parent instanceof WebApplicationContext && !(parent.getParent() instanceof WebApplicationContext)) {
@ -199,7 +198,7 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa @@ -199,7 +198,7 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa
}
parent = parent.getParent();
}
Assert.state(servletContext != null, "Failed to find Root WebApplicationContext in the context hierarchy");
Assert.state(servletContext != null, "Failed to find root WebApplicationContext in the context hierarchy");
context.setServletContext(servletContext);
}
}

6
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/SyncHandlerMethodArgumentResolver.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.
@ -52,7 +52,7 @@ public interface SyncHandlerMethodArgumentResolver extends HandlerMethodArgument @@ -52,7 +52,7 @@ public interface SyncHandlerMethodArgumentResolver extends HandlerMethodArgument
* @return the resolved value, if any
*/
@Nullable
Object resolveArgumentValue(MethodParameter parameter, BindingContext bindingContext,
ServerWebExchange exchange);
Object resolveArgumentValue(
MethodParameter parameter, BindingContext bindingContext, ServerWebExchange exchange);
}

11
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueSyncArgumentResolver.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.
@ -38,15 +38,14 @@ import org.springframework.web.server.ServerWebExchange; @@ -38,15 +38,14 @@ import org.springframework.web.server.ServerWebExchange;
public abstract class AbstractNamedValueSyncArgumentResolver extends AbstractNamedValueArgumentResolver
implements SyncHandlerMethodArgumentResolver {
/**
* @param factory a bean factory to use for resolving ${...}
* placeholder and #{...} SpEL expressions in default values;
* or {@code null} if default values are not expected to have expressions
* @param registry for checking reactive type wrappers
*/
protected AbstractNamedValueSyncArgumentResolver(@Nullable ConfigurableBeanFactory factory,
ReactiveAdapterRegistry registry) {
protected AbstractNamedValueSyncArgumentResolver(
@Nullable ConfigurableBeanFactory factory, ReactiveAdapterRegistry registry) {
super(factory, registry);
}
@ -65,8 +64,8 @@ public abstract class AbstractNamedValueSyncArgumentResolver extends AbstractNam @@ -65,8 +64,8 @@ public abstract class AbstractNamedValueSyncArgumentResolver extends AbstractNam
}
@Override
public Object resolveArgumentValue(MethodParameter parameter, BindingContext context,
ServerWebExchange exchange) {
public Object resolveArgumentValue(
MethodParameter parameter, BindingContext context, ServerWebExchange exchange) {
// This won't block since resolveName below doesn't
return resolveArgument(parameter, context, exchange).block();

7
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/MatrixVariableMapMethodArgumentResolver.java

@ -40,7 +40,7 @@ import org.springframework.web.server.ServerWebExchange; @@ -40,7 +40,7 @@ import org.springframework.web.server.ServerWebExchange;
/**
* Resolves arguments of type {@link Map} annotated with {@link MatrixVariable @MatrixVariable}
* where the annotation does not specify a name. In other words the purpose of this resolver
* is to provide access to multiple matrix variables, either all or associted with a specific
* is to provide access to multiple matrix variables, either all or associated with a specific
* path variable.
*
* <p>When a name is specified, an argument of type Map is considered to be a single attribute
@ -53,7 +53,6 @@ import org.springframework.web.server.ServerWebExchange; @@ -53,7 +53,6 @@ import org.springframework.web.server.ServerWebExchange;
public class MatrixVariableMapMethodArgumentResolver extends HandlerMethodArgumentResolverSupport
implements SyncHandlerMethodArgumentResolver {
public MatrixVariableMapMethodArgumentResolver(ReactiveAdapterRegistry registry) {
super(registry);
}
@ -62,7 +61,7 @@ public class MatrixVariableMapMethodArgumentResolver extends HandlerMethodArgume @@ -62,7 +61,7 @@ public class MatrixVariableMapMethodArgumentResolver extends HandlerMethodArgume
@Override
public boolean supportsParameter(MethodParameter parameter) {
return checkAnnotatedParamNoReactiveWrapper(parameter, MatrixVariable.class,
(annot, type) -> (Map.class.isAssignableFrom(type) && !StringUtils.hasText(annot.name())));
(ann, type) -> (Map.class.isAssignableFrom(type) && !StringUtils.hasText(ann.name())));
}
@Nullable
@ -113,4 +112,4 @@ public class MatrixVariableMapMethodArgumentResolver extends HandlerMethodArgume @@ -113,4 +112,4 @@ public class MatrixVariableMapMethodArgumentResolver extends HandlerMethodArgume
return false;
}
}
}

12
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/MatrixVariableMethodArgumentResolver.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.
@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.reactive.result.method.annotation;
import java.util.ArrayList;
@ -48,9 +49,8 @@ import org.springframework.web.server.ServerWebInputException; @@ -48,9 +49,8 @@ import org.springframework.web.server.ServerWebInputException;
*/
public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueSyncArgumentResolver {
protected MatrixVariableMethodArgumentResolver(@Nullable ConfigurableBeanFactory factory,
ReactiveAdapterRegistry registry) {
public MatrixVariableMethodArgumentResolver(
@Nullable ConfigurableBeanFactory factory, ReactiveAdapterRegistry registry) {
super(factory, registry);
}
@ -59,7 +59,7 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueSync @@ -59,7 +59,7 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueSync
@Override
public boolean supportsParameter(MethodParameter parameter) {
return checkAnnotatedParamNoReactiveWrapper(parameter, MatrixVariable.class,
(annot, type) -> !Map.class.isAssignableFrom(type) || StringUtils.hasText(annot.name()));
(ann, type) -> !Map.class.isAssignableFrom(type) || StringUtils.hasText(ann.name()));
}
@ -73,10 +73,8 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueSync @@ -73,10 +73,8 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueSync
@Nullable
@Override
protected Object resolveNamedValue(String name, MethodParameter param, ServerWebExchange exchange) {
Map<String, MultiValueMap<String, String>> pathParameters =
exchange.getAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE);
if (CollectionUtils.isEmpty(pathParameters)) {
return null;
}

7
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelArgumentResolver.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.
@ -21,7 +21,6 @@ import java.util.Map; @@ -21,7 +21,6 @@ import java.util.Map;
import org.springframework.core.MethodParameter;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.ui.Model;
import org.springframework.util.Assert;
import org.springframework.web.reactive.BindingContext;
import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport;
import org.springframework.web.reactive.result.method.SyncHandlerMethodArgumentResolver;
@ -49,8 +48,8 @@ public class ModelArgumentResolver extends HandlerMethodArgumentResolverSupport @@ -49,8 +48,8 @@ public class ModelArgumentResolver extends HandlerMethodArgumentResolverSupport
}
@Override
public Object resolveArgumentValue(MethodParameter parameter, BindingContext context,
ServerWebExchange exchange) {
public Object resolveArgumentValue(
MethodParameter parameter, BindingContext context, ServerWebExchange exchange) {
Class<?> type = parameter.getParameterType();
if (Model.class.isAssignableFrom(type)) {

8
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolver.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.
@ -53,13 +53,13 @@ public class PathVariableMapMethodArgumentResolver extends HandlerMethodArgument @@ -53,13 +53,13 @@ public class PathVariableMapMethodArgumentResolver extends HandlerMethodArgument
}
private boolean allVariables(PathVariable pathVariable, Class<?> type) {
return Map.class.isAssignableFrom(type) && !StringUtils.hasText(pathVariable.value());
return (Map.class.isAssignableFrom(type) && !StringUtils.hasText(pathVariable.value()));
}
@Override
public Object resolveArgumentValue(MethodParameter methodParameter, BindingContext context,
ServerWebExchange exchange) {
public Object resolveArgumentValue(
MethodParameter methodParameter, BindingContext context, ServerWebExchange exchange) {
String name = HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE;
return exchange.getAttributeOrDefault(name, Collections.emptyMap());

12
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolver.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.
@ -60,14 +60,12 @@ public class RequestHeaderMapMethodArgumentResolver extends HandlerMethodArgumen @@ -60,14 +60,12 @@ public class RequestHeaderMapMethodArgumentResolver extends HandlerMethodArgumen
@Override
public Object resolveArgumentValue(MethodParameter methodParameter,
BindingContext context, ServerWebExchange exchange) {
Class<?> paramType = methodParameter.getParameterType();
boolean isMultiValueMap = MultiValueMap.class.isAssignableFrom(paramType);
public Object resolveArgumentValue(
MethodParameter methodParameter, BindingContext context, ServerWebExchange exchange) {
boolean isMultiValueMap = MultiValueMap.class.isAssignableFrom(methodParameter.getParameterType());
HttpHeaders headers = exchange.getRequest().getHeaders();
return isMultiValueMap ? headers : headers.toSingleValueMap();
return (isMultiValueMap ? headers : headers.toSingleValueMap());
}
}

11
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolver.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.
@ -47,7 +47,6 @@ import org.springframework.web.server.ServerWebExchange; @@ -47,7 +47,6 @@ import org.springframework.web.server.ServerWebExchange;
public class RequestParamMapMethodArgumentResolver extends HandlerMethodArgumentResolverSupport
implements SyncHandlerMethodArgumentResolver {
public RequestParamMapMethodArgumentResolver(ReactiveAdapterRegistry adapterRegistry) {
super(adapterRegistry);
}
@ -59,17 +58,17 @@ public class RequestParamMapMethodArgumentResolver extends HandlerMethodArgument @@ -59,17 +58,17 @@ public class RequestParamMapMethodArgumentResolver extends HandlerMethodArgument
}
private boolean allParams(RequestParam requestParam, Class<?> type) {
return Map.class.isAssignableFrom(type) && !StringUtils.hasText(requestParam.name());
return (Map.class.isAssignableFrom(type) && !StringUtils.hasText(requestParam.name()));
}
@Override
public Object resolveArgumentValue(MethodParameter methodParameter, BindingContext context,
ServerWebExchange exchange) {
public Object resolveArgumentValue(
MethodParameter methodParameter, BindingContext context, ServerWebExchange exchange) {
boolean isMultiValueMap = MultiValueMap.class.isAssignableFrom(methodParameter.getParameterType());
MultiValueMap<String, String> queryParams = exchange.getRequest().getQueryParams();
return isMultiValueMap ? queryParams : queryParams.toSingleValueMap();
return (isMultiValueMap ? queryParams : queryParams.toSingleValueMap());
}
}

7
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeArgumentResolver.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.
@ -25,7 +25,6 @@ import org.springframework.context.i18n.TimeZoneAwareLocaleContext; @@ -25,7 +25,6 @@ import org.springframework.context.i18n.TimeZoneAwareLocaleContext;
import org.springframework.core.MethodParameter;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRequest;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.lang.Nullable;
@ -80,8 +79,8 @@ public class ServerWebExchangeArgumentResolver extends HandlerMethodArgumentReso @@ -80,8 +79,8 @@ public class ServerWebExchangeArgumentResolver extends HandlerMethodArgumentReso
}
@Override
public Object resolveArgumentValue(MethodParameter methodParameter, BindingContext context,
ServerWebExchange exchange) {
public Object resolveArgumentValue(
MethodParameter methodParameter, BindingContext context, ServerWebExchange exchange) {
Class<?> paramType = methodParameter.getParameterType();
if (ServerWebExchange.class.isAssignableFrom(paramType)) {

8
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/SessionStatusMethodArgumentResolver.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.
@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.reactive.result.method.annotation;
import org.springframework.core.MethodParameter;
@ -32,7 +33,6 @@ import org.springframework.web.server.ServerWebExchange; @@ -32,7 +33,6 @@ import org.springframework.web.server.ServerWebExchange;
*/
public class SessionStatusMethodArgumentResolver implements SyncHandlerMethodArgumentResolver {
@Override
public boolean supportsParameter(MethodParameter parameter) {
return SessionStatus.class == parameter.getParameterType();
@ -40,8 +40,8 @@ public class SessionStatusMethodArgumentResolver implements SyncHandlerMethodArg @@ -40,8 +40,8 @@ public class SessionStatusMethodArgumentResolver implements SyncHandlerMethodArg
@Nullable
@Override
public Object resolveArgumentValue(MethodParameter parameter, BindingContext bindingContext,
ServerWebExchange exchange) {
public Object resolveArgumentValue(
MethodParameter parameter, BindingContext bindingContext, ServerWebExchange exchange) {
Assert.isInstanceOf(InitBinderBindingContext.class, bindingContext);
return ((InitBinderBindingContext) bindingContext).getSessionStatus();

5
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMapMethodArgumentResolver.java

@ -40,7 +40,7 @@ import org.springframework.web.servlet.HandlerMapping; @@ -40,7 +40,7 @@ import org.springframework.web.servlet.HandlerMapping;
/**
* Resolves arguments of type {@link Map} annotated with {@link MatrixVariable @MatrixVariable}
* where the annotation does not specify a name. In other words the purpose of this resolver
* is to provide access to multiple matrix variables, either all or associted with a specific
* is to provide access to multiple matrix variables, either all or associated with a specific
* path variable.
*
* <p>When a name is specified, an argument of type Map is considered to be a single attribute
@ -51,7 +51,6 @@ import org.springframework.web.servlet.HandlerMapping; @@ -51,7 +51,6 @@ import org.springframework.web.servlet.HandlerMapping;
*/
public class MatrixVariableMapMethodArgumentResolver implements HandlerMethodArgumentResolver {
@Override
public boolean supportsParameter(MethodParameter parameter) {
MatrixVariable matrixVariable = parameter.getParameterAnnotation(MatrixVariable.class);
@ -113,4 +112,4 @@ public class MatrixVariableMapMethodArgumentResolver implements HandlerMethodArg @@ -113,4 +112,4 @@ public class MatrixVariableMapMethodArgumentResolver implements HandlerMethodArg
return false;
}
}
}

Loading…
Cancel
Save