@Nullable all the way: null-safety at field level
This commits extends nullability declarations to the field level, formalizing the interaction between methods and their underlying fields and therefore avoiding any nullability mismatch. Issue: SPR-15720
This commit is contained in:
@@ -78,15 +78,16 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
|
||||
private int autoGrowCollectionLimit = Integer.MAX_VALUE;
|
||||
|
||||
@Nullable
|
||||
Object wrappedObject;
|
||||
|
||||
private String nestedPath = "";
|
||||
|
||||
@Nullable
|
||||
Object rootObject;
|
||||
|
||||
/**
|
||||
* Map with cached nested Accessors: nested path -> Accessor instance.
|
||||
*/
|
||||
/** Map with cached nested Accessors: nested path -> Accessor instance */
|
||||
@Nullable
|
||||
private Map<String, AbstractNestablePropertyAccessor> nestedPropertyAccessors;
|
||||
|
||||
|
||||
@@ -199,7 +200,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
}
|
||||
|
||||
public final Object getWrappedInstance() {
|
||||
Assert.state(this.wrappedObject != null, "No wrapped instance");
|
||||
Assert.state(this.wrappedObject != null, "No wrapped object");
|
||||
return this.wrappedObject;
|
||||
}
|
||||
|
||||
@@ -218,8 +219,8 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
* Return the root object at the top of the path of this accessor.
|
||||
* @see #getNestedPath
|
||||
*/
|
||||
@Nullable
|
||||
public final Object getRootInstance() {
|
||||
Assert.state(this.rootObject != null, "No root object");
|
||||
return this.rootObject;
|
||||
}
|
||||
|
||||
@@ -228,8 +229,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
* @see #getNestedPath
|
||||
*/
|
||||
public final Class<?> getRootClass() {
|
||||
Assert.state(this.wrappedObject != null, "No root object");
|
||||
return this.rootObject.getClass();
|
||||
return getRootInstance().getClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -287,6 +287,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
throw new InvalidPropertyException(
|
||||
getRootClass(), this.nestedPath + tokens.actualName, "No property handler found");
|
||||
}
|
||||
Assert.state(tokens.keys != null, "No token keys");
|
||||
String lastKey = tokens.keys[tokens.keys.length - 1];
|
||||
|
||||
if (propValue.getClass().isArray()) {
|
||||
@@ -379,9 +380,9 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
|
||||
private Object getPropertyHoldingValue(PropertyTokenHolder tokens) {
|
||||
// Apply indexes and map keys: fetch value for all keys but the last one.
|
||||
PropertyTokenHolder getterTokens = new PropertyTokenHolder();
|
||||
Assert.state(tokens.keys != null, "No token keys");
|
||||
PropertyTokenHolder getterTokens = new PropertyTokenHolder(tokens.actualName);
|
||||
getterTokens.canonicalName = tokens.canonicalName;
|
||||
getterTokens.actualName = tokens.actualName;
|
||||
getterTokens.keys = new String[tokens.keys.length - 1];
|
||||
System.arraycopy(tokens.keys, 0, getterTokens.keys, 0, tokens.keys.length - 1);
|
||||
|
||||
@@ -461,7 +462,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
}
|
||||
catch (InvocationTargetException ex) {
|
||||
PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent(
|
||||
this.rootObject, this.nestedPath + tokens.canonicalName, oldValue, pv.getValue());
|
||||
getRootInstance(), this.nestedPath + tokens.canonicalName, oldValue, pv.getValue());
|
||||
if (ex.getTargetException() instanceof ClassCastException) {
|
||||
throw new TypeMismatchException(propertyChangeEvent, ph.getPropertyType(), ex.getTargetException());
|
||||
}
|
||||
@@ -476,7 +477,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
}
|
||||
catch (Exception ex) {
|
||||
PropertyChangeEvent pce = new PropertyChangeEvent(
|
||||
this.rootObject, this.nestedPath + tokens.canonicalName, oldValue, pv.getValue());
|
||||
getRootInstance(), this.nestedPath + tokens.canonicalName, oldValue, pv.getValue());
|
||||
throw new MethodInvocationException(pce, ex);
|
||||
}
|
||||
}
|
||||
@@ -582,12 +583,12 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
}
|
||||
catch (ConverterNotFoundException | IllegalStateException ex) {
|
||||
PropertyChangeEvent pce =
|
||||
new PropertyChangeEvent(this.rootObject, this.nestedPath + propertyName, oldValue, newValue);
|
||||
new PropertyChangeEvent(getRootInstance(), this.nestedPath + propertyName, oldValue, newValue);
|
||||
throw new ConversionNotSupportedException(pce, requiredType, ex);
|
||||
}
|
||||
catch (ConversionException | IllegalArgumentException ex) {
|
||||
PropertyChangeEvent pce =
|
||||
new PropertyChangeEvent(this.rootObject, this.nestedPath + propertyName, oldValue, newValue);
|
||||
new PropertyChangeEvent(getRootInstance(), this.nestedPath + propertyName, oldValue, newValue);
|
||||
throw new TypeMismatchException(pce, requiredType, ex);
|
||||
}
|
||||
}
|
||||
@@ -621,7 +622,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
if (tokens.keys != null) {
|
||||
if (value == null) {
|
||||
if (isAutoGrowNestedPaths()) {
|
||||
value = setDefaultValue(tokens.actualName);
|
||||
value = setDefaultValue(new PropertyTokenHolder(tokens.actualName));
|
||||
}
|
||||
else {
|
||||
throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + propertyName,
|
||||
@@ -865,13 +866,6 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
return nestedPa;
|
||||
}
|
||||
|
||||
private Object setDefaultValue(String propertyName) {
|
||||
PropertyTokenHolder tokens = new PropertyTokenHolder();
|
||||
tokens.actualName = propertyName;
|
||||
tokens.canonicalName = propertyName;
|
||||
return setDefaultValue(tokens);
|
||||
}
|
||||
|
||||
private Object setDefaultValue(PropertyTokenHolder tokens) {
|
||||
PropertyValue pv = createDefaultPropertyValue(tokens);
|
||||
setPropertyValue(tokens, pv);
|
||||
@@ -932,7 +926,6 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
* @return representation of the parsed property tokens
|
||||
*/
|
||||
private PropertyTokenHolder getPropertyNameTokens(String propertyName) {
|
||||
PropertyTokenHolder tokens = new PropertyTokenHolder();
|
||||
String actualName = null;
|
||||
List<String> keys = new ArrayList<>(2);
|
||||
int searchIndex = 0;
|
||||
@@ -955,8 +948,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
}
|
||||
}
|
||||
}
|
||||
tokens.actualName = (actualName != null ? actualName : propertyName);
|
||||
tokens.canonicalName = tokens.actualName;
|
||||
PropertyTokenHolder tokens = new PropertyTokenHolder(actualName != null ? actualName : propertyName);
|
||||
if (!keys.isEmpty()) {
|
||||
tokens.canonicalName += PROPERTY_KEY_PREFIX +
|
||||
StringUtils.collectionToDelimitedString(keys, PROPERTY_KEY_SUFFIX + PROPERTY_KEY_PREFIX) +
|
||||
@@ -1036,10 +1028,16 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
|
||||
protected static class PropertyTokenHolder {
|
||||
|
||||
public String canonicalName;
|
||||
public PropertyTokenHolder(String name) {
|
||||
this.actualName = name;
|
||||
this.canonicalName = name;
|
||||
}
|
||||
|
||||
public String actualName;
|
||||
|
||||
public String canonicalName;
|
||||
|
||||
@Nullable
|
||||
public String[] keys;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,10 @@ public class BeanMetadataAttribute implements BeanMetadataElement {
|
||||
|
||||
private final String name;
|
||||
|
||||
@Nullable
|
||||
private final Object value;
|
||||
|
||||
@Nullable
|
||||
private Object source;
|
||||
|
||||
|
||||
@@ -58,6 +60,7 @@ public class BeanMetadataAttribute implements BeanMetadataElement {
|
||||
/**
|
||||
* Return the value of the attribute.
|
||||
*/
|
||||
@Nullable
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
@@ -71,6 +74,7 @@ public class BeanMetadataAttribute implements BeanMetadataElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -30,6 +30,7 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class BeanMetadataAttributeAccessor extends AttributeAccessorSupport implements BeanMetadataElement {
|
||||
|
||||
@Nullable
|
||||
private Object source;
|
||||
|
||||
|
||||
@@ -42,6 +43,7 @@ public class BeanMetadataAttributeAccessor extends AttributeAccessorSupport impl
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@@ -499,7 +499,9 @@ public abstract class BeanUtils {
|
||||
return new MethodParameter(((GenericTypeAwarePropertyDescriptor) pd).getWriteMethodParameter());
|
||||
}
|
||||
else {
|
||||
return new MethodParameter(pd.getWriteMethod(), 0);
|
||||
Method writeMethod = pd.getWriteMethod();
|
||||
Assert.state(writeMethod != null, "No write method available");
|
||||
return new MethodParameter(writeMethod, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,11 +66,13 @@ public class BeanWrapperImpl extends AbstractNestablePropertyAccessor implements
|
||||
* Cached introspections results for this object, to prevent encountering
|
||||
* the cost of JavaBeans introspection every time.
|
||||
*/
|
||||
@Nullable
|
||||
private CachedIntrospectionResults cachedIntrospectionResults;
|
||||
|
||||
/**
|
||||
* The security context used for invoking the property methods
|
||||
*/
|
||||
@Nullable
|
||||
private AccessControlContext acc;
|
||||
|
||||
|
||||
@@ -178,7 +180,7 @@ public class BeanWrapperImpl extends AbstractNestablePropertyAccessor implements
|
||||
* Set the security context used during the invocation of the wrapped instance methods.
|
||||
* Can be null.
|
||||
*/
|
||||
public void setSecurityContext(AccessControlContext acc) {
|
||||
public void setSecurityContext(@Nullable AccessControlContext acc) {
|
||||
this.acc = acc;
|
||||
}
|
||||
|
||||
@@ -186,6 +188,7 @@ public class BeanWrapperImpl extends AbstractNestablePropertyAccessor implements
|
||||
* Return the security context used during the invocation of the wrapped instance methods.
|
||||
* Can be null.
|
||||
*/
|
||||
@Nullable
|
||||
public AccessControlContext getSecurityContext() {
|
||||
return this.acc;
|
||||
}
|
||||
|
||||
@@ -261,12 +261,16 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
|
||||
static class SimplePropertyDescriptor extends PropertyDescriptor {
|
||||
|
||||
@Nullable
|
||||
private Method readMethod;
|
||||
|
||||
@Nullable
|
||||
private Method writeMethod;
|
||||
|
||||
@Nullable
|
||||
private Class<?> propertyType;
|
||||
|
||||
@Nullable
|
||||
private Class<?> propertyEditorClass;
|
||||
|
||||
public SimplePropertyDescriptor(PropertyDescriptor original) throws IntrospectionException {
|
||||
@@ -282,6 +286,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Method getReadMethod() {
|
||||
return this.readMethod;
|
||||
}
|
||||
@@ -292,6 +297,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Method getWriteMethod() {
|
||||
return this.writeMethod;
|
||||
}
|
||||
@@ -315,6 +321,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?> getPropertyEditorClass() {
|
||||
return this.propertyEditorClass;
|
||||
}
|
||||
@@ -345,18 +352,25 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
|
||||
static class SimpleIndexedPropertyDescriptor extends IndexedPropertyDescriptor {
|
||||
|
||||
@Nullable
|
||||
private Method readMethod;
|
||||
|
||||
@Nullable
|
||||
private Method writeMethod;
|
||||
|
||||
@Nullable
|
||||
private Class<?> propertyType;
|
||||
|
||||
@Nullable
|
||||
private Method indexedReadMethod;
|
||||
|
||||
@Nullable
|
||||
private Method indexedWriteMethod;
|
||||
|
||||
@Nullable
|
||||
private Class<?> indexedPropertyType;
|
||||
|
||||
@Nullable
|
||||
private Class<?> propertyEditorClass;
|
||||
|
||||
public SimpleIndexedPropertyDescriptor(IndexedPropertyDescriptor original) throws IntrospectionException {
|
||||
@@ -379,6 +393,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Method getReadMethod() {
|
||||
return this.readMethod;
|
||||
}
|
||||
@@ -389,6 +404,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Method getWriteMethod() {
|
||||
return this.writeMethod;
|
||||
}
|
||||
@@ -412,6 +428,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Method getIndexedReadMethod() {
|
||||
return this.indexedReadMethod;
|
||||
}
|
||||
@@ -422,6 +439,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Method getIndexedWriteMethod() {
|
||||
return this.indexedWriteMethod;
|
||||
}
|
||||
@@ -446,6 +464,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?> getPropertyEditorClass() {
|
||||
return this.propertyEditorClass;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.core.BridgeMethodResolver;
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -44,14 +45,19 @@ final class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor {
|
||||
|
||||
private final Class<?> beanClass;
|
||||
|
||||
@Nullable
|
||||
private final Method readMethod;
|
||||
|
||||
@Nullable
|
||||
private final Method writeMethod;
|
||||
|
||||
@Nullable
|
||||
private volatile Set<Method> ambiguousWriteMethods;
|
||||
|
||||
@Nullable
|
||||
private MethodParameter writeMethodParameter;
|
||||
|
||||
@Nullable
|
||||
private Class<?> propertyType;
|
||||
|
||||
private final Class<?> propertyEditorClass;
|
||||
@@ -116,16 +122,19 @@ final class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Method getReadMethod() {
|
||||
return this.readMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Method getWriteMethod() {
|
||||
return this.writeMethod;
|
||||
}
|
||||
|
||||
public Method getWriteMethodForActualAccess() {
|
||||
Assert.state(this.writeMethod != null, "No write method available");
|
||||
Set<Method> ambiguousCandidates = this.ambiguousWriteMethods;
|
||||
if (ambiguousCandidates != null) {
|
||||
this.ambiguousWriteMethods = null;
|
||||
@@ -137,10 +146,12 @@ final class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor {
|
||||
}
|
||||
|
||||
public MethodParameter getWriteMethodParameter() {
|
||||
Assert.state(this.writeMethodParameter != null, "No write method available");
|
||||
return this.writeMethodParameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Class<?> getPropertyType() {
|
||||
return this.propertyType;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
|
||||
|
||||
private final List<PropertyValue> propertyValueList;
|
||||
|
||||
@Nullable
|
||||
private Set<String> processedProperties;
|
||||
|
||||
private volatile boolean converted = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -29,7 +29,8 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class NotWritablePropertyException extends InvalidPropertyException {
|
||||
|
||||
private String[] possibleMatches = null;
|
||||
@Nullable
|
||||
private String[] possibleMatches;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class PropertyAccessException extends BeansException {
|
||||
|
||||
@Nullable
|
||||
private transient PropertyChangeEvent propertyChangeEvent;
|
||||
|
||||
|
||||
|
||||
@@ -91,20 +91,26 @@ import org.springframework.util.ClassUtils;
|
||||
*/
|
||||
public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
|
||||
@Nullable
|
||||
private ConversionService conversionService;
|
||||
|
||||
private boolean defaultEditorsActive = false;
|
||||
|
||||
private boolean configValueEditorsActive = false;
|
||||
|
||||
@Nullable
|
||||
private Map<Class<?>, PropertyEditor> defaultEditors;
|
||||
|
||||
@Nullable
|
||||
private Map<Class<?>, PropertyEditor> overriddenDefaultEditors;
|
||||
|
||||
@Nullable
|
||||
private Map<Class<?>, PropertyEditor> customEditors;
|
||||
|
||||
@Nullable
|
||||
private Map<String, CustomEditorHolder> customEditorsForPath;
|
||||
|
||||
@Nullable
|
||||
private Map<Class<?>, PropertyEditor> customEditorCache;
|
||||
|
||||
|
||||
@@ -378,7 +384,8 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
*/
|
||||
@Nullable
|
||||
private PropertyEditor getCustomEditor(String propertyName, @Nullable Class<?> requiredType) {
|
||||
CustomEditorHolder holder = this.customEditorsForPath.get(propertyName);
|
||||
CustomEditorHolder holder =
|
||||
(this.customEditorsForPath != null ? this.customEditorsForPath.get(propertyName) : null);
|
||||
return (holder != null ? holder.getPropertyEditor(requiredType) : null);
|
||||
}
|
||||
|
||||
@@ -517,6 +524,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
|
||||
private final PropertyEditor propertyEditor;
|
||||
|
||||
@Nullable
|
||||
private final Class<?> registeredType;
|
||||
|
||||
private CustomEditorHolder(PropertyEditor propertyEditor, @Nullable Class<?> registeredType) {
|
||||
|
||||
@@ -44,18 +44,22 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri
|
||||
|
||||
private final String name;
|
||||
|
||||
@Nullable
|
||||
private final Object value;
|
||||
|
||||
private boolean optional = false;
|
||||
|
||||
private boolean converted = false;
|
||||
|
||||
@Nullable
|
||||
private Object convertedValue;
|
||||
|
||||
/** Package-visible field that indicates whether conversion is necessary */
|
||||
@Nullable
|
||||
volatile Boolean conversionNecessary;
|
||||
|
||||
/** Package-visible field for caching the resolved property path tokens */
|
||||
@Nullable
|
||||
transient volatile Object resolvedTokens;
|
||||
|
||||
|
||||
@@ -177,6 +181,7 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri
|
||||
* Return the converted value of the constructor argument,
|
||||
* after processed type conversion.
|
||||
*/
|
||||
@Nullable
|
||||
public synchronized Object getConvertedValue() {
|
||||
return this.convertedValue;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +59,7 @@ class TypeConverterDelegate {
|
||||
|
||||
private final PropertyEditorRegistrySupport propertyEditorRegistry;
|
||||
|
||||
@Nullable
|
||||
private final Object targetObject;
|
||||
|
||||
|
||||
@@ -314,7 +315,7 @@ class TypeConverterDelegate {
|
||||
private Object attemptToConvertStringToEnum(Class<?> requiredType, String trimmedValue, Object currentConvertedValue) {
|
||||
Object convertedValue = currentConvertedValue;
|
||||
|
||||
if (Enum.class == requiredType) {
|
||||
if (Enum.class == requiredType && this.targetObject != null) {
|
||||
// target type is declared as raw enum, treat the trimmed value as <enum.fqn>.FIELD_NAME
|
||||
int index = trimmedValue.lastIndexOf(".");
|
||||
if (index > - 1) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -36,8 +36,10 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||
public static final String ERROR_CODE = "typeMismatch";
|
||||
|
||||
|
||||
@Nullable
|
||||
private transient Object value;
|
||||
|
||||
@Nullable
|
||||
private Class<?> requiredType;
|
||||
|
||||
|
||||
@@ -99,6 +101,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||
* Return the offending value (may be {@code null}).
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@@ -34,10 +34,13 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class BeanCreationException extends FatalBeanException {
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
|
||||
@Nullable
|
||||
private String resourceDescription;
|
||||
|
||||
@Nullable
|
||||
private List<Throwable> relatedCauses;
|
||||
|
||||
|
||||
@@ -119,6 +122,7 @@ public class BeanCreationException extends FatalBeanException {
|
||||
/**
|
||||
* Return the name of the bean requested, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String getBeanName() {
|
||||
return this.beanName;
|
||||
}
|
||||
|
||||
@@ -30,8 +30,10 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class BeanDefinitionStoreException extends FatalBeanException {
|
||||
|
||||
@Nullable
|
||||
private String resourceDescription;
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
|
||||
|
||||
|
||||
@@ -29,10 +29,13 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class CannotLoadBeanClassException extends FatalBeanException {
|
||||
|
||||
@Nullable
|
||||
private String resourceDescription;
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
|
||||
@Nullable
|
||||
private String beanClassName;
|
||||
|
||||
|
||||
@@ -78,6 +81,7 @@ public class CannotLoadBeanClassException extends FatalBeanException {
|
||||
* Return the description of the resource that the bean
|
||||
* definition came from.
|
||||
*/
|
||||
@Nullable
|
||||
public String getResourceDescription() {
|
||||
return this.resourceDescription;
|
||||
}
|
||||
@@ -85,6 +89,7 @@ public class CannotLoadBeanClassException extends FatalBeanException {
|
||||
/**
|
||||
* Return the name of the bean requested.
|
||||
*/
|
||||
@Nullable
|
||||
public String getBeanName() {
|
||||
return this.beanName;
|
||||
}
|
||||
@@ -92,6 +97,7 @@ public class CannotLoadBeanClassException extends FatalBeanException {
|
||||
/**
|
||||
* Return the name of the class we were trying to load.
|
||||
*/
|
||||
@Nullable
|
||||
public String getBeanClassName() {
|
||||
return this.beanClassName;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.lang.reflect.Member;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* A simple descriptor for an injection point, pointing to a method/constructor
|
||||
@@ -36,10 +37,13 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class InjectionPoint {
|
||||
|
||||
@Nullable
|
||||
protected MethodParameter methodParameter;
|
||||
|
||||
@Nullable
|
||||
protected Field field;
|
||||
|
||||
@Nullable
|
||||
private volatile Annotation[] fieldAnnotations;
|
||||
|
||||
|
||||
@@ -99,18 +103,31 @@ public class InjectionPoint {
|
||||
return this.field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the wrapped MethodParameter, assuming it is present.
|
||||
* @return the MethodParameter (never {@code null})
|
||||
* @throws IllegalStateException if no MethodParameter is available
|
||||
* @since 5.0
|
||||
*/
|
||||
protected final MethodParameter obtainMethodParameter() {
|
||||
Assert.state(this.methodParameter != null, "Neither Field nor MethodParameter");
|
||||
return this.methodParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the annotations associated with the wrapped field or method/constructor parameter.
|
||||
*/
|
||||
public Annotation[] getAnnotations() {
|
||||
if (this.field != null) {
|
||||
if (this.fieldAnnotations == null) {
|
||||
this.fieldAnnotations = this.field.getAnnotations();
|
||||
Annotation[] fieldAnnotations = this.fieldAnnotations;
|
||||
if (fieldAnnotations == null) {
|
||||
fieldAnnotations = this.field.getAnnotations();
|
||||
this.fieldAnnotations = fieldAnnotations;
|
||||
}
|
||||
return this.fieldAnnotations;
|
||||
return fieldAnnotations;
|
||||
}
|
||||
else {
|
||||
return this.methodParameter.getParameterAnnotations();
|
||||
return obtainMethodParameter().getParameterAnnotations();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +140,7 @@ public class InjectionPoint {
|
||||
@Nullable
|
||||
public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
|
||||
return (this.field != null ? this.field.getAnnotation(annotationType) :
|
||||
this.methodParameter.getParameterAnnotation(annotationType));
|
||||
obtainMethodParameter().getParameterAnnotation(annotationType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +148,7 @@ public class InjectionPoint {
|
||||
* indicating the injection type.
|
||||
*/
|
||||
public Class<?> getDeclaredType() {
|
||||
return (this.field != null ? this.field.getType() : this.methodParameter.getParameterType());
|
||||
return (this.field != null ? this.field.getType() : obtainMethodParameter().getParameterType());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +156,7 @@ public class InjectionPoint {
|
||||
* @return the Field / Method / Constructor as Member
|
||||
*/
|
||||
public Member getMember() {
|
||||
return (this.field != null ? this.field : this.methodParameter.getMember());
|
||||
return (this.field != null ? this.field : obtainMethodParameter().getMember());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +169,7 @@ public class InjectionPoint {
|
||||
* @return the Field / Method / Constructor as AnnotatedElement
|
||||
*/
|
||||
public AnnotatedElement getAnnotatedElement() {
|
||||
return (this.field != null ? this.field : this.methodParameter.getAnnotatedElement());
|
||||
return (this.field != null ? this.field : obtainMethodParameter().getAnnotatedElement());
|
||||
}
|
||||
|
||||
|
||||
@@ -165,18 +182,18 @@ public class InjectionPoint {
|
||||
return false;
|
||||
}
|
||||
InjectionPoint otherPoint = (InjectionPoint) other;
|
||||
return (this.field != null ? this.field.equals(otherPoint.field) :
|
||||
this.methodParameter.equals(otherPoint.methodParameter));
|
||||
return (ObjectUtils.nullSafeEquals(this.field, otherPoint.field) &&
|
||||
ObjectUtils.nullSafeEquals(this.methodParameter, otherPoint.methodParameter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (this.field != null ? this.field.hashCode() : this.methodParameter.hashCode());
|
||||
return (this.field != null ? this.field.hashCode() : ObjectUtils.nullSafeHashCode(this.methodParameter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return (this.field != null ? "field '" + this.field.getName() + "'" : this.methodParameter.toString());
|
||||
return (this.field != null ? "field '" + this.field.getName() + "'" : String.valueOf(this.methodParameter));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -35,8 +35,10 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class NoSuchBeanDefinitionException extends BeansException {
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
|
||||
@Nullable
|
||||
private ResolvableType resolvableType;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -32,6 +32,7 @@ import org.springframework.util.StringUtils;
|
||||
@SuppressWarnings("serial")
|
||||
public class UnsatisfiedDependencyException extends BeanCreationException {
|
||||
|
||||
@Nullable
|
||||
private InjectionPoint injectionPoint;
|
||||
|
||||
|
||||
|
||||
@@ -128,6 +128,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
|
||||
private int order = Ordered.LOWEST_PRECEDENCE - 2;
|
||||
|
||||
@Nullable
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
private final Set<String> lookupMethodsChecked = Collections.newSetFromMap(new ConcurrentHashMap<>(256));
|
||||
@@ -242,6 +243,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
ReflectionUtils.doWithMethods(beanClass, method -> {
|
||||
Lookup lookup = method.getAnnotation(Lookup.class);
|
||||
if (lookup != null) {
|
||||
Assert.state(beanFactory != null, "No BeanFactory available");
|
||||
LookupOverride override = new LookupOverride(method, lookup.value());
|
||||
try {
|
||||
RootBeanDefinition mbd = (RootBeanDefinition) beanFactory.getMergedBeanDefinition(beanName);
|
||||
@@ -504,7 +506,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
private void registerDependentBeans(@Nullable String beanName, Set<String> autowiredBeanNames) {
|
||||
if (beanName != null) {
|
||||
for (String autowiredBeanName : autowiredBeanNames) {
|
||||
if (this.beanFactory.containsBean(autowiredBeanName)) {
|
||||
if (this.beanFactory != null && this.beanFactory.containsBean(autowiredBeanName)) {
|
||||
this.beanFactory.registerDependentBean(autowiredBeanName, beanName);
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
@@ -519,9 +521,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
* Resolve the specified cached method argument or field value.
|
||||
*/
|
||||
@Nullable
|
||||
private Object resolvedCachedArgument(@Nullable String beanName, Object cachedArgument) {
|
||||
private Object resolvedCachedArgument(@Nullable String beanName, @Nullable Object cachedArgument) {
|
||||
if (cachedArgument instanceof DependencyDescriptor) {
|
||||
DependencyDescriptor descriptor = (DependencyDescriptor) cachedArgument;
|
||||
Assert.state(beanFactory != null, "No BeanFactory available");
|
||||
return this.beanFactory.resolveDependency(descriptor, beanName, null, null);
|
||||
}
|
||||
else {
|
||||
@@ -539,6 +542,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
|
||||
private volatile boolean cached = false;
|
||||
|
||||
@Nullable
|
||||
private volatile Object cachedFieldValue;
|
||||
|
||||
public AutowiredFieldElement(Field field, boolean required) {
|
||||
@@ -557,6 +561,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
DependencyDescriptor desc = new DependencyDescriptor(field, this.required);
|
||||
desc.setContainingClass(bean.getClass());
|
||||
Set<String> autowiredBeanNames = new LinkedHashSet<>(1);
|
||||
Assert.state(beanFactory != null, "No BeanFactory available");
|
||||
TypeConverter typeConverter = beanFactory.getTypeConverter();
|
||||
try {
|
||||
value = beanFactory.resolveDependency(desc, beanName, autowiredBeanNames, typeConverter);
|
||||
@@ -603,6 +608,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
|
||||
private volatile boolean cached = false;
|
||||
|
||||
@Nullable
|
||||
private volatile Object[] cachedMethodArguments;
|
||||
|
||||
public AutowiredMethodElement(Method method, boolean required, @Nullable PropertyDescriptor pd) {
|
||||
@@ -626,6 +632,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
arguments = new Object[paramTypes.length];
|
||||
DependencyDescriptor[] descriptors = new DependencyDescriptor[paramTypes.length];
|
||||
Set<String> autowiredBeans = new LinkedHashSet<>(paramTypes.length);
|
||||
Assert.state(beanFactory != null, "No BeanFactory available");
|
||||
TypeConverter typeConverter = beanFactory.getTypeConverter();
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
MethodParameter methodParam = new MethodParameter(method, i);
|
||||
@@ -647,9 +654,9 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
synchronized (this) {
|
||||
if (!this.cached) {
|
||||
if (arguments != null) {
|
||||
this.cachedMethodArguments = new Object[paramTypes.length];
|
||||
Object[] cachedMethodArguments = new Object[paramTypes.length];
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
this.cachedMethodArguments[i] = descriptors[i];
|
||||
cachedMethodArguments[i] = descriptors[i];
|
||||
}
|
||||
registerDependentBeans(beanName, autowiredBeans);
|
||||
if (autowiredBeans.size() == paramTypes.length) {
|
||||
@@ -658,12 +665,13 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
String autowiredBeanName = it.next();
|
||||
if (beanFactory.containsBean(autowiredBeanName)) {
|
||||
if (beanFactory.isTypeMatch(autowiredBeanName, paramTypes[i])) {
|
||||
this.cachedMethodArguments[i] = new ShortcutDependencyDescriptor(
|
||||
cachedMethodArguments[i] = new ShortcutDependencyDescriptor(
|
||||
descriptors[i], autowiredBeanName, paramTypes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.cachedMethodArguments = cachedMethodArguments;
|
||||
}
|
||||
else {
|
||||
this.cachedMethodArguments = null;
|
||||
@@ -685,12 +693,13 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
|
||||
@Nullable
|
||||
private Object[] resolveCachedArguments(@Nullable String beanName) {
|
||||
if (this.cachedMethodArguments == null) {
|
||||
Object[] cachedMethodArguments = this.cachedMethodArguments;
|
||||
if (cachedMethodArguments == null) {
|
||||
return null;
|
||||
}
|
||||
Object[] arguments = new Object[this.cachedMethodArguments.length];
|
||||
Object[] arguments = new Object[cachedMethodArguments.length];
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
arguments[i] = resolvedCachedArgument(beanName, this.cachedMethodArguments[i]);
|
||||
arguments[i] = resolvedCachedArgument(beanName, cachedMethodArguments[i]);
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -51,8 +51,10 @@ public class CustomAutowireConfigurer implements BeanFactoryPostProcessor, BeanC
|
||||
|
||||
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
|
||||
|
||||
@Nullable
|
||||
private Set<?> customQualifierTypes;
|
||||
|
||||
@Nullable
|
||||
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
||||
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcess
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.PriorityOrdered;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -77,14 +78,16 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||
|
||||
protected transient Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Nullable
|
||||
private Class<? extends Annotation> initAnnotationType;
|
||||
|
||||
@Nullable
|
||||
private Class<? extends Annotation> destroyAnnotationType;
|
||||
|
||||
private int order = Ordered.LOWEST_PRECEDENCE;
|
||||
|
||||
private transient final Map<Class<?>, LifecycleMetadata> lifecycleMetadataCache =
|
||||
new ConcurrentHashMap<>(256);
|
||||
@Nullable
|
||||
private transient final Map<Class<?>, LifecycleMetadata> lifecycleMetadataCache = new ConcurrentHashMap<>(256);
|
||||
|
||||
|
||||
/**
|
||||
@@ -255,8 +258,10 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||
|
||||
private final Collection<LifecycleElement> destroyMethods;
|
||||
|
||||
@Nullable
|
||||
private volatile Set<LifecycleElement> checkedInitMethods;
|
||||
|
||||
@Nullable
|
||||
private volatile Set<LifecycleElement> checkedDestroyMethods;
|
||||
|
||||
public LifecycleMetadata(Class<?> targetClass, Collection<LifecycleElement> initMethods,
|
||||
@@ -295,8 +300,9 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||
}
|
||||
|
||||
public void invokeInitMethods(Object target, String beanName) throws Throwable {
|
||||
Collection<LifecycleElement> checkedInitMethods = this.checkedInitMethods;
|
||||
Collection<LifecycleElement> initMethodsToIterate =
|
||||
(this.checkedInitMethods != null ? this.checkedInitMethods : this.initMethods);
|
||||
(checkedInitMethods != null ? checkedInitMethods : this.initMethods);
|
||||
if (!initMethodsToIterate.isEmpty()) {
|
||||
boolean debug = logger.isDebugEnabled();
|
||||
for (LifecycleElement element : initMethodsToIterate) {
|
||||
@@ -309,8 +315,9 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||
}
|
||||
|
||||
public void invokeDestroyMethods(Object target, String beanName) throws Throwable {
|
||||
Collection<LifecycleElement> checkedDestroyMethods = this.checkedDestroyMethods;
|
||||
Collection<LifecycleElement> destroyMethodsToUse =
|
||||
(this.checkedDestroyMethods != null ? this.checkedDestroyMethods : this.destroyMethods);
|
||||
(checkedDestroyMethods != null ? checkedDestroyMethods : this.destroyMethods);
|
||||
if (!destroyMethodsToUse.isEmpty()) {
|
||||
boolean debug = logger.isDebugEnabled();
|
||||
for (LifecycleElement element : destroyMethodsToUse) {
|
||||
@@ -323,8 +330,9 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||
}
|
||||
|
||||
public boolean hasDestroyMethods() {
|
||||
Collection<LifecycleElement> checkedDestroyMethods = this.checkedDestroyMethods;
|
||||
Collection<LifecycleElement> destroyMethodsToUse =
|
||||
(this.checkedDestroyMethods != null ? this.checkedDestroyMethods : this.destroyMethods);
|
||||
(checkedDestroyMethods != null ? checkedDestroyMethods : this.destroyMethods);
|
||||
return !destroyMethodsToUse.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public class InjectionMetadata {
|
||||
|
||||
private final Collection<InjectedElement> injectedElements;
|
||||
|
||||
@Nullable
|
||||
private volatile Set<InjectedElement> checkedElements;
|
||||
|
||||
|
||||
@@ -78,8 +79,9 @@ public class InjectionMetadata {
|
||||
}
|
||||
|
||||
public void inject(Object target, @Nullable String beanName, @Nullable PropertyValues pvs) throws Throwable {
|
||||
Collection<InjectedElement> checkedElements = this.checkedElements;
|
||||
Collection<InjectedElement> elementsToIterate =
|
||||
(this.checkedElements != null ? this.checkedElements : this.injectedElements);
|
||||
(checkedElements != null ? checkedElements : this.injectedElements);
|
||||
if (!elementsToIterate.isEmpty()) {
|
||||
boolean debug = logger.isDebugEnabled();
|
||||
for (InjectedElement element : elementsToIterate) {
|
||||
@@ -95,8 +97,9 @@ public class InjectionMetadata {
|
||||
* @since 3.2.13
|
||||
*/
|
||||
public void clear(@Nullable PropertyValues pvs) {
|
||||
Collection<InjectedElement> checkedElements = this.checkedElements;
|
||||
Collection<InjectedElement> elementsToIterate =
|
||||
(this.checkedElements != null ? this.checkedElements : this.injectedElements);
|
||||
(checkedElements != null ? checkedElements : this.injectedElements);
|
||||
if (!elementsToIterate.isEmpty()) {
|
||||
for (InjectedElement element : elementsToIterate) {
|
||||
element.clearPropertySkipping(pvs);
|
||||
@@ -116,8 +119,10 @@ public class InjectionMetadata {
|
||||
|
||||
protected final boolean isField;
|
||||
|
||||
@Nullable
|
||||
protected final PropertyDescriptor pd;
|
||||
|
||||
@Nullable
|
||||
protected volatile Boolean skip;
|
||||
|
||||
protected InjectedElement(Member member, @Nullable PropertyDescriptor pd) {
|
||||
@@ -192,16 +197,18 @@ public class InjectionMetadata {
|
||||
* affected property as processed for other processors to ignore it.
|
||||
*/
|
||||
protected boolean checkPropertySkipping(@Nullable PropertyValues pvs) {
|
||||
if (this.skip != null) {
|
||||
return this.skip;
|
||||
Boolean skip = this.skip;
|
||||
if (skip != null) {
|
||||
return skip;
|
||||
}
|
||||
if (pvs == null) {
|
||||
this.skip = false;
|
||||
return false;
|
||||
}
|
||||
synchronized (pvs) {
|
||||
if (this.skip != null) {
|
||||
return this.skip;
|
||||
skip = this.skip;
|
||||
if (skip != null) {
|
||||
return skip;
|
||||
}
|
||||
if (this.pd != null) {
|
||||
if (pvs.contains(this.pd.getName())) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -34,6 +34,7 @@ import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -66,14 +67,18 @@ public abstract class AbstractFactoryBean<T>
|
||||
|
||||
private boolean singleton = true;
|
||||
|
||||
@Nullable
|
||||
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
||||
|
||||
@Nullable
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
@Nullable
|
||||
private T singletonInstance;
|
||||
|
||||
@Nullable
|
||||
private T earlySingletonInstance;
|
||||
|
||||
|
||||
@@ -103,6 +108,7 @@ public abstract class AbstractFactoryBean<T>
|
||||
/**
|
||||
* Return the BeanFactory that this bean runs in.
|
||||
*/
|
||||
@Nullable
|
||||
protected BeanFactory getBeanFactory() {
|
||||
return this.beanFactory;
|
||||
}
|
||||
@@ -176,10 +182,9 @@ public abstract class AbstractFactoryBean<T>
|
||||
* @return the singleton instance that this FactoryBean holds
|
||||
* @throws IllegalStateException if the singleton instance is not initialized
|
||||
*/
|
||||
@Nullable
|
||||
private T getSingletonInstance() throws IllegalStateException {
|
||||
if (!this.initialized) {
|
||||
throw new IllegalStateException("Singleton instance not initialized yet");
|
||||
}
|
||||
Assert.state(this.initialized, "Singleton instance not initialized yet");
|
||||
return this.singletonInstance;
|
||||
}
|
||||
|
||||
@@ -241,7 +246,7 @@ public abstract class AbstractFactoryBean<T>
|
||||
* @throws Exception in case of shutdown errors
|
||||
* @see #createInstance()
|
||||
*/
|
||||
protected void destroyInstance(T instance) throws Exception {
|
||||
protected void destroyInstance(@Nullable T instance) throws Exception {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ public class BeanDefinitionHolder implements BeanMetadataElement {
|
||||
|
||||
private final String beanName;
|
||||
|
||||
@Nullable
|
||||
private final String[] aliases;
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.springframework.util.StringValueResolver;
|
||||
*/
|
||||
public class BeanDefinitionVisitor {
|
||||
|
||||
@Nullable
|
||||
private StringValueResolver valueResolver;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -29,6 +29,7 @@ public class BeanExpressionContext {
|
||||
|
||||
private final ConfigurableBeanFactory beanFactory;
|
||||
|
||||
@Nullable
|
||||
private final Scope scope;
|
||||
|
||||
|
||||
@@ -42,6 +43,7 @@ public class BeanExpressionContext {
|
||||
return this.beanFactory;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public final Scope getScope() {
|
||||
return this.scope;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
|
||||
/**
|
||||
* Return this factory's class loader for loading bean classes.
|
||||
*/
|
||||
@Nullable
|
||||
ClassLoader getBeanClassLoader();
|
||||
|
||||
/**
|
||||
|
||||
@@ -435,16 +435,21 @@ public class ConstructorArgumentValues {
|
||||
*/
|
||||
public static class ValueHolder implements BeanMetadataElement {
|
||||
|
||||
@Nullable
|
||||
private Object value;
|
||||
|
||||
@Nullable
|
||||
private String type;
|
||||
|
||||
@Nullable
|
||||
private String name;
|
||||
|
||||
@Nullable
|
||||
private Object source;
|
||||
|
||||
private boolean converted = false;
|
||||
|
||||
@Nullable
|
||||
private Object convertedValue;
|
||||
|
||||
/**
|
||||
@@ -558,6 +563,7 @@ public class ConstructorArgumentValues {
|
||||
* Return the converted value of the constructor argument,
|
||||
* after processed type conversion.
|
||||
*/
|
||||
@Nullable
|
||||
public synchronized Object getConvertedValue() {
|
||||
return this.convertedValue;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.PropertyEditorRegistrar;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
@@ -98,8 +99,10 @@ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, Ordered
|
||||
|
||||
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
|
||||
|
||||
@Nullable
|
||||
private PropertyEditorRegistrar[] propertyEditorRegistrars;
|
||||
|
||||
@Nullable
|
||||
private Map<Class<?>, Class<? extends PropertyEditor>> customEditors;
|
||||
|
||||
|
||||
|
||||
@@ -46,10 +46,12 @@ import org.springframework.util.ClassUtils;
|
||||
*/
|
||||
public class CustomScopeConfigurer implements BeanFactoryPostProcessor, BeanClassLoaderAware, Ordered {
|
||||
|
||||
@Nullable
|
||||
private Map<String, Object> scopes;
|
||||
|
||||
private int order = Ordered.LOWEST_PRECEDENCE;
|
||||
|
||||
@Nullable
|
||||
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
||||
|
||||
|
||||
|
||||
@@ -58,12 +58,15 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
|
||||
private final Class<?> declaringClass;
|
||||
|
||||
@Nullable
|
||||
private String methodName;
|
||||
|
||||
@Nullable
|
||||
private Class<?>[] parameterTypes;
|
||||
|
||||
private int parameterIndex;
|
||||
|
||||
@Nullable
|
||||
private String fieldName;
|
||||
|
||||
private final boolean required;
|
||||
@@ -72,8 +75,10 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
|
||||
private int nestingLevel = 1;
|
||||
|
||||
@Nullable
|
||||
private Class<?> containingClass;
|
||||
|
||||
@Nullable
|
||||
private volatile ResolvableType resolvableType;
|
||||
|
||||
|
||||
@@ -98,8 +103,8 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
super(methodParameter);
|
||||
|
||||
this.declaringClass = methodParameter.getDeclaringClass();
|
||||
if (this.methodParameter.getMethod() != null) {
|
||||
this.methodName = this.methodParameter.getMethod().getName();
|
||||
if (methodParameter.getMethod() != null) {
|
||||
this.methodName = methodParameter.getMethod().getName();
|
||||
}
|
||||
this.parameterTypes = methodParameter.getExecutable().getParameterTypes();
|
||||
this.parameterIndex = methodParameter.getParameterIndex();
|
||||
@@ -170,7 +175,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
(kotlinPresent && KotlinDelegate.isNullable(this.field)));
|
||||
}
|
||||
else {
|
||||
return !this.methodParameter.isOptional();
|
||||
return !obtainMethodParameter().isOptional();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,12 +287,14 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
* @since 4.0
|
||||
*/
|
||||
public ResolvableType getResolvableType() {
|
||||
if (this.resolvableType == null) {
|
||||
this.resolvableType = (this.field != null ?
|
||||
ResolvableType resolvableType = this.resolvableType;
|
||||
if (resolvableType == null) {
|
||||
resolvableType = (this.field != null ?
|
||||
ResolvableType.forField(this.field, this.nestingLevel, this.containingClass) :
|
||||
ResolvableType.forMethodParameter(this.methodParameter));
|
||||
ResolvableType.forMethodParameter(obtainMethodParameter()));
|
||||
this.resolvableType = resolvableType;
|
||||
}
|
||||
return this.resolvableType;
|
||||
return resolvableType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,7 +340,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
*/
|
||||
@Nullable
|
||||
public String getDependencyName() {
|
||||
return (this.field != null ? this.field.getName() : this.methodParameter.getParameterName());
|
||||
return (this.field != null ? this.field.getName() : obtainMethodParameter().getParameterName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,7 +374,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
}
|
||||
}
|
||||
else {
|
||||
return this.methodParameter.getNestedParameterType();
|
||||
return obtainMethodParameter().getNestedParameterType();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringValueResolver;
|
||||
|
||||
/**
|
||||
@@ -37,6 +38,7 @@ public class EmbeddedValueResolver implements StringValueResolver {
|
||||
|
||||
private final BeanExpressionContext exprContext;
|
||||
|
||||
@Nullable
|
||||
private final BeanExpressionResolver exprResolver;
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -55,19 +57,26 @@ import org.springframework.util.StringUtils;
|
||||
public class FieldRetrievingFactoryBean
|
||||
implements FactoryBean<Object>, BeanNameAware, BeanClassLoaderAware, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private Class<?> targetClass;
|
||||
|
||||
@Nullable
|
||||
private Object targetObject;
|
||||
|
||||
@Nullable
|
||||
private String targetField;
|
||||
|
||||
@Nullable
|
||||
private String staticField;
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
|
||||
@Nullable
|
||||
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
||||
|
||||
// the field we will retrieve
|
||||
@Nullable
|
||||
private Field fieldObject;
|
||||
|
||||
|
||||
@@ -85,6 +94,7 @@ public class FieldRetrievingFactoryBean
|
||||
/**
|
||||
* Return the target class on which the field is defined.
|
||||
*/
|
||||
@Nullable
|
||||
public Class<?> getTargetClass() {
|
||||
return targetClass;
|
||||
}
|
||||
@@ -103,6 +113,7 @@ public class FieldRetrievingFactoryBean
|
||||
/**
|
||||
* Return the target object on which the field is defined.
|
||||
*/
|
||||
@Nullable
|
||||
public Object getTargetObject() {
|
||||
return this.targetObject;
|
||||
}
|
||||
@@ -121,6 +132,7 @@ public class FieldRetrievingFactoryBean
|
||||
/**
|
||||
* Return the name of the field to be retrieved.
|
||||
*/
|
||||
@Nullable
|
||||
public String getTargetField() {
|
||||
return this.targetField;
|
||||
}
|
||||
@@ -168,6 +180,7 @@ public class FieldRetrievingFactoryBean
|
||||
// If no other property specified, consider bean name as static field expression.
|
||||
if (this.staticField == null) {
|
||||
this.staticField = this.beanName;
|
||||
Assert.state(this.staticField != null, "No target field specified");
|
||||
}
|
||||
|
||||
// Try to parse static field into class and field.
|
||||
|
||||
@@ -35,9 +35,11 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class ListFactoryBean extends AbstractFactoryBean<List<Object>> {
|
||||
|
||||
@Nullable
|
||||
private List<?> sourceList;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Nullable
|
||||
private Class<? extends List> targetListClass;
|
||||
|
||||
|
||||
|
||||
@@ -35,9 +35,11 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class MapFactoryBean extends AbstractFactoryBean<Map<Object, Object>> {
|
||||
|
||||
@Nullable
|
||||
private Map<?, ?> sourceMap;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Nullable
|
||||
private Class<? extends Map> targetMapClass;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-20147 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -67,8 +67,10 @@ import org.springframework.util.ClassUtils;
|
||||
public class MethodInvokingBean extends ArgumentConvertingMethodInvoker
|
||||
implements BeanClassLoaderAware, BeanFactoryAware, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
||||
|
||||
@Nullable
|
||||
private ConfigurableBeanFactory beanFactory;
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@link FactoryBean} which returns a value which is the result of a static or instance
|
||||
@@ -87,6 +88,7 @@ public class MethodInvokingFactoryBean extends MethodInvokingBean implements Fac
|
||||
private boolean initialized = false;
|
||||
|
||||
/** Method call result in the singleton case */
|
||||
@Nullable
|
||||
private Object singletonObject;
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.beans.factory.NamedBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -39,7 +38,7 @@ public class NamedBeanHolder<T> implements NamedBean {
|
||||
* @param beanName the name of the bean
|
||||
* @param beanInstance the corresponding bean instance
|
||||
*/
|
||||
public NamedBeanHolder(String beanName, @Nullable T beanInstance) {
|
||||
public NamedBeanHolder(String beanName, T beanInstance) {
|
||||
Assert.notNull(beanName, "Bean name must not be null");
|
||||
this.beanName = beanName;
|
||||
this.beanInstance = beanInstance;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +21,7 @@ import java.io.Serializable;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -96,6 +97,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ObjectFactoryCreatingFactoryBean extends AbstractFactoryBean<ObjectFactory<Object>> {
|
||||
|
||||
@Nullable
|
||||
private String targetBeanName;
|
||||
|
||||
|
||||
@@ -124,7 +126,10 @@ public class ObjectFactoryCreatingFactoryBean extends AbstractFactoryBean<Object
|
||||
|
||||
@Override
|
||||
protected ObjectFactory<Object> createInstance() {
|
||||
return new TargetBeanObjectFactory(getBeanFactory(), this.targetBeanName);
|
||||
BeanFactory beanFactory = getBeanFactory();
|
||||
Assert.state(beanFactory != null, "No BeanFactory available");
|
||||
Assert.state(this.targetBeanName != null, "No target bean name specified");
|
||||
return new TargetBeanObjectFactory(beanFactory, this.targetBeanName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -106,16 +106,20 @@ public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfi
|
||||
protected String placeholderSuffix = DEFAULT_PLACEHOLDER_SUFFIX;
|
||||
|
||||
/** Defaults to {@value #DEFAULT_VALUE_SEPARATOR} */
|
||||
@Nullable
|
||||
protected String valueSeparator = DEFAULT_VALUE_SEPARATOR;
|
||||
|
||||
protected boolean trimValues = false;
|
||||
|
||||
@Nullable
|
||||
protected String nullValue;
|
||||
|
||||
protected boolean ignoreUnresolvablePlaceholders = false;
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
|
||||
@Nullable
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
|
||||
|
||||
@@ -45,13 +45,15 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class PreferencesPlaceholderConfigurer extends PropertyPlaceholderConfigurer implements InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private String systemTreePath;
|
||||
|
||||
@Nullable
|
||||
private String userTreePath;
|
||||
|
||||
private Preferences systemPrefs;
|
||||
private Preferences systemPrefs = Preferences.systemRoot();
|
||||
|
||||
private Preferences userPrefs;
|
||||
private Preferences userPrefs = Preferences.userRoot();
|
||||
|
||||
|
||||
/**
|
||||
@@ -77,10 +79,12 @@ public class PreferencesPlaceholderConfigurer extends PropertyPlaceholderConfigu
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
this.systemPrefs = (this.systemTreePath != null) ?
|
||||
Preferences.systemRoot().node(this.systemTreePath) : Preferences.systemRoot();
|
||||
this.userPrefs = (this.userTreePath != null) ?
|
||||
Preferences.userRoot().node(this.userTreePath) : Preferences.userRoot();
|
||||
if (this.systemTreePath != null) {
|
||||
this.systemPrefs = this.systemPrefs.node(this.systemTreePath);
|
||||
}
|
||||
if (this.userTreePath != null) {
|
||||
this.userPrefs = this.userPrefs.node(this.userTreePath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -27,6 +27,8 @@ import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -85,16 +87,22 @@ public class PropertyPathFactoryBean implements FactoryBean<Object>, BeanNameAwa
|
||||
|
||||
private static final Log logger = LogFactory.getLog(PropertyPathFactoryBean.class);
|
||||
|
||||
@Nullable
|
||||
private BeanWrapper targetBeanWrapper;
|
||||
|
||||
@Nullable
|
||||
private String targetBeanName;
|
||||
|
||||
@Nullable
|
||||
private String propertyPath;
|
||||
|
||||
@Nullable
|
||||
private Class<?> resultType;
|
||||
|
||||
@Nullable
|
||||
private String beanName;
|
||||
|
||||
@Nullable
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
|
||||
@@ -168,7 +176,7 @@ public class PropertyPathFactoryBean implements FactoryBean<Object>, BeanNameAwa
|
||||
}
|
||||
|
||||
// No other properties specified: check bean name.
|
||||
int dotIndex = this.beanName.indexOf('.');
|
||||
int dotIndex = (this.beanName != null ? this.beanName.indexOf('.') : -1);
|
||||
if (dotIndex == -1) {
|
||||
throw new IllegalArgumentException(
|
||||
"Neither 'targetObject' nor 'targetBeanName' specified, and PropertyPathFactoryBean " +
|
||||
@@ -205,9 +213,12 @@ public class PropertyPathFactoryBean implements FactoryBean<Object>, BeanNameAwa
|
||||
}
|
||||
else {
|
||||
// Fetch prototype target bean...
|
||||
Assert.state(this.beanFactory != null, "No BeanFactory available");
|
||||
Assert.state(this.targetBeanName != null, "No target bean name specified");
|
||||
Object bean = this.beanFactory.getBean(this.targetBeanName);
|
||||
target = PropertyAccessorFactory.forBeanPropertyAccess(bean);
|
||||
}
|
||||
Assert.state(this.propertyPath != null, "No property path specified");
|
||||
return target.getPropertyValue(this.propertyPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +21,7 @@ import javax.inject.Provider;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ProviderCreatingFactoryBean extends AbstractFactoryBean<Provider<Object>> {
|
||||
|
||||
@Nullable
|
||||
private String targetBeanName;
|
||||
|
||||
|
||||
@@ -69,7 +71,10 @@ public class ProviderCreatingFactoryBean extends AbstractFactoryBean<Provider<Ob
|
||||
|
||||
@Override
|
||||
protected Provider<Object> createInstance() {
|
||||
return new TargetBeanProvider(getBeanFactory(), this.targetBeanName);
|
||||
BeanFactory beanFactory = getBeanFactory();
|
||||
Assert.state(beanFactory != null, "No BeanFactory available");
|
||||
Assert.state(this.targetBeanName != null, "No target bean name specified");
|
||||
return new TargetBeanProvider(beanFactory, this.targetBeanName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ public class RuntimeBeanNameReference implements BeanReference {
|
||||
|
||||
private final String beanName;
|
||||
|
||||
@Nullable
|
||||
private Object source;
|
||||
|
||||
|
||||
@@ -59,6 +60,7 @@ public class RuntimeBeanNameReference implements BeanReference {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public class RuntimeBeanReference implements BeanReference {
|
||||
|
||||
private final boolean toParent;
|
||||
|
||||
@Nullable
|
||||
private Object source;
|
||||
|
||||
|
||||
@@ -84,6 +85,7 @@ public class RuntimeBeanReference implements BeanReference {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -189,14 +190,19 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFactoryAware, InitializingBean {
|
||||
|
||||
@Nullable
|
||||
private Class<?> serviceLocatorInterface;
|
||||
|
||||
@Nullable
|
||||
private Constructor<Exception> serviceLocatorExceptionConstructor;
|
||||
|
||||
@Nullable
|
||||
private Properties serviceMappings;
|
||||
|
||||
@Nullable
|
||||
private ListableBeanFactory beanFactory;
|
||||
|
||||
@Nullable
|
||||
private Object proxy;
|
||||
|
||||
|
||||
@@ -278,15 +284,15 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Constructor<Exception> determineServiceLocatorExceptionConstructor(Class<? extends Exception> exceptionClass) {
|
||||
try {
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {String.class, Throwable.class});
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(String.class, Throwable.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
try {
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {Throwable.class});
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(Throwable.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex2) {
|
||||
try {
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {String.class});
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(String.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex3) {
|
||||
throw new IllegalArgumentException(
|
||||
@@ -354,7 +360,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
|
||||
return System.identityHashCode(proxy);
|
||||
}
|
||||
else if (ReflectionUtils.isToStringMethod(method)) {
|
||||
return "Service locator: " + serviceLocatorInterface.getName();
|
||||
return "Service locator: " + serviceLocatorInterface;
|
||||
}
|
||||
else {
|
||||
return invokeServiceLocatorMethod(method, args);
|
||||
@@ -365,6 +371,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
|
||||
Class<?> serviceLocatorMethodReturnType = getServiceLocatorMethodReturnType(method);
|
||||
try {
|
||||
String beanName = tryGetBeanName(args);
|
||||
Assert.state(beanFactory != null, "No BeanFactory available");
|
||||
if (StringUtils.hasLength(beanName)) {
|
||||
// Service locator for a specific bean name
|
||||
return beanFactory.getBean(beanName, serviceLocatorMethodReturnType);
|
||||
@@ -401,6 +408,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
|
||||
}
|
||||
|
||||
private Class<?> getServiceLocatorMethodReturnType(Method method) throws NoSuchMethodException {
|
||||
Assert.state(serviceLocatorInterface != null, "No service locator interface specified");
|
||||
Class<?>[] paramTypes = method.getParameterTypes();
|
||||
Method interfaceMethod = serviceLocatorInterface.getMethod(method.getName(), paramTypes);
|
||||
Class<?> serviceLocatorReturnType = interfaceMethod.getReturnType();
|
||||
|
||||
@@ -35,9 +35,11 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class SetFactoryBean extends AbstractFactoryBean<Set<Object>> {
|
||||
|
||||
@Nullable
|
||||
private Set<?> sourceSet;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Nullable
|
||||
private Class<? extends Set> targetSetClass;
|
||||
|
||||
|
||||
|
||||
@@ -37,12 +37,16 @@ import org.springframework.util.ObjectUtils;
|
||||
*/
|
||||
public class TypedStringValue implements BeanMetadataElement {
|
||||
|
||||
@Nullable
|
||||
private String value;
|
||||
|
||||
@Nullable
|
||||
private volatile Object targetType;
|
||||
|
||||
@Nullable
|
||||
private Object source;
|
||||
|
||||
@Nullable
|
||||
private String specifiedTypeName;
|
||||
|
||||
private volatile boolean dynamic;
|
||||
@@ -157,7 +161,7 @@ public class TypedStringValue implements BeanMetadataElement {
|
||||
* @throws ClassNotFoundException if the type cannot be resolved
|
||||
*/
|
||||
@Nullable
|
||||
public Class<?> resolveTargetType(ClassLoader classLoader) throws ClassNotFoundException {
|
||||
public Class<?> resolveTargetType(@Nullable ClassLoader classLoader) throws ClassNotFoundException {
|
||||
String typeName = getTargetTypeName();
|
||||
if (typeName == null) {
|
||||
return null;
|
||||
@@ -177,6 +181,7 @@ public class TypedStringValue implements BeanMetadataElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Factory for a {@code Map} that reads from a YAML source, preserving the
|
||||
@@ -71,6 +72,7 @@ public class YamlMapFactoryBean extends YamlProcessor implements FactoryBean<Map
|
||||
|
||||
private boolean singleton = true;
|
||||
|
||||
@Nullable
|
||||
private Map<String, Object> map;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +21,7 @@ import java.util.Properties;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.CollectionFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Factory for {@link java.util.Properties} that reads from a YAML source,
|
||||
@@ -82,6 +83,7 @@ public class YamlPropertiesFactoryBean extends YamlProcessor implements FactoryB
|
||||
|
||||
private boolean singleton = true;
|
||||
|
||||
@Nullable
|
||||
private Properties properties;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -33,6 +33,7 @@ public class AliasDefinition implements BeanMetadataElement {
|
||||
|
||||
private final String alias;
|
||||
|
||||
@Nullable
|
||||
private final Object source;
|
||||
|
||||
|
||||
@@ -75,6 +76,7 @@ public class AliasDefinition implements BeanMetadataElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public final Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public class CompositeComponentDefinition extends AbstractComponentDefinition {
|
||||
|
||||
private final String name;
|
||||
|
||||
@Nullable
|
||||
private final Object source;
|
||||
|
||||
private final List<ComponentDefinition> nestedComponents = new LinkedList<>();
|
||||
@@ -58,6 +59,7 @@ public class CompositeComponentDefinition extends AbstractComponentDefinition {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@@ -32,8 +32,10 @@ public class ImportDefinition implements BeanMetadataElement {
|
||||
|
||||
private final String importedResource;
|
||||
|
||||
@Nullable
|
||||
private final Resource[] actualResources;
|
||||
|
||||
@Nullable
|
||||
private final Object source;
|
||||
|
||||
|
||||
@@ -74,11 +76,13 @@ public class ImportDefinition implements BeanMetadataElement {
|
||||
return this.importedResource;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public final Resource[] getActualResources() {
|
||||
return this.actualResources;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public final Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +37,7 @@ public class Location {
|
||||
|
||||
private final Resource resource;
|
||||
|
||||
@Nullable
|
||||
private final Object source;
|
||||
|
||||
|
||||
|
||||
@@ -36,8 +36,10 @@ public class Problem {
|
||||
|
||||
private final Location location;
|
||||
|
||||
@Nullable
|
||||
private final ParseState parseState;
|
||||
|
||||
@Nullable
|
||||
private final Throwable rootCause;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -35,8 +35,10 @@ import org.springframework.util.ClassUtils;
|
||||
public abstract class AbstractServiceLoaderBasedFactoryBean extends AbstractFactoryBean<Object>
|
||||
implements BeanClassLoaderAware {
|
||||
|
||||
@Nullable
|
||||
private Class<?> serviceType;
|
||||
|
||||
@Nullable
|
||||
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
||||
|
||||
|
||||
@@ -50,6 +52,7 @@ public abstract class AbstractServiceLoaderBasedFactoryBean extends AbstractFact
|
||||
/**
|
||||
* Return the desired service type.
|
||||
*/
|
||||
@Nullable
|
||||
public Class<?> getServiceType() {
|
||||
return this.serviceType;
|
||||
}
|
||||
|
||||
@@ -125,6 +125,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
private InstantiationStrategy instantiationStrategy = new CglibSubclassingInstantiationStrategy();
|
||||
|
||||
/** Resolver strategy for method parameter names */
|
||||
@Nullable
|
||||
private ParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer();
|
||||
|
||||
/** Whether to automatically try to resolve circular references between beans */
|
||||
@@ -755,13 +756,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
}
|
||||
Class<?> returnType = AutowireUtils.resolveReturnTypeForFactoryMethod(
|
||||
factoryMethod, args, getBeanClassLoader());
|
||||
if (returnType != null) {
|
||||
uniqueCandidate = (commonType == null ? factoryMethod : null);
|
||||
commonType = ClassUtils.determineCommonAncestor(returnType, commonType);
|
||||
if (commonType == null) {
|
||||
// Ambiguous return types found: return null to indicate "not determinable".
|
||||
return null;
|
||||
}
|
||||
uniqueCandidate = (commonType == null ? factoryMethod : null);
|
||||
commonType = ClassUtils.determineCommonAncestor(returnType, commonType);
|
||||
if (commonType == null) {
|
||||
// Ambiguous return types found: return null to indicate "not determinable".
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
@@ -869,7 +868,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
*/
|
||||
@Nullable
|
||||
private Class<?> getTypeForFactoryBeanFromMethod(Class<?> beanClass, final String factoryMethodName) {
|
||||
class Holder { Class<?> value = null; }
|
||||
class Holder { @Nullable Class<?> value = null; }
|
||||
final Holder objectType = new Holder();
|
||||
|
||||
// CGLIB subclass methods hide generic parameters; look at the original user class.
|
||||
@@ -1731,7 +1730,10 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
((BeanNameAware) bean).setBeanName(beanName);
|
||||
}
|
||||
if (bean instanceof BeanClassLoaderAware) {
|
||||
((BeanClassLoaderAware) bean).setBeanClassLoader(getBeanClassLoader());
|
||||
ClassLoader bcl = getBeanClassLoader();
|
||||
if (bcl != null) {
|
||||
((BeanClassLoaderAware) bean).setBeanClassLoader(bcl);
|
||||
}
|
||||
}
|
||||
if (bean instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) bean).setBeanFactory(AbstractAutowireCapableBeanFactory.this);
|
||||
|
||||
@@ -137,8 +137,10 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
public static final String INFER_METHOD = "(inferred)";
|
||||
|
||||
|
||||
@Nullable
|
||||
private volatile Object beanClass;
|
||||
|
||||
@Nullable
|
||||
private String scope = SCOPE_DEFAULT;
|
||||
|
||||
private boolean abstractFlag = false;
|
||||
@@ -149,6 +151,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
|
||||
private int dependencyCheck = DEPENDENCY_CHECK_NONE;
|
||||
|
||||
@Nullable
|
||||
private String[] dependsOn;
|
||||
|
||||
private boolean autowireCandidate = true;
|
||||
@@ -157,14 +160,17 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
|
||||
private final Map<String, AutowireCandidateQualifier> qualifiers = new LinkedHashMap<>(0);
|
||||
|
||||
@Nullable
|
||||
private Supplier<?> instanceSupplier;
|
||||
|
||||
private boolean nonPublicAccessAllowed = true;
|
||||
|
||||
private boolean lenientConstructorResolution = true;
|
||||
|
||||
@Nullable
|
||||
private String factoryBeanName;
|
||||
|
||||
@Nullable
|
||||
private String factoryMethodName;
|
||||
|
||||
private ConstructorArgumentValues constructorArgumentValues;
|
||||
@@ -173,8 +179,10 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
|
||||
private MethodOverrides methodOverrides = new MethodOverrides();
|
||||
|
||||
@Nullable
|
||||
private String initMethodName;
|
||||
|
||||
@Nullable
|
||||
private String destroyMethodName;
|
||||
|
||||
private boolean enforceInitMethod = true;
|
||||
@@ -185,8 +193,10 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
|
||||
private int role = BeanDefinition.ROLE_APPLICATION;
|
||||
|
||||
@Nullable
|
||||
private String description;
|
||||
|
||||
@Nullable
|
||||
private Resource resource;
|
||||
|
||||
|
||||
@@ -202,8 +212,8 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* constructor argument values and property values.
|
||||
*/
|
||||
protected AbstractBeanDefinition(@Nullable ConstructorArgumentValues cargs, @Nullable MutablePropertyValues pvs) {
|
||||
setConstructorArgumentValues(cargs);
|
||||
setPropertyValues(pvs);
|
||||
this.constructorArgumentValues = (cargs != null ? cargs : new ConstructorArgumentValues());
|
||||
this.propertyValues = (pvs != null ? pvs : new MutablePropertyValues());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,8 +229,8 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
setLazyInit(original.isLazyInit());
|
||||
setFactoryBeanName(original.getFactoryBeanName());
|
||||
setFactoryMethodName(original.getFactoryMethodName());
|
||||
setConstructorArgumentValues(new ConstructorArgumentValues(original.getConstructorArgumentValues()));
|
||||
setPropertyValues(new MutablePropertyValues(original.getPropertyValues()));
|
||||
this.constructorArgumentValues = new ConstructorArgumentValues(original.getConstructorArgumentValues());
|
||||
this.propertyValues = new MutablePropertyValues(original.getPropertyValues());
|
||||
setRole(original.getRole());
|
||||
setSource(original.getSource());
|
||||
copyAttributesFrom(original);
|
||||
@@ -399,7 +409,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* @throws ClassNotFoundException if the class name could be resolved
|
||||
*/
|
||||
@Nullable
|
||||
public Class<?> resolveBeanClass(ClassLoader classLoader) throws ClassNotFoundException {
|
||||
public Class<?> resolveBeanClass(@Nullable ClassLoader classLoader) throws ClassNotFoundException {
|
||||
String className = getBeanClassName();
|
||||
if (className == null) {
|
||||
return null;
|
||||
@@ -428,6 +438,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* Return the name of the target scope for the bean.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public String getScope() {
|
||||
return this.scope;
|
||||
}
|
||||
@@ -574,6 +585,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* Return the bean names that this bean depends on.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public String[] getDependsOn() {
|
||||
return this.dependsOn;
|
||||
}
|
||||
@@ -735,6 +747,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* Return the factory bean name, if any.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public String getFactoryBeanName() {
|
||||
return this.factoryBeanName;
|
||||
}
|
||||
@@ -756,6 +769,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* Return a factory method, if any.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public String getFactoryMethodName() {
|
||||
return this.factoryMethodName;
|
||||
}
|
||||
@@ -923,6 +937,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* Return a human-readable description of this bean definition.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
@@ -931,13 +946,14 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* Set the resource that this bean definition came from
|
||||
* (for the purpose of showing context in case of errors).
|
||||
*/
|
||||
public void setResource(Resource resource) {
|
||||
public void setResource(@Nullable Resource resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the resource that this bean definition came from.
|
||||
*/
|
||||
@Nullable
|
||||
public Resource getResource() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
@@ -52,8 +52,10 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable
|
||||
|
||||
private final BeanDefinitionRegistry registry;
|
||||
|
||||
@Nullable
|
||||
private ResourceLoader resourceLoader;
|
||||
|
||||
@Nullable
|
||||
private ClassLoader beanClassLoader;
|
||||
|
||||
private Environment environment;
|
||||
@@ -120,11 +122,12 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable
|
||||
* @see org.springframework.core.io.support.ResourcePatternResolver
|
||||
* @see org.springframework.core.io.support.PathMatchingResourcePatternResolver
|
||||
*/
|
||||
public void setResourceLoader(@Nullable ResourceLoader resourceLoader) {
|
||||
public void setResourceLoader(ResourceLoader resourceLoader) {
|
||||
this.resourceLoader = resourceLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ResourceLoader getResourceLoader() {
|
||||
return this.resourceLoader;
|
||||
}
|
||||
@@ -141,6 +144,7 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ClassLoader getBeanClassLoader() {
|
||||
return this.beanClassLoader;
|
||||
}
|
||||
|
||||
@@ -113,21 +113,26 @@ import org.springframework.util.StringValueResolver;
|
||||
public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport implements ConfigurableBeanFactory {
|
||||
|
||||
/** Parent bean factory, for bean inheritance support */
|
||||
@Nullable
|
||||
private BeanFactory parentBeanFactory;
|
||||
|
||||
/** ClassLoader to resolve bean class names with, if necessary */
|
||||
@Nullable
|
||||
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
||||
|
||||
/** ClassLoader to temporarily resolve bean class names with, if necessary */
|
||||
@Nullable
|
||||
private ClassLoader tempClassLoader;
|
||||
|
||||
/** Whether to cache bean metadata or rather reobtain it for every access */
|
||||
private boolean cacheBeanMetadata = true;
|
||||
|
||||
/** Resolution strategy for expressions in bean definition values */
|
||||
@Nullable
|
||||
private BeanExpressionResolver beanExpressionResolver;
|
||||
|
||||
/** Spring ConversionService to use instead of PropertyEditors */
|
||||
@Nullable
|
||||
private ConversionService conversionService;
|
||||
|
||||
/** Custom PropertyEditorRegistrars to apply to the beans of this factory */
|
||||
@@ -137,6 +142,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
private final Map<Class<?>, Class<? extends PropertyEditor>> customEditors = new HashMap<>(4);
|
||||
|
||||
/** A custom TypeConverter to use, overriding the default PropertyEditor mechanism */
|
||||
@Nullable
|
||||
private TypeConverter typeConverter;
|
||||
|
||||
/** String resolvers to apply e.g. to annotation attribute values */
|
||||
@@ -155,6 +161,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
private final Map<String, Scope> scopes = new LinkedHashMap<>(8);
|
||||
|
||||
/** Security context used when running with a SecurityManager */
|
||||
@Nullable
|
||||
private SecurityContextProvider securityContextProvider;
|
||||
|
||||
/** Map from bean name to merged RootBeanDefinition */
|
||||
@@ -681,6 +688,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BeanFactory getParentBeanFactory() {
|
||||
return this.parentBeanFactory;
|
||||
}
|
||||
@@ -711,6 +719,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ClassLoader getBeanClassLoader() {
|
||||
return this.beanClassLoader;
|
||||
}
|
||||
@@ -721,6 +730,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ClassLoader getTempClassLoader() {
|
||||
return this.tempClassLoader;
|
||||
}
|
||||
@@ -741,6 +751,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BeanExpressionResolver getBeanExpressionResolver() {
|
||||
return this.beanExpressionResolver;
|
||||
}
|
||||
@@ -751,6 +762,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ConversionService getConversionService() {
|
||||
return this.conversionService;
|
||||
}
|
||||
@@ -1172,7 +1184,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
Throwable rootCause = ex.getMostSpecificCause();
|
||||
if (rootCause instanceof BeanCurrentlyInCreationException) {
|
||||
BeanCreationException bce = (BeanCreationException) rootCause;
|
||||
if (isCurrentlyInCreation(bce.getBeanName())) {
|
||||
String bceBeanName = bce.getBeanName();
|
||||
if (bceBeanName != null && isCurrentlyInCreation(bceBeanName)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("PropertyEditorRegistrar [" + registrar.getClass().getName() +
|
||||
"] failed because it tried to obtain currently created bean '" +
|
||||
|
||||
@@ -191,10 +191,11 @@ abstract class AutowireUtils {
|
||||
* @return the resolved target return type or the standard method return type
|
||||
* @since 3.2.5
|
||||
*/
|
||||
public static Class<?> resolveReturnTypeForFactoryMethod(Method method, Object[] args, ClassLoader classLoader) {
|
||||
public static Class<?> resolveReturnTypeForFactoryMethod(
|
||||
Method method, Object[] args, @Nullable ClassLoader classLoader) {
|
||||
|
||||
Assert.notNull(method, "Method must not be null");
|
||||
Assert.notNull(args, "Argument array must not be null");
|
||||
Assert.notNull(classLoader, "ClassLoader must not be null");
|
||||
|
||||
TypeVariable<Method>[] declaredTypeVariables = method.getTypeParameters();
|
||||
Type genericReturnType = method.getGenericReturnType();
|
||||
|
||||
@@ -33,8 +33,10 @@ public class BeanDefinitionDefaults {
|
||||
|
||||
private int autowireMode = AbstractBeanDefinition.AUTOWIRE_NO;
|
||||
|
||||
@Nullable
|
||||
private String initMethodName;
|
||||
|
||||
@Nullable
|
||||
private String destroyMethodName;
|
||||
|
||||
|
||||
|
||||
@@ -194,6 +194,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt
|
||||
*/
|
||||
private static class ClassLoaderAwareGeneratorStrategy extends DefaultGeneratorStrategy {
|
||||
|
||||
@Nullable
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
public ClassLoaderAwareGeneratorStrategy(@Nullable ClassLoader classLoader) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -46,6 +46,7 @@ import org.springframework.util.ObjectUtils;
|
||||
@SuppressWarnings("serial")
|
||||
public class ChildBeanDefinition extends AbstractBeanDefinition {
|
||||
|
||||
@Nullable
|
||||
private String parentName;
|
||||
|
||||
|
||||
@@ -135,6 +136,7 @@ public class ChildBeanDefinition extends AbstractBeanDefinition {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getParentName() {
|
||||
return this.parentName;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,8 @@ import org.springframework.util.StringUtils;
|
||||
public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFactory
|
||||
implements ConfigurableListableBeanFactory, BeanDefinitionRegistry, Serializable {
|
||||
|
||||
private static Class<?> javaxInjectProviderClass = null;
|
||||
@Nullable
|
||||
private static Class<?> javaxInjectProviderClass;
|
||||
|
||||
static {
|
||||
try {
|
||||
@@ -126,6 +127,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
// JSR-330 API not available - Provider interface simply not supported then.
|
||||
javaxInjectProviderClass = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +137,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
new ConcurrentHashMap<>(8);
|
||||
|
||||
/** Optional id for this factory, for serialization purposes */
|
||||
@Nullable
|
||||
private String serializationId;
|
||||
|
||||
/** Whether to allow re-registration of a different definition with the same name */
|
||||
@@ -144,6 +147,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
private boolean allowEagerClassLoading = true;
|
||||
|
||||
/** Optional OrderComparator for dependency Lists and arrays */
|
||||
@Nullable
|
||||
private Comparator<Object> dependencyComparator;
|
||||
|
||||
/** Resolver to use for checking if a bean definition is an autowire candidate */
|
||||
@@ -168,6 +172,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
private volatile Set<String> manualSingletonNames = new LinkedHashSet<>(16);
|
||||
|
||||
/** Cached array of bean definition names in case of frozen configuration */
|
||||
@Nullable
|
||||
private volatile String[] frozenBeanDefinitionNames;
|
||||
|
||||
/** Whether bean definition metadata may be cached for all beans */
|
||||
@@ -209,6 +214,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
* to be deserialized from this id back into the BeanFactory object, if needed.
|
||||
* @since 4.1.2
|
||||
*/
|
||||
@Nullable
|
||||
public String getSerializationId() {
|
||||
return this.serializationId;
|
||||
}
|
||||
@@ -360,8 +366,9 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
|
||||
@Override
|
||||
public String[] getBeanDefinitionNames() {
|
||||
if (this.frozenBeanDefinitionNames != null) {
|
||||
return this.frozenBeanDefinitionNames.clone();
|
||||
String[] frozenNames = this.frozenBeanDefinitionNames;
|
||||
if (frozenNames != null) {
|
||||
return frozenNames.clone();
|
||||
}
|
||||
else {
|
||||
return StringUtils.toStringArray(this.beanDefinitionNames);
|
||||
@@ -511,9 +518,10 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
Throwable rootCause = ex.getMostSpecificCause();
|
||||
if (rootCause instanceof BeanCurrentlyInCreationException) {
|
||||
BeanCreationException bce = (BeanCreationException) rootCause;
|
||||
if (isCurrentlyInCreation(bce.getBeanName())) {
|
||||
String exBeanName = bce.getBeanName();
|
||||
if (exBeanName != null && isCurrentlyInCreation(exBeanName)) {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Ignoring match to currently created bean '" + beanName + "': " +
|
||||
this.logger.debug("Ignoring match to currently created bean '" + exBeanName + "': " +
|
||||
ex.getMessage());
|
||||
}
|
||||
onSuppressedException(ex);
|
||||
@@ -1595,6 +1603,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
|
||||
private final boolean optional;
|
||||
|
||||
@Nullable
|
||||
private final String beanName;
|
||||
|
||||
public DependencyObjectProvider(DependencyDescriptor descriptor, @Nullable String beanName) {
|
||||
|
||||
@@ -104,6 +104,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
|
||||
Collections.newSetFromMap(new ConcurrentHashMap<>(16));
|
||||
|
||||
/** List of suppressed Exceptions, available for associating related causes */
|
||||
@Nullable
|
||||
private Set<Exception> suppressedExceptions;
|
||||
|
||||
/** Flag that indicates whether we're currently within destroySingletons */
|
||||
|
||||
@@ -77,12 +77,16 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
|
||||
private final boolean nonPublicAccessAllowed;
|
||||
|
||||
@Nullable
|
||||
private final AccessControlContext acc;
|
||||
|
||||
@Nullable
|
||||
private String destroyMethodName;
|
||||
|
||||
@Nullable
|
||||
private transient Method destroyMethod;
|
||||
|
||||
@Nullable
|
||||
private List<DestructionAwareBeanPostProcessor> beanPostProcessors;
|
||||
|
||||
|
||||
@@ -108,7 +112,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
if (destroyMethodName != null && !(this.invokeDisposableBean && "destroy".equals(destroyMethodName)) &&
|
||||
!beanDefinition.isExternallyManagedDestroyMethod(destroyMethodName)) {
|
||||
this.destroyMethodName = destroyMethodName;
|
||||
this.destroyMethod = determineDestroyMethod();
|
||||
this.destroyMethod = determineDestroyMethod(destroyMethodName);
|
||||
if (this.destroyMethod == null) {
|
||||
if (beanDefinition.isEnforceDestroyMethod()) {
|
||||
throw new BeanDefinitionValidationException("Couldn't find a destroy method named '" +
|
||||
@@ -139,7 +143,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
public DisposableBeanAdapter(Object bean, List<BeanPostProcessor> postProcessors, AccessControlContext acc) {
|
||||
Assert.notNull(bean, "Disposable bean must not be null");
|
||||
this.bean = bean;
|
||||
this.beanName = null;
|
||||
this.beanName = bean.getClass().getName();
|
||||
this.invokeDisposableBean = (this.bean instanceof DisposableBean);
|
||||
this.nonPublicAccessAllowed = true;
|
||||
this.acc = acc;
|
||||
@@ -150,7 +154,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
* Create a new DisposableBeanAdapter for the given bean.
|
||||
*/
|
||||
private DisposableBeanAdapter(Object bean, String beanName, boolean invokeDisposableBean,
|
||||
boolean nonPublicAccessAllowed, String destroyMethodName,
|
||||
boolean nonPublicAccessAllowed, @Nullable String destroyMethodName,
|
||||
@Nullable List<DestructionAwareBeanPostProcessor> postProcessors) {
|
||||
|
||||
this.bean = bean;
|
||||
@@ -267,7 +271,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
invokeCustomDestroyMethod(this.destroyMethod);
|
||||
}
|
||||
else if (this.destroyMethodName != null) {
|
||||
Method methodToCall = determineDestroyMethod();
|
||||
Method methodToCall = determineDestroyMethod(this.destroyMethodName);
|
||||
if (methodToCall != null) {
|
||||
invokeCustomDestroyMethod(methodToCall);
|
||||
}
|
||||
@@ -276,13 +280,13 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
|
||||
|
||||
@Nullable
|
||||
private Method determineDestroyMethod() {
|
||||
private Method determineDestroyMethod(String name) {
|
||||
try {
|
||||
if (System.getSecurityManager() != null) {
|
||||
return AccessController.doPrivileged((PrivilegedAction<Method>) () -> findDestroyMethod());
|
||||
return AccessController.doPrivileged((PrivilegedAction<Method>) () -> findDestroyMethod(name));
|
||||
}
|
||||
else {
|
||||
return findDestroyMethod();
|
||||
return findDestroyMethod(name);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
@@ -292,10 +296,10 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Method findDestroyMethod() {
|
||||
private Method findDestroyMethod(String name) {
|
||||
return (this.nonPublicAccessAllowed ?
|
||||
BeanUtils.findMethodWithMinimalParameters(this.bean.getClass(), this.destroyMethodName) :
|
||||
BeanUtils.findMethodWithMinimalParameters(this.bean.getClass().getMethods(), this.destroyMethodName));
|
||||
BeanUtils.findMethodWithMinimalParameters(this.bean.getClass(), name) :
|
||||
BeanUtils.findMethodWithMinimalParameters(this.bean.getClass().getMethods(), name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -39,6 +39,7 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class GenericBeanDefinition extends AbstractBeanDefinition {
|
||||
|
||||
@Nullable
|
||||
private String parentName;
|
||||
|
||||
|
||||
@@ -70,6 +71,7 @@ public class GenericBeanDefinition extends AbstractBeanDefinition {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getParentName() {
|
||||
return this.parentName;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.springframework.util.ClassUtils;
|
||||
public class GenericTypeAwareAutowireCandidateResolver extends SimpleAutowireCandidateResolver
|
||||
implements BeanFactoryAware {
|
||||
|
||||
@Nullable
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -33,8 +33,10 @@ import org.springframework.util.ObjectUtils;
|
||||
*/
|
||||
public class LookupOverride extends MethodOverride {
|
||||
|
||||
@Nullable
|
||||
private final String beanName;
|
||||
|
||||
@Nullable
|
||||
private Method method;
|
||||
|
||||
|
||||
@@ -65,6 +67,7 @@ public class LookupOverride extends MethodOverride {
|
||||
/**
|
||||
* Return the name of the bean that should be returned by this method.
|
||||
*/
|
||||
@Nullable
|
||||
public String getBeanName() {
|
||||
return this.beanName;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.beans.factory.support;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -29,6 +30,7 @@ import org.springframework.util.Assert;
|
||||
public class ManagedArray extends ManagedList<Object> {
|
||||
|
||||
/** Resolved element type for runtime creation of the target array */
|
||||
@Nullable
|
||||
volatile Class<?> resolvedElementType;
|
||||
|
||||
|
||||
|
||||
@@ -35,8 +35,10 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class ManagedList<E> extends ArrayList<E> implements Mergeable, BeanMetadataElement {
|
||||
|
||||
@Nullable
|
||||
private Object source;
|
||||
|
||||
@Nullable
|
||||
private String elementTypeName;
|
||||
|
||||
private boolean mergeEnabled;
|
||||
@@ -59,6 +61,7 @@ public class ManagedList<E> extends ArrayList<E> implements Mergeable, BeanMetad
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
@@ -73,6 +76,7 @@ public class ManagedList<E> extends ArrayList<E> implements Mergeable, BeanMetad
|
||||
/**
|
||||
* Return the default element type name (class name) to be used for this list.
|
||||
*/
|
||||
@Nullable
|
||||
public String getElementTypeName() {
|
||||
return this.elementTypeName;
|
||||
}
|
||||
|
||||
@@ -34,10 +34,13 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class ManagedMap<K, V> extends LinkedHashMap<K, V> implements Mergeable, BeanMetadataElement {
|
||||
|
||||
@Nullable
|
||||
private Object source;
|
||||
|
||||
@Nullable
|
||||
private String keyTypeName;
|
||||
|
||||
@Nullable
|
||||
private String valueTypeName;
|
||||
|
||||
private boolean mergeEnabled;
|
||||
@@ -60,6 +63,7 @@ public class ManagedMap<K, V> extends LinkedHashMap<K, V> implements Mergeable,
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
@@ -74,6 +78,7 @@ public class ManagedMap<K, V> extends LinkedHashMap<K, V> implements Mergeable,
|
||||
/**
|
||||
* Return the default key type name (class name) to be used for this map.
|
||||
*/
|
||||
@Nullable
|
||||
public String getKeyTypeName() {
|
||||
return this.keyTypeName;
|
||||
}
|
||||
@@ -88,6 +93,7 @@ public class ManagedMap<K, V> extends LinkedHashMap<K, V> implements Mergeable,
|
||||
/**
|
||||
* Return the default value type name (class name) to be used for this map.
|
||||
*/
|
||||
@Nullable
|
||||
public String getValueTypeName() {
|
||||
return this.valueTypeName;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class ManagedProperties extends Properties implements Mergeable, BeanMetadataElement {
|
||||
|
||||
@Nullable
|
||||
private Object source;
|
||||
|
||||
private boolean mergeEnabled;
|
||||
@@ -47,6 +48,7 @@ public class ManagedProperties extends Properties implements Mergeable, BeanMeta
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,10 @@ import org.springframework.lang.Nullable;
|
||||
@SuppressWarnings("serial")
|
||||
public class ManagedSet<E> extends LinkedHashSet<E> implements Mergeable, BeanMetadataElement {
|
||||
|
||||
@Nullable
|
||||
private Object source;
|
||||
|
||||
@Nullable
|
||||
private String elementTypeName;
|
||||
|
||||
private boolean mergeEnabled;
|
||||
@@ -58,6 +60,7 @@ public class ManagedSet<E> extends LinkedHashSet<E> implements Mergeable, BeanMe
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
@@ -72,6 +75,7 @@ public class ManagedSet<E> extends LinkedHashSet<E> implements Mergeable, BeanMe
|
||||
/**
|
||||
* Return the default element type name (class name) to be used for this set.
|
||||
*/
|
||||
@Nullable
|
||||
public String getElementTypeName() {
|
||||
return this.elementTypeName;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public abstract class MethodOverride implements BeanMetadataElement {
|
||||
|
||||
private boolean overloaded = true;
|
||||
|
||||
@Nullable
|
||||
private Object source;
|
||||
|
||||
|
||||
@@ -88,6 +89,7 @@ public abstract class MethodOverride implements BeanMetadataElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@@ -141,6 +141,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
|
||||
public static final String CONSTRUCTOR_ARG_PREFIX = "$";
|
||||
|
||||
|
||||
@Nullable
|
||||
private String defaultParentBean;
|
||||
|
||||
private PropertiesPersister propertiesPersister = new DefaultPropertiesPersister();
|
||||
@@ -168,13 +169,14 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
|
||||
* not apply to a bean definition that carries a class is there for
|
||||
* backwards compatibility reasons. It still matches the typical use case.
|
||||
*/
|
||||
public void setDefaultParentBean(String defaultParentBean) {
|
||||
public void setDefaultParentBean(@Nullable String defaultParentBean) {
|
||||
this.defaultParentBean = defaultParentBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default parent bean for this bean factory.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDefaultParentBean() {
|
||||
return this.defaultParentBean;
|
||||
}
|
||||
|
||||
@@ -53,35 +53,43 @@ import org.springframework.util.Assert;
|
||||
@SuppressWarnings("serial")
|
||||
public class RootBeanDefinition extends AbstractBeanDefinition {
|
||||
|
||||
@Nullable
|
||||
private BeanDefinitionHolder decoratedDefinition;
|
||||
|
||||
@Nullable
|
||||
private AnnotatedElement qualifiedElement;
|
||||
|
||||
boolean allowCaching = true;
|
||||
|
||||
boolean isFactoryMethodUnique = false;
|
||||
|
||||
@Nullable
|
||||
volatile ResolvableType targetType;
|
||||
|
||||
/** Package-visible field for caching the determined Class of a given bean definition */
|
||||
@Nullable
|
||||
volatile Class<?> resolvedTargetType;
|
||||
|
||||
/** Package-visible field for caching the return type of a generically typed factory method */
|
||||
@Nullable
|
||||
volatile ResolvableType factoryMethodReturnType;
|
||||
|
||||
/** Common lock for the four constructor fields below */
|
||||
final Object constructorArgumentLock = new Object();
|
||||
|
||||
/** Package-visible field for caching the resolved constructor or factory method */
|
||||
@Nullable
|
||||
Executable resolvedConstructorOrFactoryMethod;
|
||||
|
||||
/** Package-visible field that marks the constructor arguments as resolved */
|
||||
boolean constructorArgumentsResolved = false;
|
||||
|
||||
/** Package-visible field for caching fully resolved constructor arguments */
|
||||
@Nullable
|
||||
Object[] resolvedConstructorArguments;
|
||||
|
||||
/** Package-visible field for caching partly prepared constructor arguments */
|
||||
@Nullable
|
||||
Object[] preparedConstructorArguments;
|
||||
|
||||
/** Common lock for the two post-processing fields below */
|
||||
@@ -91,12 +99,16 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
|
||||
boolean postProcessed = false;
|
||||
|
||||
/** Package-visible field that indicates a before-instantiation post-processor having kicked in */
|
||||
@Nullable
|
||||
volatile Boolean beforeInstantiationResolved;
|
||||
|
||||
@Nullable
|
||||
private Set<Member> externallyManagedConfigMembers;
|
||||
|
||||
@Nullable
|
||||
private Set<String> externallyManagedInitMethods;
|
||||
|
||||
@Nullable
|
||||
private Set<String> externallyManagedDestroyMethods;
|
||||
|
||||
|
||||
@@ -304,7 +316,8 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
|
||||
if (this.resolvedTargetType != null) {
|
||||
return this.resolvedTargetType;
|
||||
}
|
||||
return (this.targetType != null ? this.targetType.resolve() : null);
|
||||
ResolvableType targetType = this.targetType;
|
||||
return (targetType != null ? targetType.resolve() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -29,6 +29,7 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class SimpleSecurityContextProvider implements SecurityContextProvider {
|
||||
|
||||
@Nullable
|
||||
private final AccessControlContext acc;
|
||||
|
||||
|
||||
|
||||
@@ -52,8 +52,10 @@ public class BeanConfigurerSupport implements BeanFactoryAware, InitializingBean
|
||||
/** Logger available to subclasses */
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Nullable
|
||||
private volatile BeanWiringInfoResolver beanWiringInfoResolver;
|
||||
|
||||
@Nullable
|
||||
private volatile ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
|
||||
@@ -130,29 +132,35 @@ public class BeanConfigurerSupport implements BeanFactoryAware, InitializingBean
|
||||
return;
|
||||
}
|
||||
|
||||
BeanWiringInfo bwi = this.beanWiringInfoResolver.resolveWiringInfo(beanInstance);
|
||||
BeanWiringInfoResolver bwiResolver = this.beanWiringInfoResolver;
|
||||
Assert.state(bwiResolver != null, "No BeanWiringInfoResolver available");
|
||||
BeanWiringInfo bwi = bwiResolver.resolveWiringInfo(beanInstance);
|
||||
if (bwi == null) {
|
||||
// Skip the bean if no wiring info given.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ConfigurableListableBeanFactory beanFactory = this.beanFactory;
|
||||
Assert.state(beanFactory != null, "No BeanFactory available");
|
||||
try {
|
||||
if (bwi.indicatesAutowiring() || (bwi.isDefaultBeanName() && bwi.getBeanName() != null &&
|
||||
!this.beanFactory.containsBean(bwi.getBeanName()))) {
|
||||
!beanFactory.containsBean(bwi.getBeanName()))) {
|
||||
// Perform autowiring (also applying standard factory / post-processor callbacks).
|
||||
this.beanFactory.autowireBeanProperties(beanInstance, bwi.getAutowireMode(), bwi.getDependencyCheck());
|
||||
this.beanFactory.initializeBean(beanInstance, bwi.getBeanName());
|
||||
beanFactory.autowireBeanProperties(beanInstance, bwi.getAutowireMode(), bwi.getDependencyCheck());
|
||||
beanFactory.initializeBean(beanInstance, bwi.getBeanName());
|
||||
}
|
||||
else {
|
||||
// Perform explicit wiring based on the specified bean definition.
|
||||
this.beanFactory.configureBean(beanInstance, bwi.getBeanName());
|
||||
beanFactory.configureBean(beanInstance, bwi.getBeanName());
|
||||
}
|
||||
}
|
||||
catch (BeanCreationException ex) {
|
||||
Throwable rootCause = ex.getMostSpecificCause();
|
||||
if (rootCause instanceof BeanCurrentlyInCreationException) {
|
||||
BeanCreationException bce = (BeanCreationException) rootCause;
|
||||
if (this.beanFactory.isCurrentlyInCreation(bce.getBeanName())) {
|
||||
String bceBeanName = bce.getBeanName();
|
||||
if (bceBeanName != null && beanFactory.isCurrentlyInCreation(bceBeanName)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to create target bean '" + bce.getBeanName() +
|
||||
"' while configuring object of type [" + beanInstance.getClass().getName() +
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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,7 +49,8 @@ public class BeanWiringInfo {
|
||||
public static final int AUTOWIRE_BY_TYPE = AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE;
|
||||
|
||||
|
||||
private String beanName = null;
|
||||
@Nullable
|
||||
private String beanName;
|
||||
|
||||
private boolean isDefaultBeanName = false;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.xml;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -75,9 +76,10 @@ public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef
|
||||
}
|
||||
}
|
||||
builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
|
||||
if (parserContext.isNested()) {
|
||||
BeanDefinition containingBd = parserContext.getContainingBeanDefinition();
|
||||
if (containingBd != null) {
|
||||
// Inner bean definition must receive same scope as containing bean.
|
||||
String scopeName = parserContext.getContainingBeanDefinition().getScope();
|
||||
String scopeName = containingBd.getScope();
|
||||
if (scopeName != null) {
|
||||
builder.setScope(scopeName);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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,12 +59,14 @@ public class DefaultNamespaceHandlerResolver implements NamespaceHandlerResolver
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
/** ClassLoader to use for NamespaceHandler classes */
|
||||
@Nullable
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
/** Resource location to search for */
|
||||
private final String handlerMappingsLocation;
|
||||
|
||||
/** Stores the mappings from namespace URI to NamespaceHandler class name / instance */
|
||||
@Nullable
|
||||
private volatile Map<String, Object> handlerMappings;
|
||||
|
||||
|
||||
@@ -148,17 +150,20 @@ public class DefaultNamespaceHandlerResolver implements NamespaceHandlerResolver
|
||||
* Load the specified NamespaceHandler mappings lazily.
|
||||
*/
|
||||
private Map<String, Object> getHandlerMappings() {
|
||||
if (this.handlerMappings == null) {
|
||||
Map<String, Object> handlerMappings = this.handlerMappings;
|
||||
if (handlerMappings == null) {
|
||||
synchronized (this) {
|
||||
if (this.handlerMappings == null) {
|
||||
handlerMappings = this.handlerMappings;
|
||||
if (handlerMappings == null) {
|
||||
try {
|
||||
Properties mappings =
|
||||
PropertiesLoaderUtils.loadAllProperties(this.handlerMappingsLocation, this.classLoader);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Loaded NamespaceHandler mappings: " + mappings);
|
||||
}
|
||||
Map<String, Object> handlerMappings = new ConcurrentHashMap<>(mappings.size());
|
||||
CollectionUtils.mergePropertiesIntoMap(mappings, handlerMappings);
|
||||
Map<String, Object> mappingsToUse = new ConcurrentHashMap<>(mappings.size());
|
||||
CollectionUtils.mergePropertiesIntoMap(mappings, mappingsToUse);
|
||||
handlerMappings = mappingsToUse;
|
||||
this.handlerMappings = handlerMappings;
|
||||
}
|
||||
catch (IOException ex) {
|
||||
@@ -168,7 +173,7 @@ public class DefaultNamespaceHandlerResolver implements NamespaceHandlerResolver
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.handlerMappings;
|
||||
return handlerMappings;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,18 +29,25 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class DocumentDefaultsDefinition implements DefaultsDefinition {
|
||||
|
||||
@Nullable
|
||||
private String lazyInit;
|
||||
|
||||
@Nullable
|
||||
private String merge;
|
||||
|
||||
@Nullable
|
||||
private String autowire;
|
||||
|
||||
@Nullable
|
||||
private String autowireCandidates;
|
||||
|
||||
@Nullable
|
||||
private String initMethod;
|
||||
|
||||
@Nullable
|
||||
private String destroyMethod;
|
||||
|
||||
@Nullable
|
||||
private Object source;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -43,6 +43,7 @@ public final class ParserContext {
|
||||
|
||||
private final BeanDefinitionParserDelegate delegate;
|
||||
|
||||
@Nullable
|
||||
private BeanDefinition containingBeanDefinition;
|
||||
|
||||
private final Stack<ComponentDefinition> containingComponents = new Stack<>();
|
||||
@@ -74,6 +75,7 @@ public final class ParserContext {
|
||||
return this.delegate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public final BeanDefinition getContainingBeanDefinition() {
|
||||
return this.containingBeanDefinition;
|
||||
}
|
||||
|
||||
@@ -66,11 +66,13 @@ public class PluggableSchemaResolver implements EntityResolver {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(PluggableSchemaResolver.class);
|
||||
|
||||
@Nullable
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
private final String schemaMappingsLocation;
|
||||
|
||||
/** Stores the mapping of schema URL -> local schema path */
|
||||
@Nullable
|
||||
private volatile Map<String, String> schemaMappings;
|
||||
|
||||
|
||||
@@ -136,9 +138,11 @@ public class PluggableSchemaResolver implements EntityResolver {
|
||||
* Load the specified schema mappings lazily.
|
||||
*/
|
||||
private Map<String, String> getSchemaMappings() {
|
||||
if (this.schemaMappings == null) {
|
||||
Map<String, String> schemaMappings = this.schemaMappings;
|
||||
if (schemaMappings == null) {
|
||||
synchronized (this) {
|
||||
if (this.schemaMappings == null) {
|
||||
schemaMappings = this.schemaMappings;
|
||||
if (schemaMappings == null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Loading schema mappings from [" + this.schemaMappingsLocation + "]");
|
||||
}
|
||||
@@ -148,8 +152,9 @@ public class PluggableSchemaResolver implements EntityResolver {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Loaded schema mappings: " + mappings);
|
||||
}
|
||||
Map<String, String> schemaMappings = new ConcurrentHashMap<>(mappings.size());
|
||||
CollectionUtils.mergePropertiesIntoMap(mappings, schemaMappings);
|
||||
Map<String, String> mappingsToUse = new ConcurrentHashMap<>(mappings.size());
|
||||
CollectionUtils.mergePropertiesIntoMap(mappings, mappingsToUse);
|
||||
schemaMappings = mappingsToUse;
|
||||
this.schemaMappings = schemaMappings;
|
||||
}
|
||||
catch (IOException ex) {
|
||||
@@ -159,7 +164,7 @@ public class PluggableSchemaResolver implements EntityResolver {
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.schemaMappings;
|
||||
return schemaMappings;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -113,10 +113,12 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
|
||||
|
||||
private SourceExtractor sourceExtractor = new NullSourceExtractor();
|
||||
|
||||
@Nullable
|
||||
private NamespaceHandlerResolver namespaceHandlerResolver;
|
||||
|
||||
private DocumentLoader documentLoader = new DefaultDocumentLoader();
|
||||
|
||||
@Nullable
|
||||
private EntityResolver entityResolver;
|
||||
|
||||
private ErrorHandler errorHandler = new SimpleSaxErrorHandler(logger);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +37,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class ClassArrayEditor extends PropertyEditorSupport {
|
||||
|
||||
@Nullable
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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,6 +38,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class ClassEditor extends PropertyEditorSupport {
|
||||
|
||||
@Nullable
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
|
||||
|
||||
@@ -51,8 +51,10 @@ public class CustomBooleanEditor extends PropertyEditorSupport {
|
||||
public static final String VALUE_0 = "0";
|
||||
|
||||
|
||||
@Nullable
|
||||
private final String trueString;
|
||||
|
||||
@Nullable
|
||||
private final String falseString;
|
||||
|
||||
private final boolean allowEmpty;
|
||||
|
||||
@@ -47,6 +47,7 @@ public class CustomNumberEditor extends PropertyEditorSupport {
|
||||
|
||||
private final Class<? extends Number> numberClass;
|
||||
|
||||
@Nullable
|
||||
private final NumberFormat numberFormat;
|
||||
|
||||
private final boolean allowEmpty;
|
||||
|
||||
@@ -44,6 +44,7 @@ public class StringArrayPropertyEditor extends PropertyEditorSupport {
|
||||
|
||||
private final String separator;
|
||||
|
||||
@Nullable
|
||||
private final String charsToDelete;
|
||||
|
||||
private final boolean emptyArrayAsNull;
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class StringTrimmerEditor extends PropertyEditorSupport {
|
||||
|
||||
@Nullable
|
||||
private final String charsToDelete;
|
||||
|
||||
private final boolean emptyAsNull;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -50,6 +50,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class URIEditor extends PropertyEditorSupport {
|
||||
|
||||
@Nullable
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
private final boolean encode;
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
*/
|
||||
public class ArgumentConvertingMethodInvoker extends MethodInvoker {
|
||||
|
||||
@Nullable
|
||||
private TypeConverter typeConverter;
|
||||
|
||||
private boolean useDefaultConverter = true;
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.beans.support;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -56,12 +57,15 @@ public class PagedListHolder<E> implements Serializable {
|
||||
public static final int DEFAULT_MAX_LINKED_PAGES = 10;
|
||||
|
||||
|
||||
private List<E> source;
|
||||
private List<E> source = Collections.emptyList();
|
||||
|
||||
@Nullable
|
||||
private Date refreshDate;
|
||||
|
||||
@Nullable
|
||||
private SortDefinition sort;
|
||||
|
||||
@Nullable
|
||||
private SortDefinition sortUsed;
|
||||
|
||||
private int pageSize = DEFAULT_PAGE_SIZE;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -135,7 +135,7 @@ public class PropertyComparator<T> implements Comparator<T> {
|
||||
*/
|
||||
public static void sort(List<?> source, SortDefinition sortDefinition) throws BeansException {
|
||||
if (StringUtils.hasText(sortDefinition.getProperty())) {
|
||||
Collections.sort(source, new PropertyComparator<Object>(sortDefinition));
|
||||
Collections.sort(source, new PropertyComparator<>(sortDefinition));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user