Polishing
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
@@ -28,6 +27,7 @@ import org.springframework.web.cors.CorsConfiguration;
|
||||
* @author Sebastien Deleuze
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 5.0
|
||||
* @see CorsConfiguration
|
||||
* @see CorsRegistry
|
||||
*/
|
||||
public class CorsRegistration {
|
||||
@@ -39,6 +39,7 @@ public class CorsRegistration {
|
||||
|
||||
public CorsRegistration(String pathPattern) {
|
||||
this.pathPattern = pathPattern;
|
||||
// Same implicit default values as the @CrossOrigin annotation + allows simple methods
|
||||
this.config = new CorsConfiguration().applyPermitDefaultValues();
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ public class CorsRegistration {
|
||||
* See the Spring Framework reference for more on this filter.
|
||||
*/
|
||||
public CorsRegistration allowedOrigins(String... origins) {
|
||||
this.config.setAllowedOrigins(new ArrayList<>(Arrays.asList(origins)));
|
||||
this.config.setAllowedOrigins(Arrays.asList(origins));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -69,7 +70,7 @@ public class CorsRegistration {
|
||||
* are allowed.
|
||||
*/
|
||||
public CorsRegistration allowedMethods(String... methods) {
|
||||
this.config.setAllowedMethods(new ArrayList<>(Arrays.asList(methods)));
|
||||
this.config.setAllowedMethods(Arrays.asList(methods));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ public class CorsRegistration {
|
||||
* <p>By default all headers are allowed.
|
||||
*/
|
||||
public CorsRegistration allowedHeaders(String... headers) {
|
||||
this.config.setAllowedHeaders(new ArrayList<>(Arrays.asList(headers)));
|
||||
this.config.setAllowedHeaders(Arrays.asList(headers));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -96,7 +97,7 @@ public class CorsRegistration {
|
||||
* <p>By default this is not set.
|
||||
*/
|
||||
public CorsRegistration exposedHeaders(String... headers) {
|
||||
this.config.setExposedHeaders(new ArrayList<>(Arrays.asList(headers)));
|
||||
this.config.setExposedHeaders(Arrays.asList(headers));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -37,18 +37,12 @@ public class CorsRegistry {
|
||||
|
||||
|
||||
/**
|
||||
* Enable cross origin request handling for the specified path pattern.
|
||||
*
|
||||
* Enable cross-origin request handling for the specified path pattern.
|
||||
* <p>Exact path mapping URIs (such as {@code "/admin"}) are supported as
|
||||
* well as Ant-style path patterns (such as {@code "/admin/**"}).
|
||||
*
|
||||
* <p>The following defaults are applied to the {@link CorsRegistration}:
|
||||
* <ul>
|
||||
* <li>Allow all origins.</li>
|
||||
* <li>Allow "simple" methods {@code GET}, {@code HEAD} and {@code POST}.</li>
|
||||
* <li>Allow all headers.</li>
|
||||
* <li>Set max age to 1800 seconds (30 minutes).</li>
|
||||
* </ul>
|
||||
* <p>By default, the {@code CorsConfiguration} for this mapping is
|
||||
* initialized with default values as described in
|
||||
* {@link CorsConfiguration#applyPermitDefaultValues()}.
|
||||
*/
|
||||
public CorsRegistration addMapping(String pathPattern) {
|
||||
CorsRegistration registration = new CorsRegistration(pathPattern);
|
||||
@@ -56,6 +50,10 @@ public class CorsRegistry {
|
||||
return registration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the registered {@link CorsConfiguration} objects,
|
||||
* keyed by path pattern.
|
||||
*/
|
||||
protected Map<String, CorsConfiguration> getCorsConfigurations() {
|
||||
Map<String, CorsConfiguration> configs = new LinkedHashMap<>(this.registrations.size());
|
||||
for (CorsRegistration registration : this.registrations) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -83,7 +83,7 @@ class ControllerMethodResolver {
|
||||
AnnotationUtils.findAnnotation(method, ModelAttribute.class) != null);
|
||||
|
||||
|
||||
private static Log logger = LogFactory.getLog(ControllerMethodResolver.class);
|
||||
private static final Log logger = LogFactory.getLog(ControllerMethodResolver.class);
|
||||
|
||||
private final List<SyncHandlerMethodArgumentResolver> initBinderResolvers;
|
||||
|
||||
@@ -95,14 +95,12 @@ class ControllerMethodResolver {
|
||||
|
||||
private final ReactiveAdapterRegistry reactiveAdapterRegistry;
|
||||
|
||||
|
||||
private final Map<Class<?>, Set<Method>> initBinderMethodCache = new ConcurrentHashMap<>(64);
|
||||
|
||||
private final Map<Class<?>, Set<Method>> modelAttributeMethodCache = new ConcurrentHashMap<>(64);
|
||||
|
||||
private final Map<Class<?>, ExceptionHandlerMethodResolver> exceptionHandlerCache = new ConcurrentHashMap<>(64);
|
||||
|
||||
|
||||
private final Map<ControllerAdviceBean, Set<Method>> initBinderAdviceCache = new LinkedHashMap<>(64);
|
||||
|
||||
private final Map<ControllerAdviceBean, Set<Method>> modelAttributeAdviceCache = new LinkedHashMap<>(64);
|
||||
@@ -169,7 +167,7 @@ class ControllerMethodResolver {
|
||||
boolean requestMappingMethod = !readers.isEmpty() && supportDataBinding;
|
||||
|
||||
// Annotation-based...
|
||||
List<HandlerMethodArgumentResolver> result = new ArrayList<>();
|
||||
List<HandlerMethodArgumentResolver> result = new ArrayList<>(30);
|
||||
result.add(new RequestParamMethodArgumentResolver(beanFactory, adapterRegistry, false));
|
||||
result.add(new RequestParamMapMethodArgumentResolver(adapterRegistry));
|
||||
result.add(new PathVariableMethodArgumentResolver(beanFactory, adapterRegistry));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2020 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,7 +38,6 @@ import org.springframework.web.server.ServerWebInputException;
|
||||
*/
|
||||
public class RequestAttributeMethodArgumentResolver extends AbstractNamedValueSyncArgumentResolver {
|
||||
|
||||
|
||||
/**
|
||||
* @param factory a bean factory to use for resolving ${...}
|
||||
* placeholder and #{...} SpEL expressions in default values;
|
||||
|
||||
Reference in New Issue
Block a user