Polishing
This commit is contained in:
@@ -419,7 +419,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
|
||||
// Only check bean definition if it is complete.
|
||||
if (!mbd.isAbstract() && (allowEagerInit ||
|
||||
((mbd.hasBeanClass() || !mbd.isLazyInit() || isAllowEagerClassLoading())) &&
|
||||
(mbd.hasBeanClass() || !mbd.isLazyInit() || isAllowEagerClassLoading()) &&
|
||||
!requiresEagerInitForType(mbd.getFactoryBeanName()))) {
|
||||
// In case of FactoryBean, match object created by FactoryBean.
|
||||
boolean isFactoryBean = isFactoryBean(beanName, mbd);
|
||||
|
||||
@@ -402,8 +402,8 @@ public class BeanDefinitionParserDelegate {
|
||||
public BeanDefinitionDefaults getBeanDefinitionDefaults() {
|
||||
BeanDefinitionDefaults bdd = new BeanDefinitionDefaults();
|
||||
bdd.setLazyInit("TRUE".equalsIgnoreCase(this.defaults.getLazyInit()));
|
||||
bdd.setDependencyCheck(this.getDependencyCheck(DEFAULT_VALUE));
|
||||
bdd.setAutowireMode(this.getAutowireMode(DEFAULT_VALUE));
|
||||
bdd.setDependencyCheck(getDependencyCheck(DEFAULT_VALUE));
|
||||
bdd.setAutowireMode(getAutowireMode(DEFAULT_VALUE));
|
||||
bdd.setInitMethodName(this.defaults.getInitMethod());
|
||||
bdd.setDestroyMethodName(this.defaults.getDestroyMethod());
|
||||
return bdd;
|
||||
@@ -1255,7 +1255,7 @@ public class BeanDefinitionParserDelegate {
|
||||
boolean hasKeyAttribute = entryEle.hasAttribute(KEY_ATTRIBUTE);
|
||||
boolean hasKeyRefAttribute = entryEle.hasAttribute(KEY_REF_ATTRIBUTE);
|
||||
if ((hasKeyAttribute && hasKeyRefAttribute) ||
|
||||
((hasKeyAttribute || hasKeyRefAttribute)) && keyEle != null) {
|
||||
(hasKeyAttribute || hasKeyRefAttribute) && keyEle != null) {
|
||||
error("<entry> element is only allowed to contain either " +
|
||||
"a 'key' attribute OR a 'key-ref' attribute OR a <key> sub-element", entryEle);
|
||||
}
|
||||
@@ -1284,7 +1284,7 @@ public class BeanDefinitionParserDelegate {
|
||||
boolean hasValueRefAttribute = entryEle.hasAttribute(VALUE_REF_ATTRIBUTE);
|
||||
boolean hasValueTypeAttribute = entryEle.hasAttribute(VALUE_TYPE_ATTRIBUTE);
|
||||
if ((hasValueAttribute && hasValueRefAttribute) ||
|
||||
((hasValueAttribute || hasValueRefAttribute)) && valueEle != null) {
|
||||
(hasValueAttribute || hasValueRefAttribute) && valueEle != null) {
|
||||
error("<entry> element is only allowed to contain either " +
|
||||
"'value' attribute OR 'value-ref' attribute OR <value> sub-element", entryEle);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -355,7 +355,7 @@ public class ResolvableType implements Serializable {
|
||||
if (this == NONE) {
|
||||
return false;
|
||||
}
|
||||
return (((this.type instanceof Class && ((Class<?>) this.type).isArray())) ||
|
||||
return ((this.type instanceof Class && ((Class<?>) this.type).isArray()) ||
|
||||
this.type instanceof GenericArrayType || resolveType().isArray());
|
||||
}
|
||||
|
||||
@@ -1427,8 +1427,9 @@ public class ResolvableType implements Serializable {
|
||||
@Override
|
||||
public ResolvableType resolveVariable(TypeVariable<?> variable) {
|
||||
for (int i = 0; i < this.variables.length; i++) {
|
||||
if (SerializableTypeWrapper.unwrap(this.variables[i]).equals(
|
||||
SerializableTypeWrapper.unwrap(variable))) {
|
||||
TypeVariable<?> v1 = SerializableTypeWrapper.unwrap(this.variables[i]);
|
||||
TypeVariable<?> v2 = SerializableTypeWrapper.unwrap(variable);
|
||||
if (ObjectUtils.nullSafeEquals(v1, v2)) {
|
||||
return this.generics[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,7 +584,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
|
||||
Type typeArgument = parameterizedType.getActualTypeArguments()[0];
|
||||
if (typeArgument instanceof Class) {
|
||||
Class<?> classArgument = (Class<?>) typeArgument;
|
||||
return (((classArgument.isArray() && Byte.TYPE == classArgument.getComponentType())) ||
|
||||
return ((classArgument.isArray() && Byte.TYPE == classArgument.getComponentType()) ||
|
||||
isPrimitiveWrapper(classArgument) || isStandardClass(classArgument) ||
|
||||
supportsInternal(classArgument, false));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.test.context.support;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.springframework.test.context.ContextConfigurationAttributes;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Utility methods for working with {@link ApplicationContextInitializer
|
||||
* ApplicationContextInitializers}.
|
||||
* Utility methods for working with
|
||||
* {@link ApplicationContextInitializer ApplicationContextInitializers}.
|
||||
*
|
||||
* <p>Although {@code ApplicationContextInitializerUtils} was first introduced
|
||||
* in Spring Framework 4.1, the initial implementations of methods in this class
|
||||
@@ -47,21 +47,15 @@ abstract class ApplicationContextInitializerUtils {
|
||||
private static final Log logger = LogFactory.getLog(ApplicationContextInitializerUtils.class);
|
||||
|
||||
|
||||
private ApplicationContextInitializerUtils() {
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the set of merged {@code ApplicationContextInitializer} classes for the
|
||||
* supplied list of {@code ContextConfigurationAttributes}.
|
||||
*
|
||||
* <p>Note that the {@link ContextConfiguration#inheritInitializers inheritInitializers}
|
||||
* flag of {@link ContextConfiguration @ContextConfiguration} will be taken into
|
||||
* consideration. Specifically, if the {@code inheritInitializers} flag is set to
|
||||
* {@code true} for a given level in the class hierarchy represented by the provided
|
||||
* configuration attributes, context initializer classes defined at the given level
|
||||
* will be merged with those defined in higher levels of the class hierarchy.
|
||||
*
|
||||
* @param configAttributesList the list of configuration attributes to process; must
|
||||
* not be {@code null} or <em>empty</em>; must be ordered <em>bottom-up</em>
|
||||
* (i.e., as if we were traversing up the class hierarchy)
|
||||
@@ -71,19 +65,16 @@ abstract class ApplicationContextInitializerUtils {
|
||||
*/
|
||||
static Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> resolveInitializerClasses(
|
||||
List<ContextConfigurationAttributes> configAttributesList) {
|
||||
Assert.notEmpty(configAttributesList, "ContextConfigurationAttributes list must not be empty");
|
||||
|
||||
final Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> initializerClasses = //
|
||||
new HashSet<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>>();
|
||||
Assert.notEmpty(configAttributesList, "ContextConfigurationAttributes list must not be empty");
|
||||
Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> initializerClasses =
|
||||
new LinkedHashSet<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>>();
|
||||
|
||||
for (ContextConfigurationAttributes configAttributes : configAttributesList) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace(String.format("Processing context initializers for context configuration attributes %s",
|
||||
configAttributes));
|
||||
logger.trace("Processing context initializers for configuration attributes " + configAttributes);
|
||||
}
|
||||
|
||||
initializerClasses.addAll(Arrays.asList(configAttributes.getInitializers()));
|
||||
|
||||
if (!configAttributes.isInheritInitializers()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -68,6 +68,7 @@ public final class HostRequestMatcher implements WebRequestMatcher {
|
||||
this.hosts.addAll(Arrays.asList(hosts));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(WebRequest request) {
|
||||
URL url = request.getUrl();
|
||||
|
||||
@@ -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.
|
||||
@@ -59,9 +59,9 @@ public class SessionAttributesHandler {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance for a controller type. Session attribute names and
|
||||
* types are extracted from the {@code @SessionAttributes} annotation, if
|
||||
* present, on the given type.
|
||||
* Create a new session attributes handler. Session attribute names and types
|
||||
* are extracted from the {@code @SessionAttributes} annotation, if present,
|
||||
* on the given type.
|
||||
* @param handlerType the controller type
|
||||
* @param sessionAttributeStore used for session access
|
||||
*/
|
||||
@@ -69,15 +69,15 @@ public class SessionAttributesHandler {
|
||||
Assert.notNull(sessionAttributeStore, "SessionAttributeStore may not be null");
|
||||
this.sessionAttributeStore = sessionAttributeStore;
|
||||
|
||||
SessionAttributes annotation =
|
||||
AnnotatedElementUtils.findMergedAnnotation(handlerType, SessionAttributes.class);
|
||||
if (annotation != null) {
|
||||
this.attributeNames.addAll(Arrays.asList(annotation.names()));
|
||||
this.attributeTypes.addAll(Arrays.asList(annotation.types()));
|
||||
SessionAttributes ann = AnnotatedElementUtils.findMergedAnnotation(handlerType, SessionAttributes.class);
|
||||
if (ann != null) {
|
||||
this.attributeNames.addAll(Arrays.asList(ann.names()));
|
||||
this.attributeTypes.addAll(Arrays.asList(ann.types()));
|
||||
}
|
||||
this.knownAttributeNames.addAll(this.attributeNames);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the controller represented by this instance has declared any
|
||||
* session attributes through an {@link SessionAttributes} annotation.
|
||||
|
||||
Reference in New Issue
Block a user