Polishing
This commit is contained in:
parent
30bf870810
commit
e9898f7d52
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 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.
|
||||
|
|
@ -49,8 +49,9 @@ abstract class AbstractJndiLocatingBeanDefinitionParser extends AbstractSimpleBe
|
|||
|
||||
@Override
|
||||
protected boolean isEligibleAttribute(String attributeName) {
|
||||
return (super.isEligibleAttribute(attributeName) && !ENVIRONMENT_REF.equals(attributeName) && !LAZY_INIT_ATTRIBUTE
|
||||
.equals(attributeName));
|
||||
return (super.isEligibleAttribute(attributeName) &&
|
||||
!ENVIRONMENT_REF.equals(attributeName) &&
|
||||
!LAZY_INIT_ATTRIBUTE.equals(attributeName));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -42,8 +42,9 @@ public class JeeNamespaceHandlerTests {
|
|||
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
public void setup() {
|
||||
GenericApplicationContext ctx = new GenericApplicationContext();
|
||||
new XmlBeanDefinitionReader(ctx).loadBeanDefinitions(
|
||||
new ClassPathResource("jeeNamespaceHandlerTests.xml", getClass()));
|
||||
|
|
@ -52,8 +53,9 @@ public class JeeNamespaceHandlerTests {
|
|||
this.beanFactory.getBeanNamesForType(ITestBean.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSimpleDefinition() throws Exception {
|
||||
public void testSimpleDefinition() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simple");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "jndiName", "jdbc/MyDataSource");
|
||||
|
|
@ -61,7 +63,7 @@ public class JeeNamespaceHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testComplexDefinition() throws Exception {
|
||||
public void testComplexDefinition() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complex");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "jndiName", "jdbc/MyDataSource");
|
||||
|
|
@ -75,21 +77,21 @@ public class JeeNamespaceHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testWithEnvironment() throws Exception {
|
||||
public void testWithEnvironment() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("withEnvironment");
|
||||
assertPropertyValue(beanDefinition, "jndiEnvironment", "foo=bar");
|
||||
assertPropertyValue(beanDefinition, "defaultObject", new RuntimeBeanReference("myBean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithReferencedEnvironment() throws Exception {
|
||||
public void testWithReferencedEnvironment() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("withReferencedEnvironment");
|
||||
assertPropertyValue(beanDefinition, "jndiEnvironment", new RuntimeBeanReference("myEnvironment"));
|
||||
assertThat(beanDefinition.getPropertyValues().contains("environmentRef")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleLocalSlsb() throws Exception {
|
||||
public void testSimpleLocalSlsb() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleLocalEjb");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(LocalStatelessSessionProxyFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "businessInterface", ITestBean.class.getName());
|
||||
|
|
@ -97,7 +99,7 @@ public class JeeNamespaceHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleRemoteSlsb() throws Exception {
|
||||
public void testSimpleRemoteSlsb() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleRemoteEjb");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(SimpleRemoteStatelessSessionProxyFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "businessInterface", ITestBean.class.getName());
|
||||
|
|
@ -105,7 +107,7 @@ public class JeeNamespaceHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testComplexLocalSlsb() throws Exception {
|
||||
public void testComplexLocalSlsb() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexLocalEjb");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(LocalStatelessSessionProxyFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "businessInterface", ITestBean.class.getName());
|
||||
|
|
@ -117,7 +119,7 @@ public class JeeNamespaceHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testComplexRemoteSlsb() throws Exception {
|
||||
public void testComplexRemoteSlsb() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexRemoteEjb");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(SimpleRemoteStatelessSessionProxyFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "businessInterface", ITestBean.class.getName());
|
||||
|
|
@ -132,7 +134,7 @@ public class JeeNamespaceHandlerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLazyInitJndiLookup() throws Exception {
|
||||
public void testLazyInitJndiLookup() {
|
||||
BeanDefinition definition = this.beanFactory.getMergedBeanDefinition("lazyDataSource");
|
||||
assertThat(definition.isLazyInit()).isTrue();
|
||||
definition = this.beanFactory.getMergedBeanDefinition("lazyLocalBean");
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ public @interface RequestMapping {
|
|||
* produces = "text/plain;charset=UTF-8"
|
||||
* </pre>
|
||||
* <p>If a declared media type contains a parameter (e.g. "charset=UTF-8",
|
||||
* "type=feed", type="entry") and if a compatible media type from the request
|
||||
* "type=feed", "type=entry") and if a compatible media type from the request
|
||||
* has that parameter too, then the parameter values must match. Otherwise
|
||||
* if the media type from the request does not contain the parameter, it is
|
||||
* assumed the client accepts any value.
|
||||
|
|
@ -212,7 +212,6 @@ public @interface RequestMapping {
|
|||
* If specified at both levels, the method level produces condition overrides
|
||||
* the type level condition.
|
||||
* @see org.springframework.http.MediaType
|
||||
* @see org.springframework.http.MediaType
|
||||
*/
|
||||
String[] produces() default {};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,11 +37,9 @@ 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>By default, the {@code CorsConfiguration} for this mapping is
|
||||
* initialized with default values as described in
|
||||
* {@link CorsConfiguration#applyPermitDefaultValues()}.
|
||||
|
|
@ -52,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.
|
||||
|
|
@ -169,7 +169,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-2018 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 {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new {@link RequestAttributeMethodArgumentResolver} instance.
|
||||
* @param factory a bean factory to use for resolving {@code ${...}}
|
||||
|
|
|
|||
|
|
@ -67,9 +67,9 @@ public class CorsRegistration {
|
|||
|
||||
/**
|
||||
* Set the HTTP methods to allow, e.g. {@code "GET"}, {@code "POST"}, etc.
|
||||
* The special value {@code "*"} allows all methods.
|
||||
* <p>By default "simple" methods, i.e. {@code GET}, {@code HEAD}, and
|
||||
* {@code POST} are allowed.
|
||||
* <p>The special value {@code "*"} allows all methods.
|
||||
* <p>By default "simple" methods {@code GET}, {@code HEAD}, and {@code POST}
|
||||
* are allowed.
|
||||
*/
|
||||
public CorsRegistration allowedMethods(String... methods) {
|
||||
this.config.setAllowedMethods(Arrays.asList(methods));
|
||||
|
|
@ -77,9 +77,9 @@ public class CorsRegistration {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the list of headers that a preflight request can list as allowed
|
||||
* for use during an actual request. The special value {@code "*"} may be
|
||||
* used to allow all headers.
|
||||
* Set the list of headers that a pre-flight request can list as allowed
|
||||
* for use during an actual request.
|
||||
* <p>The special value {@code "*"} may be used to allow all headers.
|
||||
* <p>A header name is not required to be listed if it is one of:
|
||||
* {@code Cache-Control}, {@code Content-Language}, {@code Expires},
|
||||
* {@code Last-Modified}, or {@code Pragma} as per the CORS spec.
|
||||
|
|
|
|||
|
|
@ -39,10 +39,8 @@ public class CorsRegistry {
|
|||
|
||||
/**
|
||||
* 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>By default, the {@code CorsConfiguration} for this mapping is
|
||||
* initialized with default values as described in
|
||||
* {@link CorsConfiguration#applyPermitDefaultValues()}.
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
|||
|
||||
private List<HttpMessageConverter<?>> messageConverters;
|
||||
|
||||
private List<Object> requestResponseBodyAdvice = new ArrayList<>();
|
||||
private final List<Object> requestResponseBodyAdvice = new ArrayList<>();
|
||||
|
||||
@Nullable
|
||||
private WebBindingInitializer webBindingInitializer;
|
||||
|
|
@ -632,7 +632,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
|||
* and custom resolvers provided via {@link #setCustomArgumentResolvers}.
|
||||
*/
|
||||
private List<HandlerMethodArgumentResolver> getDefaultArgumentResolvers() {
|
||||
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
|
||||
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>(30);
|
||||
|
||||
// Annotation-based argument resolution
|
||||
resolvers.add(new RequestParamMethodArgumentResolver(getBeanFactory(), false));
|
||||
|
|
@ -679,7 +679,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
|||
* methods including built-in and custom resolvers.
|
||||
*/
|
||||
private List<HandlerMethodArgumentResolver> getDefaultInitBinderArgumentResolvers() {
|
||||
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
|
||||
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>(20);
|
||||
|
||||
// Annotation-based argument resolution
|
||||
resolvers.add(new RequestParamMethodArgumentResolver(getBeanFactory(), false));
|
||||
|
|
@ -712,7 +712,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
|
|||
* custom handlers provided via {@link #setReturnValueHandlers}.
|
||||
*/
|
||||
private List<HandlerMethodReturnValueHandler> getDefaultReturnValueHandlers() {
|
||||
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<>();
|
||||
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<>(20);
|
||||
|
||||
// Single-purpose return value types
|
||||
handlers.add(new ModelAndViewMethodReturnValueHandler());
|
||||
|
|
|
|||
Loading…
Reference in New Issue