Polishing
This commit is contained in:
parent
ac1e2879e5
commit
0480e75785
|
|
@ -813,22 +813,22 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
}
|
}
|
||||||
else if (oldBeanDefinition.getRole() < beanDefinition.getRole()) {
|
else if (oldBeanDefinition.getRole() < beanDefinition.getRole()) {
|
||||||
// e.g. was ROLE_APPLICATION, now overriding with ROLE_SUPPORT or ROLE_INFRASTRUCTURE
|
// e.g. was ROLE_APPLICATION, now overriding with ROLE_SUPPORT or ROLE_INFRASTRUCTURE
|
||||||
if (this.logger.isWarnEnabled()) {
|
if (logger.isWarnEnabled()) {
|
||||||
this.logger.warn("Overriding user-defined bean definition for bean '" + beanName +
|
logger.warn("Overriding user-defined bean definition for bean '" + beanName +
|
||||||
"' with a framework-generated bean definition: replacing [" +
|
"' with a framework-generated bean definition: replacing [" +
|
||||||
oldBeanDefinition + "] with [" + beanDefinition + "]");
|
oldBeanDefinition + "] with [" + beanDefinition + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!beanDefinition.equals(oldBeanDefinition)) {
|
else if (!beanDefinition.equals(oldBeanDefinition)) {
|
||||||
if (this.logger.isInfoEnabled()) {
|
if (logger.isInfoEnabled()) {
|
||||||
this.logger.info("Overriding bean definition for bean '" + beanName +
|
logger.info("Overriding bean definition for bean '" + beanName +
|
||||||
"' with a different definition: replacing [" + oldBeanDefinition +
|
"' with a different definition: replacing [" + oldBeanDefinition +
|
||||||
"] with [" + beanDefinition + "]");
|
"] with [" + beanDefinition + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
this.logger.debug("Overriding bean definition for bean '" + beanName +
|
logger.debug("Overriding bean definition for bean '" + beanName +
|
||||||
"' with an equivalent definition: replacing [" + oldBeanDefinition +
|
"' with an equivalent definition: replacing [" + oldBeanDefinition +
|
||||||
"] with [" + beanDefinition + "]");
|
"] with [" + beanDefinition + "]");
|
||||||
}
|
}
|
||||||
|
|
@ -871,8 +871,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
|
|
||||||
BeanDefinition bd = this.beanDefinitionMap.remove(beanName);
|
BeanDefinition bd = this.beanDefinitionMap.remove(beanName);
|
||||||
if (bd == null) {
|
if (bd == null) {
|
||||||
if (this.logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
this.logger.trace("No bean named '" + beanName + "' found in " + this);
|
logger.trace("No bean named '" + beanName + "' found in " + this);
|
||||||
}
|
}
|
||||||
throw new NoSuchBeanDefinitionException(beanName);
|
throw new NoSuchBeanDefinitionException(beanName);
|
||||||
}
|
}
|
||||||
|
|
@ -1656,7 +1656,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
return createOptionalDependency(this.descriptor, this.beanName, args);
|
return createOptionalDependency(this.descriptor, this.beanName, args);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DependencyDescriptor descriptorToUse = new DependencyDescriptor(descriptor) {
|
DependencyDescriptor descriptorToUse = new DependencyDescriptor(this.descriptor) {
|
||||||
@Override
|
@Override
|
||||||
public Object resolveCandidate(String beanName, Class<?> requiredType, BeanFactory beanFactory) {
|
public Object resolveCandidate(String beanName, Class<?> requiredType, BeanFactory beanFactory) {
|
||||||
return beanFactory.getBean(beanName, args);
|
return beanFactory.getBean(beanName, args);
|
||||||
|
|
@ -1677,7 +1677,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
return createOptionalDependency(this.descriptor, this.beanName);
|
return createOptionalDependency(this.descriptor, this.beanName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DependencyDescriptor descriptorToUse = new DependencyDescriptor(descriptor) {
|
DependencyDescriptor descriptorToUse = new DependencyDescriptor(this.descriptor) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isRequired() {
|
public boolean isRequired() {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1690,7 +1690,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Object getIfUnique() throws BeansException {
|
public Object getIfUnique() throws BeansException {
|
||||||
DependencyDescriptor descriptorToUse = new DependencyDescriptor(descriptor) {
|
DependencyDescriptor descriptorToUse = new DependencyDescriptor(this.descriptor) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isRequired() {
|
public boolean isRequired() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -86,7 +86,7 @@ public abstract class GenericTypeResolver {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Class<?> resolveReturnTypeArgument(Method method, Class<?> genericIfc) {
|
public static Class<?> resolveReturnTypeArgument(Method method, Class<?> genericIfc) {
|
||||||
Assert.notNull(method, "method must not be null");
|
Assert.notNull(method, "Method must not be null");
|
||||||
ResolvableType resolvableType = ResolvableType.forMethodReturnType(method).as(genericIfc);
|
ResolvableType resolvableType = ResolvableType.forMethodReturnType(method).as(genericIfc);
|
||||||
if (!resolvableType.hasGenerics() || resolvableType.getType() instanceof WildcardType) {
|
if (!resolvableType.hasGenerics() || resolvableType.getType() instanceof WildcardType) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -31,7 +31,6 @@ import java.lang.reflect.TypeVariable;
|
||||||
import java.lang.reflect.WildcardType;
|
import java.lang.reflect.WildcardType;
|
||||||
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
|
||||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
@ -69,7 +68,6 @@ abstract class SerializableTypeWrapper {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Type forField(Field field) {
|
public static Type forField(Field field) {
|
||||||
Assert.notNull(field, "Field must not be null");
|
|
||||||
return forTypeProvider(new FieldTypeProvider(field));
|
return forTypeProvider(new FieldTypeProvider(field));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,21 +133,20 @@ abstract class SerializableTypeWrapper {
|
||||||
* Return a {@link Serializable} {@link Type} backed by a {@link TypeProvider} .
|
* Return a {@link Serializable} {@link Type} backed by a {@link TypeProvider} .
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
static Type forTypeProvider(final TypeProvider provider) {
|
static Type forTypeProvider(TypeProvider provider) {
|
||||||
Assert.notNull(provider, "Provider must not be null");
|
|
||||||
Type providedType = provider.getType();
|
Type providedType = provider.getType();
|
||||||
if (providedType == null) {
|
if (providedType == null || providedType instanceof Serializable) {
|
||||||
return null;
|
// No serializable type wrapping necessary (e.g. for java.lang.Class)
|
||||||
}
|
|
||||||
if (providedType instanceof Serializable) {
|
|
||||||
return providedType;
|
return providedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtain a serializable type proxy for the given provider...
|
||||||
Type cached = cache.get(providedType);
|
Type cached = cache.get(providedType);
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
for (Class<?> type : SUPPORTED_SERIALIZABLE_TYPES) {
|
for (Class<?> type : SUPPORTED_SERIALIZABLE_TYPES) {
|
||||||
if (type.isAssignableFrom(providedType.getClass())) {
|
if (type.isInstance(providedType)) {
|
||||||
ClassLoader classLoader = provider.getClass().getClassLoader();
|
ClassLoader classLoader = provider.getClass().getClassLoader();
|
||||||
Class<?>[] interfaces = new Class<?>[] {type, SerializableTypeProxy.class, Serializable.class};
|
Class<?>[] interfaces = new Class<?>[] {type, SerializableTypeProxy.class, Serializable.class};
|
||||||
InvocationHandler handler = new TypeProxyInvocationHandler(provider);
|
InvocationHandler handler = new TypeProxyInvocationHandler(provider);
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ public class SimpleAliasRegistry implements AliasRegistry {
|
||||||
throw new IllegalStateException("Cannot define alias '" + alias + "' for name '" +
|
throw new IllegalStateException("Cannot define alias '" + alias + "' for name '" +
|
||||||
name + "': It is already registered for name '" + registeredName + "'.");
|
name + "': It is already registered for name '" + registeredName + "'.");
|
||||||
}
|
}
|
||||||
if (this.logger.isInfoEnabled()) {
|
if (logger.isInfoEnabled()) {
|
||||||
logger.info("Overriding alias '" + alias + "' definition for registered name '" +
|
logger.info("Overriding alias '" + alias + "' definition for registered name '" +
|
||||||
registeredName + "' with new target name '" + name + "'");
|
registeredName + "' with new target name '" + name + "'");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
*/
|
*/
|
||||||
public static final String CONTENT_ENCODING = "Content-Encoding";
|
public static final String CONTENT_ENCODING = "Content-Encoding";
|
||||||
/**
|
/**
|
||||||
* The HTTP {@code Content-Disposition} header field name
|
* The HTTP {@code Content-Disposition} header field name.
|
||||||
* @see <a href="http://tools.ietf.org/html/rfc6266">RFC 6266</a>
|
* @see <a href="http://tools.ietf.org/html/rfc6266">RFC 6266</a>
|
||||||
*/
|
*/
|
||||||
public static final String CONTENT_DISPOSITION = "Content-Disposition";
|
public static final String CONTENT_DISPOSITION = "Content-Disposition";
|
||||||
|
|
@ -378,7 +378,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
|
public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match"
|
* Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match".
|
||||||
* @see <a href="https://tools.ietf.org/html/rfc7232#section-2.3">Section 2.3 of RFC 7232</a>
|
* @see <a href="https://tools.ietf.org/html/rfc7232#section-2.3">Section 2.3 of RFC 7232</a>
|
||||||
*/
|
*/
|
||||||
private static final Pattern ETAG_HEADER_VALUE_PATTERN = Pattern.compile("\\*|\\s*((W\\/)?(\"[^\"]*\"))\\s*,?");
|
private static final Pattern ETAG_HEADER_VALUE_PATTERN = Pattern.compile("\\*|\\s*((W\\/)?(\"[^\"]*\"))\\s*,?");
|
||||||
|
|
@ -388,7 +388,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
private static final ZoneId GMT = ZoneId.of("GMT");
|
private static final ZoneId GMT = ZoneId.of("GMT");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date formats with time zone as specified in the HTTP RFC
|
* Date formats with time zone as specified in the HTTP RFC.
|
||||||
* @see <a href="https://tools.ietf.org/html/rfc7231#section-7.1.1.1">Section 7.1.1.1 of RFC 7231</a>
|
* @see <a href="https://tools.ietf.org/html/rfc7231#section-7.1.1.1">Section 7.1.1.1 of RFC 7231</a>
|
||||||
*/
|
*/
|
||||||
private static final DateTimeFormatter[] DATE_FORMATTERS = new DateTimeFormatter[] {
|
private static final DateTimeFormatter[] DATE_FORMATTERS = new DateTimeFormatter[] {
|
||||||
|
|
@ -1281,7 +1281,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
* {@link IllegalArgumentException} ({@code true}) or rather return {@code null}
|
* {@link IllegalArgumentException} ({@code true}) or rather return {@code null}
|
||||||
* in that case ({@code false})
|
* in that case ({@code false})
|
||||||
* @return the parsed date header, or {@code null} if none (or invalid)
|
* @return the parsed date header, or {@code null} if none (or invalid)
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
private ZonedDateTime getFirstZonedDateTime(String headerName, boolean rejectInvalid) {
|
private ZonedDateTime getFirstZonedDateTime(String headerName, boolean rejectInvalid) {
|
||||||
String headerValue = getFirst(headerName);
|
String headerValue = getFirst(headerName);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue