Introduce null-safety of Spring Framework API
This commit introduces 2 new @Nullable and @NonNullApi annotations that leverage JSR 305 (dormant but available via Findbugs jsr305 dependency and already used by libraries like OkHttp) meta-annotations to specify explicitly null-safety of Spring Framework parameters and return values. In order to avoid adding too much annotations, the default is set at package level with @NonNullApi and @Nullable annotations are added when needed at parameter or return value level. These annotations are intended to be used on Spring Framework itself but also by other Spring projects. @Nullable annotations have been introduced based on Javadoc and search of patterns like "return null;". It is expected that nullability of Spring Framework API will be polished with complementary commits. In practice, this will make the whole Spring Framework API null-safe for Kotlin projects (when KT-10942 will be fixed) since Kotlin will be able to leverage these annotations to know if a parameter or a return value is nullable or not. But this is also useful for Java developers as well since IntelliJ IDEA, for example, also understands these annotations to generate warnings when unsafe nullable usages are detected. Issue: SPR-15540
This commit is contained in:
@@ -40,6 +40,7 @@ import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.convert.ConversionException;
|
||||
import org.springframework.core.convert.ConverterNotFoundException;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -715,6 +716,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
* or {@code null} if not found
|
||||
* @throws BeansException in case of introspection failure
|
||||
*/
|
||||
@Nullable
|
||||
protected PropertyHandler getPropertyHandler(String propertyName) throws BeansException {
|
||||
Assert.notNull(propertyName, "Property name must not be null");
|
||||
AbstractNestablePropertyAccessor nestedPa = getPropertyAccessorForPropertyPath(propertyName);
|
||||
@@ -727,6 +729,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
* @param propertyName the name of a local property
|
||||
* @return the handler for that property or {@code null} if it has not been found
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract PropertyHandler getLocalPropertyHandler(String propertyName);
|
||||
|
||||
/**
|
||||
@@ -1016,6 +1019,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
||||
|
||||
public abstract TypeDescriptor nested(int level);
|
||||
|
||||
@Nullable
|
||||
public abstract Object getValue() throws Exception;
|
||||
|
||||
public abstract void setValue(Object object, Object value) throws Exception;
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.beans;
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.IntrospectionException;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Strategy interface for creating {@link BeanInfo} instances for Spring beans.
|
||||
* Can be used to plug in custom bean property resolution strategies (e.g. for other
|
||||
@@ -52,6 +54,7 @@ public interface BeanInfoFactory {
|
||||
* @return the BeanInfo, or {@code null} if the given class is not supported
|
||||
* @throws IntrospectionException in case of exceptions
|
||||
*/
|
||||
@Nullable
|
||||
BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException;
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.beans;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Exception thrown when instantiation of a bean failed.
|
||||
* Carries the offending bean class.
|
||||
@@ -98,6 +100,7 @@ public class BeanInstantiationException extends FatalBeanException {
|
||||
* factory method or in case of default instantiation
|
||||
* @since 4.3
|
||||
*/
|
||||
@Nullable
|
||||
public Constructor<?> getConstructor() {
|
||||
return this.constructor;
|
||||
}
|
||||
@@ -108,6 +111,7 @@ public class BeanInstantiationException extends FatalBeanException {
|
||||
* or {@code null} in case of constructor-based instantiation
|
||||
* @since 4.3
|
||||
*/
|
||||
@Nullable
|
||||
public Method getConstructingMethod() {
|
||||
return this.constructingMethod;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans;
|
||||
|
||||
import org.springframework.core.AttributeAccessorSupport;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Extension of {@link org.springframework.core.AttributeAccessorSupport},
|
||||
@@ -60,6 +61,7 @@ public class BeanMetadataAttributeAccessor extends AttributeAccessorSupport impl
|
||||
* @return the corresponding BeanMetadataAttribute object,
|
||||
* or {@code null} if no such attribute defined
|
||||
*/
|
||||
@Nullable
|
||||
public BeanMetadataAttribute getMetadataAttribute(String name) {
|
||||
return (BeanMetadataAttribute) super.getAttribute(name);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.beans;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by bean metadata elements
|
||||
* that carry a configuration source object.
|
||||
@@ -29,6 +31,7 @@ public interface BeanMetadataElement {
|
||||
* Return the configuration source {@code Object} for this metadata element
|
||||
* (may be {@code null}).
|
||||
*/
|
||||
@Nullable
|
||||
Object getSource();
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
@@ -172,6 +173,7 @@ public abstract class BeanUtils {
|
||||
* @see Class#getMethod
|
||||
* @see #findDeclaredMethod
|
||||
*/
|
||||
@Nullable
|
||||
public static Method findMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) {
|
||||
try {
|
||||
return clazz.getMethod(methodName, paramTypes);
|
||||
@@ -192,6 +194,7 @@ public abstract class BeanUtils {
|
||||
* @return the Method object, or {@code null} if not found
|
||||
* @see Class#getDeclaredMethod
|
||||
*/
|
||||
@Nullable
|
||||
public static Method findDeclaredMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) {
|
||||
try {
|
||||
return clazz.getDeclaredMethod(methodName, paramTypes);
|
||||
@@ -219,6 +222,7 @@ public abstract class BeanUtils {
|
||||
* @see Class#getMethods
|
||||
* @see #findDeclaredMethodWithMinimalParameters
|
||||
*/
|
||||
@Nullable
|
||||
public static Method findMethodWithMinimalParameters(Class<?> clazz, String methodName)
|
||||
throws IllegalArgumentException {
|
||||
|
||||
@@ -241,6 +245,7 @@ public abstract class BeanUtils {
|
||||
* could not be resolved to a unique method with minimal parameters
|
||||
* @see Class#getDeclaredMethods
|
||||
*/
|
||||
@Nullable
|
||||
public static Method findDeclaredMethodWithMinimalParameters(Class<?> clazz, String methodName)
|
||||
throws IllegalArgumentException {
|
||||
|
||||
@@ -260,6 +265,7 @@ public abstract class BeanUtils {
|
||||
* @throws IllegalArgumentException if methods of the given name were found but
|
||||
* could not be resolved to a unique method with minimal parameters
|
||||
*/
|
||||
@Nullable
|
||||
public static Method findMethodWithMinimalParameters(Method[] methods, String methodName)
|
||||
throws IllegalArgumentException {
|
||||
|
||||
@@ -311,6 +317,7 @@ public abstract class BeanUtils {
|
||||
* @see #findMethod
|
||||
* @see #findMethodWithMinimalParameters
|
||||
*/
|
||||
@Nullable
|
||||
public static Method resolveSignature(String signature, Class<?> clazz) {
|
||||
Assert.hasText(signature, "'signature' must not be empty");
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
@@ -365,6 +372,7 @@ public abstract class BeanUtils {
|
||||
* @return the corresponding PropertyDescriptor, or {@code null} if none
|
||||
* @throws BeansException if PropertyDescriptor lookup fails
|
||||
*/
|
||||
@Nullable
|
||||
public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String propertyName)
|
||||
throws BeansException {
|
||||
|
||||
@@ -381,6 +389,7 @@ public abstract class BeanUtils {
|
||||
* @return the corresponding PropertyDescriptor, or {@code null} if none
|
||||
* @throws BeansException if PropertyDescriptor lookup fails
|
||||
*/
|
||||
@Nullable
|
||||
public static PropertyDescriptor findPropertyForMethod(Method method) throws BeansException {
|
||||
return findPropertyForMethod(method, method.getDeclaringClass());
|
||||
}
|
||||
@@ -395,6 +404,7 @@ public abstract class BeanUtils {
|
||||
* @throws BeansException if PropertyDescriptor lookup fails
|
||||
* @since 3.2.13
|
||||
*/
|
||||
@Nullable
|
||||
public static PropertyDescriptor findPropertyForMethod(Method method, Class<?> clazz) throws BeansException {
|
||||
Assert.notNull(method, "Method must not be null");
|
||||
PropertyDescriptor[] pds = getPropertyDescriptors(clazz);
|
||||
@@ -415,6 +425,7 @@ public abstract class BeanUtils {
|
||||
* @param targetType the type to find an editor for
|
||||
* @return the corresponding editor, or {@code null} if none found
|
||||
*/
|
||||
@Nullable
|
||||
public static PropertyEditor findEditorByConvention(Class<?> targetType) {
|
||||
if (targetType == null || targetType.isArray() || unknownEditorTypes.contains(targetType)) {
|
||||
return null;
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.beans;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* The central interface of Spring's low-level JavaBeans infrastructure.
|
||||
*
|
||||
@@ -65,6 +67,7 @@ public interface BeanWrapper extends ConfigurablePropertyAccessor {
|
||||
* Return the bean instance wrapped by this object, if any.
|
||||
* @return the bean instance, or {@code null} if none set
|
||||
*/
|
||||
@Nullable
|
||||
Object getWrappedInstance();
|
||||
|
||||
/**
|
||||
@@ -72,6 +75,7 @@ public interface BeanWrapper extends ConfigurablePropertyAccessor {
|
||||
* @return the type of the wrapped bean instance,
|
||||
* or {@code null} if no wrapped object has been set
|
||||
*/
|
||||
@Nullable
|
||||
Class<?> getWrappedClass();
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans;
|
||||
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface that encapsulates configuration methods for a PropertyAccessor.
|
||||
@@ -41,6 +42,7 @@ public interface ConfigurablePropertyAccessor extends PropertyAccessor, Property
|
||||
/**
|
||||
* Return the associated ConversionService, if any.
|
||||
*/
|
||||
@Nullable
|
||||
ConversionService getConversionService();
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.beans;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Exception thrown when no suitable editor or converter can be found for a bean property.
|
||||
*
|
||||
@@ -35,7 +37,7 @@ public class ConversionNotSupportedException extends TypeMismatchException {
|
||||
* @param cause the root cause (may be {@code null})
|
||||
*/
|
||||
public ConversionNotSupportedException(PropertyChangeEvent propertyChangeEvent,
|
||||
Class<?> requiredType, Throwable cause) {
|
||||
@Nullable Class<?> requiredType, @Nullable Throwable cause) {
|
||||
super(propertyChangeEvent, requiredType, cause);
|
||||
}
|
||||
|
||||
@@ -45,7 +47,7 @@ public class ConversionNotSupportedException extends TypeMismatchException {
|
||||
* @param requiredType the required target type (or {@code null} if not known)
|
||||
* @param cause the root cause (may be {@code null})
|
||||
*/
|
||||
public ConversionNotSupportedException(Object value, Class<?> requiredType, Throwable cause) {
|
||||
public ConversionNotSupportedException(@Nullable Object value, @Nullable Class<?> requiredType, @Nullable Throwable cause) {
|
||||
super(value, requiredType, cause);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.TreeSet;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -188,6 +189,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PropertyDescriptor findExistingPropertyDescriptor(String propertyName, Class<?> propertyType) {
|
||||
for (PropertyDescriptor pd : this.propertyDescriptors) {
|
||||
final Class<?> candidateType;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.beans;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface representing an object whose value set can be merged with
|
||||
* that of a parent object.
|
||||
@@ -44,6 +46,6 @@ public interface Mergeable {
|
||||
* @exception IllegalStateException if merging is not enabled for this instance
|
||||
* (i.e. {@code mergeEnabled} equals {@code false}).
|
||||
*/
|
||||
Object merge(Object parent);
|
||||
Object merge(@Nullable Object parent);
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -267,6 +268,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable {
|
||||
* @see #getPropertyValue(String)
|
||||
* @see PropertyValue#getValue()
|
||||
*/
|
||||
@Nullable
|
||||
public Object get(String propertyName) {
|
||||
PropertyValue pv = getPropertyValue(propertyName);
|
||||
return (pv != null ? pv.getValue() : null);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.beans;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Exception thrown on an attempt to set the value of a property that
|
||||
* is not writable (typically because there is no setter method).
|
||||
@@ -80,6 +82,7 @@ public class NotWritablePropertyException extends InvalidPropertyException {
|
||||
* Return suggestions for actual bean property names that closely match
|
||||
* the invalid property name, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String[] getPossibleMatches() {
|
||||
return this.possibleMatches;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.beans;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Superclass for exceptions related to a property access,
|
||||
* such as type mismatch or invocation target exception.
|
||||
@@ -57,6 +59,7 @@ public abstract class PropertyAccessException extends BeansException {
|
||||
* <p>May be {@code null}; only available if an actual bean property
|
||||
* was affected.
|
||||
*/
|
||||
@Nullable
|
||||
public PropertyChangeEvent getPropertyChangeEvent() {
|
||||
return this.propertyChangeEvent;
|
||||
}
|
||||
@@ -71,6 +74,7 @@ public abstract class PropertyAccessException extends BeansException {
|
||||
/**
|
||||
* Return the affected value that was about to be set, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public Object getValue() {
|
||||
return (this.propertyChangeEvent != null ? this.propertyChangeEvent.getNewValue() : null);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.beans;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Common interface for classes that can access named properties
|
||||
@@ -86,6 +87,7 @@ public interface PropertyAccessor {
|
||||
* @throws PropertyAccessException if the property was valid but the
|
||||
* accessor method failed
|
||||
*/
|
||||
@Nullable
|
||||
Class<?> getPropertyType(String propertyName) throws BeansException;
|
||||
|
||||
/**
|
||||
@@ -98,6 +100,7 @@ public interface PropertyAccessor {
|
||||
* @throws InvalidPropertyException if there is no such property or
|
||||
* if the property isn't readable
|
||||
*/
|
||||
@Nullable
|
||||
TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.beans;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -71,6 +72,7 @@ public class PropertyBatchUpdateException extends BeansException {
|
||||
/**
|
||||
* Return the exception for this field, or {@code null} if there isn't any.
|
||||
*/
|
||||
@Nullable
|
||||
public PropertyAccessException getPropertyAccessException(String propertyName) {
|
||||
for (PropertyAccessException pae : this.propertyAccessExceptions) {
|
||||
if (ObjectUtils.nullSafeEquals(propertyName, pae.getPropertyName())) {
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.beans;
|
||||
|
||||
import java.beans.PropertyEditor;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Encapsulates methods for registering JavaBeans {@link PropertyEditor PropertyEditors}.
|
||||
* This is the central interface that a {@link PropertyEditorRegistrar} operates on.
|
||||
@@ -64,7 +66,7 @@ public interface PropertyEditorRegistry {
|
||||
* {@code null} if registering an editor for all properties of the given type
|
||||
* @param propertyEditor editor to register
|
||||
*/
|
||||
void registerCustomEditor(Class<?> requiredType, String propertyPath, PropertyEditor propertyEditor);
|
||||
void registerCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath, PropertyEditor propertyEditor);
|
||||
|
||||
/**
|
||||
* Find a custom property editor for the given type and property.
|
||||
@@ -74,6 +76,7 @@ public interface PropertyEditorRegistry {
|
||||
* {@code null} if looking for an editor for all properties of the given type
|
||||
* @return the registered editor, or {@code null} if none
|
||||
*/
|
||||
PropertyEditor findCustomEditor(Class<?> requiredType, String propertyPath);
|
||||
@Nullable
|
||||
PropertyEditor findCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath);
|
||||
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ import org.springframework.beans.propertyeditors.ZoneIdEditor;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.ResourceArrayPropertyEditor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
@@ -118,6 +119,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
/**
|
||||
* Return the associated ConversionService, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public ConversionService getConversionService() {
|
||||
return this.conversionService;
|
||||
}
|
||||
@@ -169,6 +171,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* @return the default editor, or {@code null} if none found
|
||||
* @see #registerDefaultEditors
|
||||
*/
|
||||
@Nullable
|
||||
public PropertyEditor getDefaultEditor(Class<?> requiredType) {
|
||||
if (!this.defaultEditorsActive) {
|
||||
return null;
|
||||
@@ -336,7 +339,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* can be {@code null} if not known)
|
||||
* @return whether a matching custom editor has been found
|
||||
*/
|
||||
public boolean hasCustomEditorForElement(Class<?> elementType, String propertyPath) {
|
||||
public boolean hasCustomEditorForElement(@Nullable Class<?> elementType, @Nullable String propertyPath) {
|
||||
if (propertyPath != null && this.customEditorsForPath != null) {
|
||||
for (Map.Entry<String, CustomEditorHolder> entry : this.customEditorsForPath.entrySet()) {
|
||||
if (PropertyAccessorUtils.matchesProperty(entry.getKey(), propertyPath)) {
|
||||
@@ -361,6 +364,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* @return the type of the property, or {@code null} if not determinable
|
||||
* @see BeanWrapper#getPropertyType(String)
|
||||
*/
|
||||
@Nullable
|
||||
protected Class<?> getPropertyType(String propertyPath) {
|
||||
return null;
|
||||
}
|
||||
@@ -371,6 +375,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* @param requiredType the type to look for
|
||||
* @return the custom editor, or {@code null} if none specific for this property
|
||||
*/
|
||||
@Nullable
|
||||
private PropertyEditor getCustomEditor(String propertyName, Class<?> requiredType) {
|
||||
CustomEditorHolder holder = this.customEditorsForPath.get(propertyName);
|
||||
return (holder != null ? holder.getPropertyEditor(requiredType) : null);
|
||||
@@ -384,6 +389,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* @return the custom editor, or {@code null} if none found for this type
|
||||
* @see java.beans.PropertyEditor#getAsText()
|
||||
*/
|
||||
@Nullable
|
||||
private PropertyEditor getCustomEditor(Class<?> requiredType) {
|
||||
if (requiredType == null || this.customEditors == null) {
|
||||
return null;
|
||||
@@ -420,6 +426,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* @param propertyName the name of the property
|
||||
* @return the property type, or {@code null} if not determinable
|
||||
*/
|
||||
@Nullable
|
||||
protected Class<?> guessPropertyTypeFromEditors(String propertyName) {
|
||||
if (this.customEditorsForPath != null) {
|
||||
CustomEditorHolder editorHolder = this.customEditorsForPath.get(propertyName);
|
||||
@@ -445,7 +452,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry {
|
||||
* If this is non-null, only editors registered for a path below this nested property
|
||||
* will be copied. If this is null, all editors will be copied.
|
||||
*/
|
||||
protected void copyCustomEditorsTo(PropertyEditorRegistry target, String nestedProperty) {
|
||||
protected void copyCustomEditorsTo(PropertyEditorRegistry target, @Nullable String nestedProperty) {
|
||||
String actualPropertyName =
|
||||
(nestedProperty != null ? PropertyAccessorUtils.getPropertyName(nestedProperty) : null);
|
||||
if (this.customEditors != null) {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.beans;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Holder containing one or more {@link PropertyValue} objects,
|
||||
* typically comprising one update for a specific target bean.
|
||||
@@ -37,6 +39,7 @@ public interface PropertyValues {
|
||||
* @param propertyName the name to search for
|
||||
* @return the property value, or {@code null}
|
||||
*/
|
||||
@Nullable
|
||||
PropertyValue getPropertyValue(String propertyName);
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.beans;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface that defines type conversion methods. Typically (but not necessarily)
|
||||
@@ -49,7 +50,7 @@ public interface TypeConverter {
|
||||
* @see org.springframework.core.convert.ConversionService
|
||||
* @see org.springframework.core.convert.converter.Converter
|
||||
*/
|
||||
<T> T convertIfNecessary(Object value, Class<T> requiredType) throws TypeMismatchException;
|
||||
<T> T convertIfNecessary(Object value, @Nullable Class<T> requiredType) throws TypeMismatchException;
|
||||
|
||||
/**
|
||||
* Convert the value to the required type (if necessary from a String).
|
||||
@@ -67,7 +68,7 @@ public interface TypeConverter {
|
||||
* @see org.springframework.core.convert.ConversionService
|
||||
* @see org.springframework.core.convert.converter.Converter
|
||||
*/
|
||||
<T> T convertIfNecessary(Object value, Class<T> requiredType, MethodParameter methodParam)
|
||||
<T> T convertIfNecessary(Object value, @Nullable Class<T> requiredType, @Nullable MethodParameter methodParam)
|
||||
throws TypeMismatchException;
|
||||
|
||||
/**
|
||||
@@ -86,7 +87,7 @@ public interface TypeConverter {
|
||||
* @see org.springframework.core.convert.ConversionService
|
||||
* @see org.springframework.core.convert.converter.Converter
|
||||
*/
|
||||
<T> T convertIfNecessary(Object value, Class<T> requiredType, Field field)
|
||||
<T> T convertIfNecessary(Object value, @Nullable Class<T> requiredType, @Nullable Field field)
|
||||
throws TypeMismatchException;
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.convert.ConversionFailedException;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.NumberUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -90,7 +91,7 @@ class TypeConverterDelegate {
|
||||
* @return the new value, possibly the result of type conversion
|
||||
* @throws IllegalArgumentException if type conversion failed
|
||||
*/
|
||||
public <T> T convertIfNecessary(Object newValue, Class<T> requiredType, MethodParameter methodParam)
|
||||
public <T> T convertIfNecessary(Object newValue, @Nullable Class<T> requiredType, @Nullable MethodParameter methodParam)
|
||||
throws IllegalArgumentException {
|
||||
|
||||
return convertIfNecessary(null, null, newValue, requiredType,
|
||||
@@ -107,7 +108,7 @@ class TypeConverterDelegate {
|
||||
* @return the new value, possibly the result of type conversion
|
||||
* @throws IllegalArgumentException if type conversion failed
|
||||
*/
|
||||
public <T> T convertIfNecessary(Object newValue, Class<T> requiredType, Field field)
|
||||
public <T> T convertIfNecessary(Object newValue, @Nullable Class<T> requiredType, @Nullable Field field)
|
||||
throws IllegalArgumentException {
|
||||
|
||||
return convertIfNecessary(null, null, newValue, requiredType,
|
||||
@@ -125,7 +126,7 @@ class TypeConverterDelegate {
|
||||
* @throws IllegalArgumentException if type conversion failed
|
||||
*/
|
||||
public <T> T convertIfNecessary(
|
||||
String propertyName, Object oldValue, Object newValue, Class<T> requiredType)
|
||||
String propertyName, @Nullable Object oldValue, Object newValue, @Nullable Class<T> requiredType)
|
||||
throws IllegalArgumentException {
|
||||
|
||||
return convertIfNecessary(propertyName, oldValue, newValue, requiredType, TypeDescriptor.valueOf(requiredType));
|
||||
@@ -144,8 +145,8 @@ class TypeConverterDelegate {
|
||||
* @throws IllegalArgumentException if type conversion failed
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T convertIfNecessary(String propertyName, Object oldValue, Object newValue,
|
||||
Class<T> requiredType, TypeDescriptor typeDescriptor) throws IllegalArgumentException {
|
||||
public <T> T convertIfNecessary(String propertyName, @Nullable Object oldValue, Object newValue,
|
||||
@Nullable Class<T> requiredType, TypeDescriptor typeDescriptor) throws IllegalArgumentException {
|
||||
|
||||
// Custom editor for this type?
|
||||
PropertyEditor editor = this.propertyEditorRegistry.findCustomEditor(requiredType, propertyName);
|
||||
@@ -357,6 +358,7 @@ class TypeConverterDelegate {
|
||||
* @param requiredType the type to find an editor for
|
||||
* @return the corresponding editor, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
private PropertyEditor findDefaultEditor(Class<?> requiredType) {
|
||||
PropertyEditor editor = null;
|
||||
if (requiredType != null) {
|
||||
@@ -381,7 +383,7 @@ class TypeConverterDelegate {
|
||||
* @return the new value, possibly the result of type conversion
|
||||
* @throws IllegalArgumentException if type conversion failed
|
||||
*/
|
||||
private Object doConvertValue(Object oldValue, Object newValue, Class<?> requiredType, PropertyEditor editor) {
|
||||
private Object doConvertValue(@Nullable Object oldValue, Object newValue, @Nullable Class<?> requiredType, PropertyEditor editor) {
|
||||
Object convertedValue = newValue;
|
||||
|
||||
if (editor != null && !(convertedValue instanceof String)) {
|
||||
@@ -443,7 +445,7 @@ class TypeConverterDelegate {
|
||||
* @param editor the PropertyEditor to use
|
||||
* @return the converted value
|
||||
*/
|
||||
private Object doConvertTextValue(Object oldValue, String newTextValue, PropertyEditor editor) {
|
||||
private Object doConvertTextValue(@Nullable Object oldValue, String newTextValue, PropertyEditor editor) {
|
||||
try {
|
||||
editor.setValue(oldValue);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.beans;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
@@ -55,7 +56,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||
* @param requiredType the required target type (or {@code null} if not known)
|
||||
* @param cause the root cause (may be {@code null})
|
||||
*/
|
||||
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType, Throwable cause) {
|
||||
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, @Nullable Class<?> requiredType, @Nullable Throwable cause) {
|
||||
super(propertyChangeEvent,
|
||||
"Failed to convert property value of type '" +
|
||||
ClassUtils.getDescriptiveType(propertyChangeEvent.getNewValue()) + "'" +
|
||||
@@ -73,7 +74,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||
* @param value the offending value that couldn't be converted (may be {@code null})
|
||||
* @param requiredType the required target type (or {@code null} if not known)
|
||||
*/
|
||||
public TypeMismatchException(Object value, Class<?> requiredType) {
|
||||
public TypeMismatchException(@Nullable Object value, @Nullable Class<?> requiredType) {
|
||||
this(value, requiredType, null);
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||
* @param requiredType the required target type (or {@code null} if not known)
|
||||
* @param cause the root cause (may be {@code null})
|
||||
*/
|
||||
public TypeMismatchException(Object value, Class<?> requiredType, Throwable cause) {
|
||||
public TypeMismatchException(@Nullable Object value, @Nullable Class<?> requiredType, @Nullable Throwable cause) {
|
||||
super("Failed to convert value of type '" + ClassUtils.getDescriptiveType(value) + "'" +
|
||||
(requiredType != null ? " to required type '" + ClassUtils.getQualifiedName(requiredType) + "'" : ""),
|
||||
cause);
|
||||
@@ -103,6 +104,7 @@ public class TypeMismatchException extends PropertyAccessException {
|
||||
/**
|
||||
* Return the required target type, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public Class<?> getRequiredType() {
|
||||
return this.requiredType;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Set;
|
||||
|
||||
import org.springframework.beans.BeanWrapper;
|
||||
import org.springframework.beans.PropertyAccessorFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringValueResolver;
|
||||
|
||||
@@ -44,7 +45,7 @@ public abstract class AnnotationBeanUtils {
|
||||
* @param excludedProperties the names of excluded properties, if any
|
||||
* @see org.springframework.beans.BeanWrapper
|
||||
*/
|
||||
public static void copyPropertiesToBean(Annotation ann, Object bean, String... excludedProperties) {
|
||||
public static void copyPropertiesToBean(Annotation ann, Object bean, @Nullable String... excludedProperties) {
|
||||
copyPropertiesToBean(ann, bean, null, excludedProperties);
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ public abstract class AnnotationBeanUtils {
|
||||
* @param excludedProperties the names of excluded properties, if any
|
||||
* @see org.springframework.beans.BeanWrapper
|
||||
*/
|
||||
public static void copyPropertiesToBean(Annotation ann, Object bean, StringValueResolver valueResolver, String... excludedProperties) {
|
||||
public static void copyPropertiesToBean(Annotation ann, Object bean, @Nullable StringValueResolver valueResolver, @Nullable String... excludedProperties) {
|
||||
Set<String> excluded = new HashSet<>(Arrays.asList(excludedProperties));
|
||||
Method[] annotationProperties = ann.annotationType().getDeclaredMethods();
|
||||
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(bean);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Support package for beans-style handling of Java 5 annotations.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.beans.annotation;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.beans.factory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Callback that allows a bean to be aware of the bean
|
||||
* {@link ClassLoader class loader}; that is, the class loader used by the
|
||||
@@ -50,6 +52,6 @@ public interface BeanClassLoaderAware extends Aware {
|
||||
* the {@code ClassLoader} obtained via
|
||||
* {@link org.springframework.util.ClassUtils#getDefaultClassLoader()}
|
||||
*/
|
||||
void setBeanClassLoader(ClassLoader classLoader);
|
||||
void setBeanClassLoader(@Nullable ClassLoader classLoader);
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
import org.springframework.core.NestedRuntimeException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Exception thrown when a BeanFactory encounters an error when
|
||||
@@ -109,6 +110,7 @@ public class BeanCreationException extends FatalBeanException {
|
||||
/**
|
||||
* Return the name of the bean requested, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String getBeanName() {
|
||||
return this.beanName;
|
||||
}
|
||||
@@ -117,6 +119,7 @@ public class BeanCreationException extends FatalBeanException {
|
||||
* Return the description of the resource that the bean
|
||||
* definition came from, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String getResourceDescription() {
|
||||
return this.resourceDescription;
|
||||
}
|
||||
@@ -138,6 +141,7 @@ public class BeanCreationException extends FatalBeanException {
|
||||
* Return the related causes, if any.
|
||||
* @return the array of related causes, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
public Throwable[] getRelatedCauses() {
|
||||
if (this.relatedCauses == null) {
|
||||
return null;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory;
|
||||
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Exception thrown when a BeanFactory encounters an invalid bean definition:
|
||||
@@ -47,7 +48,7 @@ public class BeanDefinitionStoreException extends FatalBeanException {
|
||||
* @param msg the detail message (used as exception message as-is)
|
||||
* @param cause the root cause (may be {@code null})
|
||||
*/
|
||||
public BeanDefinitionStoreException(String msg, Throwable cause) {
|
||||
public BeanDefinitionStoreException(String msg, @Nullable Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
@@ -67,7 +68,7 @@ public class BeanDefinitionStoreException extends FatalBeanException {
|
||||
* @param msg the detail message (used as exception message as-is)
|
||||
* @param cause the root cause (may be {@code null})
|
||||
*/
|
||||
public BeanDefinitionStoreException(String resourceDescription, String msg, Throwable cause) {
|
||||
public BeanDefinitionStoreException(String resourceDescription, String msg, @Nullable Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.resourceDescription = resourceDescription;
|
||||
}
|
||||
@@ -91,7 +92,7 @@ public class BeanDefinitionStoreException extends FatalBeanException {
|
||||
* the resource and the name of the bean)
|
||||
* @param cause the root cause (may be {@code null})
|
||||
*/
|
||||
public BeanDefinitionStoreException(String resourceDescription, String beanName, String msg, Throwable cause) {
|
||||
public BeanDefinitionStoreException(String resourceDescription, String beanName, String msg, @Nullable Throwable cause) {
|
||||
super("Invalid bean definition with name '" + beanName + "' defined in " + resourceDescription + ": " + msg, cause);
|
||||
this.resourceDescription = resourceDescription;
|
||||
this.beanName = beanName;
|
||||
@@ -102,6 +103,7 @@ public class BeanDefinitionStoreException extends FatalBeanException {
|
||||
* Return the description of the resource that the bean
|
||||
* definition came from, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String getResourceDescription() {
|
||||
return this.resourceDescription;
|
||||
}
|
||||
@@ -109,6 +111,7 @@ public class BeanDefinitionStoreException extends FatalBeanException {
|
||||
/**
|
||||
* Return the name of the bean requested, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String getBeanName() {
|
||||
return this.beanName;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.beans.factory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* The root interface for accessing a Spring bean container.
|
||||
@@ -156,7 +157,7 @@ public interface BeanFactory {
|
||||
* @throws BeanNotOfRequiredTypeException if the bean is not of the required type
|
||||
* @throws BeansException if the bean could not be created
|
||||
*/
|
||||
<T> T getBean(String name, Class<T> requiredType) throws BeansException;
|
||||
<T> T getBean(String name, @Nullable Class<T> requiredType) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return the bean instance that uniquely matches the given object type, if any.
|
||||
@@ -313,6 +314,7 @@ public interface BeanFactory {
|
||||
* @see #getBean
|
||||
* @see #isTypeMatch
|
||||
*/
|
||||
@Nullable
|
||||
Class<?> getType(String name) throws NoSuchBeanDefinitionException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.beans.factory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by objects used within a {@link BeanFactory} which
|
||||
* are themselves factories for individual objects. If a bean implements this
|
||||
@@ -72,6 +74,7 @@ public interface FactoryBean<T> {
|
||||
* @throws Exception in case of creation errors
|
||||
* @see FactoryBeanNotInitializedException
|
||||
*/
|
||||
@Nullable
|
||||
T getObject() throws Exception;
|
||||
|
||||
/**
|
||||
@@ -93,6 +96,7 @@ public interface FactoryBean<T> {
|
||||
* or {@code null} if not known at the time of the call
|
||||
* @see ListableBeanFactory#getBeansOfType
|
||||
*/
|
||||
@Nullable
|
||||
Class<?> getObjectType();
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.beans.factory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Sub-interface implemented by bean factories that can be part
|
||||
* of a hierarchy.
|
||||
@@ -34,6 +36,7 @@ public interface HierarchicalBeanFactory extends BeanFactory {
|
||||
/**
|
||||
* Return the parent bean factory, or {@code null} if there is none.
|
||||
*/
|
||||
@Nullable
|
||||
BeanFactory getParentBeanFactory();
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Member;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -83,6 +84,7 @@ public class InjectionPoint {
|
||||
* <p>Note: Either MethodParameter or Field is available.
|
||||
* @return the MethodParameter, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
public MethodParameter getMethodParameter() {
|
||||
return this.methodParameter;
|
||||
}
|
||||
@@ -92,6 +94,7 @@ public class InjectionPoint {
|
||||
* <p>Note: Either MethodParameter or Field is available.
|
||||
* @return the Field, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
public Field getField() {
|
||||
return this.field;
|
||||
}
|
||||
@@ -117,6 +120,7 @@ public class InjectionPoint {
|
||||
* @return the annotation instance, or {@code null} if none found
|
||||
* @since 4.3.9
|
||||
*/
|
||||
@Nullable
|
||||
public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
|
||||
return (this.field != null ? this.field.getAnnotation(annotationType) :
|
||||
this.methodParameter.getParameterAnnotation(annotationType));
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Extension of the {@link BeanFactory} interface to be implemented by bean factories
|
||||
@@ -113,7 +114,7 @@ public interface ListableBeanFactory extends BeanFactory {
|
||||
* @see FactoryBean#getObjectType
|
||||
* @see BeanFactoryUtils#beanNamesForTypeIncludingAncestors(ListableBeanFactory, ResolvableType)
|
||||
*/
|
||||
String[] getBeanNamesForType(ResolvableType type);
|
||||
String[] getBeanNamesForType(@Nullable ResolvableType type);
|
||||
|
||||
/**
|
||||
* Return the names of beans matching the given type (including subclasses),
|
||||
@@ -140,7 +141,7 @@ public interface ListableBeanFactory extends BeanFactory {
|
||||
* @see FactoryBean#getObjectType
|
||||
* @see BeanFactoryUtils#beanNamesForTypeIncludingAncestors(ListableBeanFactory, Class)
|
||||
*/
|
||||
String[] getBeanNamesForType(Class<?> type);
|
||||
String[] getBeanNamesForType(@Nullable Class<?> type);
|
||||
|
||||
/**
|
||||
* Return the names of beans matching the given type (including subclasses),
|
||||
@@ -173,7 +174,7 @@ public interface ListableBeanFactory extends BeanFactory {
|
||||
* @see FactoryBean#getObjectType
|
||||
* @see BeanFactoryUtils#beanNamesForTypeIncludingAncestors(ListableBeanFactory, Class, boolean, boolean)
|
||||
*/
|
||||
String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit);
|
||||
String[] getBeanNamesForType(@Nullable Class<?> type, boolean includeNonSingletons, boolean allowEagerInit);
|
||||
|
||||
/**
|
||||
* Return the bean instances that match the given object type (including
|
||||
@@ -203,7 +204,7 @@ public interface ListableBeanFactory extends BeanFactory {
|
||||
* @see FactoryBean#getObjectType
|
||||
* @see BeanFactoryUtils#beansOfTypeIncludingAncestors(ListableBeanFactory, Class)
|
||||
*/
|
||||
<T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException;
|
||||
<T> Map<String, T> getBeansOfType(@Nullable Class<T> type) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return the bean instances that match the given object type (including
|
||||
@@ -238,7 +239,7 @@ public interface ListableBeanFactory extends BeanFactory {
|
||||
* @see FactoryBean#getObjectType
|
||||
* @see BeanFactoryUtils#beansOfTypeIncludingAncestors(ListableBeanFactory, Class, boolean, boolean)
|
||||
*/
|
||||
<T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
|
||||
<T> Map<String, T> getBeansOfType(@Nullable Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
|
||||
throws BeansException;
|
||||
|
||||
/**
|
||||
@@ -271,6 +272,7 @@ public interface ListableBeanFactory extends BeanFactory {
|
||||
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
|
||||
* @since 3.0
|
||||
*/
|
||||
@Nullable
|
||||
<A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
|
||||
throws NoSuchBeanDefinitionException;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.beans.factory;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -85,6 +86,7 @@ public class NoUniqueBeanDefinitionException extends NoSuchBeanDefinitionExcepti
|
||||
* @since 4.3
|
||||
* @see #getBeanType()
|
||||
*/
|
||||
@Nullable
|
||||
public Collection<String> getBeanNamesFound() {
|
||||
return this.beanNamesFound;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.beans.factory;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A variant of {@link ObjectFactory} designed specifically for injection points,
|
||||
@@ -48,6 +49,7 @@ public interface ObjectProvider<T> extends ObjectFactory<T> {
|
||||
* @throws BeansException in case of creation errors
|
||||
* @see #getObject()
|
||||
*/
|
||||
@Nullable
|
||||
T getIfAvailable() throws BeansException;
|
||||
|
||||
/**
|
||||
@@ -74,6 +76,7 @@ public interface ObjectProvider<T> extends ObjectFactory<T> {
|
||||
* @throws BeansException in case of creation errors
|
||||
* @see #getObject()
|
||||
*/
|
||||
@Nullable
|
||||
T getIfUnique() throws BeansException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.beans.factory.annotation;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.core.type.MethodMetadata;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Extended {@link org.springframework.beans.factory.config.BeanDefinition}
|
||||
@@ -44,6 +45,7 @@ public interface AnnotatedBeanDefinition extends BeanDefinition {
|
||||
* @return the factory method metadata, or {@code null} if none
|
||||
* @since 4.1.1
|
||||
*/
|
||||
@Nullable
|
||||
MethodMetadata getFactoryMethodMetadata();
|
||||
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ import org.springframework.core.Ordered;
|
||||
import org.springframework.core.PriorityOrdered;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -468,6 +469,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
return new InjectionMetadata(clazz, elements);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private AnnotationAttributes findAutowiredAnnotation(AccessibleObject ao) {
|
||||
if (ao.getAnnotations().length > 0) {
|
||||
for (Class<? extends Annotation> type : this.autowiredAnnotationTypes) {
|
||||
@@ -691,6 +693,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object[] resolveCachedArguments(String beanName) {
|
||||
if (this.cachedMethodArguments == null) {
|
||||
return null;
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.PropertyValues;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
@@ -232,6 +233,7 @@ public class InjectionMetadata {
|
||||
/**
|
||||
* Either this or {@link #inject} needs to be overridden.
|
||||
*/
|
||||
@Nullable
|
||||
protected Object getResourceToInject(Object target, String requestingBeanName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -341,6 +342,7 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
|
||||
/**
|
||||
* Determine a suggested value from any of the given candidate annotations.
|
||||
*/
|
||||
@Nullable
|
||||
protected Object findValue(Annotation[] annotationsToSearch) {
|
||||
AnnotationAttributes attr = AnnotatedElementUtils.getMergedAnnotationAttributes(
|
||||
AnnotatedElementUtils.forAnnotations(annotationsToSearch), this.valueAnnotationType);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Support package for annotation-driven bean configuration.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.beans.factory.annotation;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.beans.factory.DisposableBean;
|
||||
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.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -225,6 +226,7 @@ public abstract class AbstractFactoryBean<T>
|
||||
* or {@code null} to indicate a FactoryBeanNotInitializedException
|
||||
* @see org.springframework.beans.factory.FactoryBeanNotInitializedException
|
||||
*/
|
||||
@Nullable
|
||||
protected Class<?>[] getEarlySingletonInterfaces() {
|
||||
Class<?> type = getObjectType();
|
||||
return (type != null && type.isInterface() ? new Class<?>[] {type} : null);
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.beans.TypeConverter;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Extension of the {@link org.springframework.beans.factory.BeanFactory}
|
||||
@@ -337,6 +338,7 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
|
||||
* @since 2.5
|
||||
* @see #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)
|
||||
*/
|
||||
@Nullable
|
||||
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName) throws BeansException;
|
||||
|
||||
/**
|
||||
@@ -353,6 +355,7 @@ public interface AutowireCapableBeanFactory extends BeanFactory {
|
||||
* @since 2.5
|
||||
* @see DependencyDescriptor
|
||||
*/
|
||||
@Nullable
|
||||
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName,
|
||||
Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.beans.factory.config;
|
||||
import org.springframework.beans.BeanMetadataElement;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.core.AttributeAccessor;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A BeanDefinition describes a bean instance, which has property values,
|
||||
@@ -84,11 +85,12 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
|
||||
/**
|
||||
* Set the name of the parent definition of this bean definition, if any.
|
||||
*/
|
||||
void setParentName(String parentName);
|
||||
void setParentName(@Nullable String parentName);
|
||||
|
||||
/**
|
||||
* Return the name of the parent definition of this bean definition, if any.
|
||||
*/
|
||||
@Nullable
|
||||
String getParentName();
|
||||
|
||||
/**
|
||||
@@ -126,6 +128,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
|
||||
* Return the name of the current target scope for this bean,
|
||||
* or {@code null} if not known yet.
|
||||
*/
|
||||
@Nullable
|
||||
String getScope();
|
||||
|
||||
/**
|
||||
@@ -188,6 +191,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
|
||||
/**
|
||||
* Return the factory bean name, if any.
|
||||
*/
|
||||
@Nullable
|
||||
String getFactoryBeanName();
|
||||
|
||||
/**
|
||||
@@ -203,6 +207,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
|
||||
/**
|
||||
* Return a factory method, if any.
|
||||
*/
|
||||
@Nullable
|
||||
String getFactoryMethodName();
|
||||
|
||||
/**
|
||||
@@ -260,6 +265,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
|
||||
* Return a description of the resource that this bean definition
|
||||
* came from (for the purpose of showing context in case of errors).
|
||||
*/
|
||||
@Nullable
|
||||
String getResourceDescription();
|
||||
|
||||
/**
|
||||
@@ -268,6 +274,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
|
||||
* <p>Note that this method returns the immediate originator. Iterate through the
|
||||
* originator chain to find the original BeanDefinition as defined by the user.
|
||||
*/
|
||||
@Nullable
|
||||
BeanDefinition getOriginatingBeanDefinition();
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.beans.BeanMetadataElement;
|
||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -60,7 +61,7 @@ public class BeanDefinitionHolder implements BeanMetadataElement {
|
||||
* @param beanName the name of the bean, as specified for the bean definition
|
||||
* @param aliases alias names for the bean, or {@code null} if none
|
||||
*/
|
||||
public BeanDefinitionHolder(BeanDefinition beanDefinition, String beanName, String[] aliases) {
|
||||
public BeanDefinitionHolder(BeanDefinition beanDefinition, String beanName, @Nullable String[] aliases) {
|
||||
Assert.notNull(beanDefinition, "BeanDefinition must not be null");
|
||||
Assert.notNull(beanName, "Bean name must not be null");
|
||||
this.beanDefinition = beanDefinition;
|
||||
@@ -101,6 +102,7 @@ public class BeanDefinitionHolder implements BeanMetadataElement {
|
||||
* Return the alias names for the bean, as specified directly for the bean definition.
|
||||
* @return the array of alias names, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
public String[] getAliases() {
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -51,6 +52,7 @@ public class BeanExpressionContext {
|
||||
(this.scope != null && this.scope.resolveContextualObject(key) != null));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getObject(String key) {
|
||||
if (this.beanFactory.containsBean(key)) {
|
||||
return this.beanFactory.getBean(key);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Factory hook that allows for custom modification of new bean instances,
|
||||
@@ -54,6 +55,7 @@ public interface BeanPostProcessor {
|
||||
* @throws org.springframework.beans.BeansException in case of errors
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet
|
||||
*/
|
||||
@Nullable
|
||||
default Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
@@ -79,6 +81,7 @@ public interface BeanPostProcessor {
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet
|
||||
* @see org.springframework.beans.factory.FactoryBean
|
||||
*/
|
||||
@Nullable
|
||||
default Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.HierarchicalBeanFactory;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringValueResolver;
|
||||
|
||||
/**
|
||||
@@ -85,7 +86,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
|
||||
* @param beanClassLoader the class loader to use,
|
||||
* or {@code null} to suggest the default class loader
|
||||
*/
|
||||
void setBeanClassLoader(ClassLoader beanClassLoader);
|
||||
void setBeanClassLoader(@Nullable ClassLoader beanClassLoader);
|
||||
|
||||
/**
|
||||
* Return this factory's class loader for loading bean classes.
|
||||
@@ -108,6 +109,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
|
||||
* if any.
|
||||
* @since 2.5
|
||||
*/
|
||||
@Nullable
|
||||
ClassLoader getTempClassLoader();
|
||||
|
||||
/**
|
||||
@@ -151,6 +153,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
|
||||
* Return the associated ConversionService, if any.
|
||||
* @since 3.0
|
||||
*/
|
||||
@Nullable
|
||||
ConversionService getConversionService();
|
||||
|
||||
/**
|
||||
@@ -222,6 +225,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
|
||||
* @return the resolved value (may be the original value as-is)
|
||||
* @since 3.0
|
||||
*/
|
||||
@Nullable
|
||||
String resolveEmbeddedValue(String value);
|
||||
|
||||
/**
|
||||
@@ -265,6 +269,7 @@ public interface ConfigurableBeanFactory extends HierarchicalBeanFactory, Single
|
||||
* @return the registered Scope implementation, or {@code null} if none
|
||||
* @see #registerScope
|
||||
*/
|
||||
@Nullable
|
||||
Scope getRegisteredScope(String scopeName);
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.Set;
|
||||
|
||||
import org.springframework.beans.BeanMetadataElement;
|
||||
import org.springframework.beans.Mergeable;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -146,7 +147,8 @@ public class ConstructorArgumentValues {
|
||||
* untyped values only)
|
||||
* @return the ValueHolder for the argument, or {@code null} if none set
|
||||
*/
|
||||
public ValueHolder getIndexedArgumentValue(int index, Class<?> requiredType) {
|
||||
@Nullable
|
||||
public ValueHolder getIndexedArgumentValue(int index, @Nullable Class<?> requiredType) {
|
||||
return getIndexedArgumentValue(index, requiredType, null);
|
||||
}
|
||||
|
||||
@@ -159,7 +161,8 @@ public class ConstructorArgumentValues {
|
||||
* unnamed values only, or empty String to match any name)
|
||||
* @return the ValueHolder for the argument, or {@code null} if none set
|
||||
*/
|
||||
public ValueHolder getIndexedArgumentValue(int index, Class<?> requiredType, String requiredName) {
|
||||
@Nullable
|
||||
public ValueHolder getIndexedArgumentValue(int index, @Nullable Class<?> requiredType, @Nullable String requiredName) {
|
||||
Assert.isTrue(index >= 0, "Index must not be negative");
|
||||
ValueHolder valueHolder = this.indexedArgumentValues.get(index);
|
||||
if (valueHolder != null &&
|
||||
@@ -247,6 +250,7 @@ public class ConstructorArgumentValues {
|
||||
* @param requiredType the type to match
|
||||
* @return the ValueHolder for the argument, or {@code null} if none set
|
||||
*/
|
||||
@Nullable
|
||||
public ValueHolder getGenericArgumentValue(Class<?> requiredType) {
|
||||
return getGenericArgumentValue(requiredType, null, null);
|
||||
}
|
||||
@@ -257,6 +261,7 @@ public class ConstructorArgumentValues {
|
||||
* @param requiredName the name to match
|
||||
* @return the ValueHolder for the argument, or {@code null} if none set
|
||||
*/
|
||||
@Nullable
|
||||
public ValueHolder getGenericArgumentValue(Class<?> requiredType, String requiredName) {
|
||||
return getGenericArgumentValue(requiredType, requiredName, null);
|
||||
}
|
||||
@@ -273,7 +278,8 @@ public class ConstructorArgumentValues {
|
||||
* in the current resolution process and should therefore not be returned again
|
||||
* @return the ValueHolder for the argument, or {@code null} if none found
|
||||
*/
|
||||
public ValueHolder getGenericArgumentValue(Class<?> requiredType, String requiredName, Set<ValueHolder> usedValueHolders) {
|
||||
@Nullable
|
||||
public ValueHolder getGenericArgumentValue(@Nullable Class<?> requiredType, @Nullable String requiredName, Set<ValueHolder> usedValueHolders) {
|
||||
for (ValueHolder valueHolder : this.genericArgumentValues) {
|
||||
if (usedValueHolders != null && usedValueHolders.contains(valueHolder)) {
|
||||
continue;
|
||||
@@ -312,6 +318,7 @@ public class ConstructorArgumentValues {
|
||||
* @param requiredType the parameter type to match
|
||||
* @return the ValueHolder for the argument, or {@code null} if none set
|
||||
*/
|
||||
@Nullable
|
||||
public ValueHolder getArgumentValue(int index, Class<?> requiredType) {
|
||||
return getArgumentValue(index, requiredType, null, null);
|
||||
}
|
||||
@@ -324,6 +331,7 @@ public class ConstructorArgumentValues {
|
||||
* @param requiredName the parameter name to match
|
||||
* @return the ValueHolder for the argument, or {@code null} if none set
|
||||
*/
|
||||
@Nullable
|
||||
public ValueHolder getArgumentValue(int index, Class<?> requiredType, String requiredName) {
|
||||
return getArgumentValue(index, requiredType, requiredName, null);
|
||||
}
|
||||
@@ -342,7 +350,8 @@ public class ConstructorArgumentValues {
|
||||
* in case of multiple generic argument values of the same type)
|
||||
* @return the ValueHolder for the argument, or {@code null} if none set
|
||||
*/
|
||||
public ValueHolder getArgumentValue(int index, Class<?> requiredType, String requiredName, Set<ValueHolder> usedValueHolders) {
|
||||
@Nullable
|
||||
public ValueHolder getArgumentValue(int index, @Nullable Class<?> requiredType, @Nullable String requiredName, Set<ValueHolder> usedValueHolders) {
|
||||
Assert.isTrue(index >= 0, "Index must not be negative");
|
||||
ValueHolder valueHolder = getIndexedArgumentValue(index, requiredType, requiredName);
|
||||
if (valueHolder == null) {
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
@@ -211,6 +212,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
* @throws BeansException in case of the not-unique scenario being fatal
|
||||
* @since 4.3
|
||||
*/
|
||||
@Nullable
|
||||
public Object resolveNotUnique(Class<?> type, Map<String, Object> matchingBeans) throws BeansException {
|
||||
throw new NoUniqueBeanDefinitionException(type, matchingBeans.keySet());
|
||||
}
|
||||
@@ -227,6 +229,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
* @throws BeansException if the shortcut could not be obtained
|
||||
* @since 4.3.1
|
||||
*/
|
||||
@Nullable
|
||||
public Object resolveShortcut(BeanFactory beanFactory) throws BeansException {
|
||||
return null;
|
||||
}
|
||||
@@ -321,7 +324,7 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
||||
* this point; it just allows discovery to happen when the application calls
|
||||
* {@link #getDependencyName()} (if ever).
|
||||
*/
|
||||
public void initParameterNameDiscovery(ParameterNameDiscoverer parameterNameDiscoverer) {
|
||||
public void initParameterNameDiscovery(@Nullable ParameterNameDiscoverer parameterNameDiscoverer) {
|
||||
if (this.methodParameter != null) {
|
||||
this.methodParameter.initParameterNameDiscovery(parameterNameDiscoverer);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.beans.PropertyDescriptor;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.PropertyValues;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Subinterface of {@link BeanPostProcessor} that adds a before-instantiation callback,
|
||||
@@ -67,6 +68,7 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor {
|
||||
* @see org.springframework.beans.factory.support.AbstractBeanDefinition#hasBeanClass
|
||||
* @see org.springframework.beans.factory.support.AbstractBeanDefinition#getFactoryMethodName
|
||||
*/
|
||||
@Nullable
|
||||
default Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
|
||||
return null;
|
||||
}
|
||||
@@ -109,6 +111,7 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor {
|
||||
* @throws org.springframework.beans.BeansException in case of errors
|
||||
* @see org.springframework.beans.MutablePropertyValues
|
||||
*/
|
||||
@Nullable
|
||||
default PropertyValues postProcessPropertyValues(
|
||||
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.beans.factory.NamedBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -56,6 +57,7 @@ public class NamedBeanHolder<T> implements NamedBean {
|
||||
/**
|
||||
* Return the corresponding bean instance (can be {@code null}).
|
||||
*/
|
||||
@Nullable
|
||||
public T getBeanInstance() {
|
||||
return this.beanInstance;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringValueResolver;
|
||||
|
||||
/**
|
||||
@@ -140,7 +141,7 @@ public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfi
|
||||
* special character should be processed as a value separator.
|
||||
* The default is {@value #DEFAULT_VALUE_SEPARATOR}.
|
||||
*/
|
||||
public void setValueSeparator(String valueSeparator) {
|
||||
public void setValueSeparator(@Nullable String valueSeparator) {
|
||||
this.valueSeparator = valueSeparator;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.prefs.Preferences;
|
||||
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Subclass of PropertyPlaceholderConfigurer that supports JDK 1.4's
|
||||
@@ -113,6 +114,7 @@ public class PreferencesPlaceholderConfigurer extends PropertyPlaceholderConfigu
|
||||
* @param preferences the Preferences to resolve against
|
||||
* @return the value for the placeholder, or {@code null} if none found
|
||||
*/
|
||||
@Nullable
|
||||
protected String resolvePlaceholder(String path, String key, Preferences preferences) {
|
||||
if (path != null) {
|
||||
// Do not create the node if it does not exist...
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.beans.BeansException;
|
||||
import org.springframework.core.Constants;
|
||||
import org.springframework.core.SpringProperties;
|
||||
import org.springframework.core.env.AbstractEnvironment;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.PropertyPlaceholderHelper;
|
||||
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
|
||||
import org.springframework.util.StringValueResolver;
|
||||
@@ -179,6 +180,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
|
||||
* @return the resolved value, of {@code null} if none
|
||||
* @see #setSystemPropertiesMode
|
||||
*/
|
||||
@Nullable
|
||||
protected String resolvePlaceholder(String placeholder, Properties props) {
|
||||
return props.getProperty(placeholder);
|
||||
}
|
||||
@@ -192,6 +194,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
|
||||
* @see System#getProperty(String)
|
||||
* @see System#getenv(String)
|
||||
*/
|
||||
@Nullable
|
||||
protected String resolveSystemProperty(String key) {
|
||||
try {
|
||||
String value = System.getProperty(key);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Strategy interface used by a {@link ConfigurableBeanFactory},
|
||||
@@ -88,6 +89,7 @@ public interface Scope {
|
||||
* @throws IllegalStateException if the underlying scope is not currently active
|
||||
* @see #registerDestructionCallback
|
||||
*/
|
||||
@Nullable
|
||||
Object remove(String name);
|
||||
|
||||
/**
|
||||
@@ -128,6 +130,7 @@ public interface Scope {
|
||||
* @return the corresponding object, or {@code null} if none found
|
||||
* @throws IllegalStateException if the underlying scope is not currently active
|
||||
*/
|
||||
@Nullable
|
||||
Object resolveContextualObject(String key);
|
||||
|
||||
/**
|
||||
@@ -145,6 +148,7 @@ public interface Scope {
|
||||
* conversation ID for the current scope
|
||||
* @throws IllegalStateException if the underlying scope is not currently active
|
||||
*/
|
||||
@Nullable
|
||||
String getConversationId();
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface that defines a registry for shared bean instances.
|
||||
* Can be implemented by {@link org.springframework.beans.factory.BeanFactory}
|
||||
@@ -68,6 +70,7 @@ public interface SingletonBeanRegistry {
|
||||
* @return the registered singleton object, or {@code null} if none found
|
||||
* @see ConfigurableListableBeanFactory#getBeanDefinition
|
||||
*/
|
||||
@Nullable
|
||||
Object getSingleton(String beanName);
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.beans.factory.config;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Extension of the {@link InstantiationAwareBeanPostProcessor} interface,
|
||||
@@ -45,6 +46,7 @@ public interface SmartInstantiationAwareBeanPostProcessor extends InstantiationA
|
||||
* @return the type of the bean, or {@code null} if not predictable
|
||||
* @throws org.springframework.beans.BeansException in case of errors
|
||||
*/
|
||||
@Nullable
|
||||
default Class<?> predictBeanType(Class<?> beanClass, String beanName) throws BeansException {
|
||||
return null;
|
||||
}
|
||||
@@ -57,6 +59,7 @@ public interface SmartInstantiationAwareBeanPostProcessor extends InstantiationA
|
||||
* @return the candidate constructors, or {@code null} if none specified
|
||||
* @throws org.springframework.beans.BeansException in case of errors
|
||||
*/
|
||||
@Nullable
|
||||
default Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName)
|
||||
throws BeansException {
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.beans.BeanMetadataElement;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -153,6 +154,7 @@ public class TypedStringValue implements BeanMetadataElement {
|
||||
* @return the resolved type to convert to
|
||||
* @throws ClassNotFoundException if the type cannot be resolved
|
||||
*/
|
||||
@Nullable
|
||||
public Class<?> resolveTargetType(ClassLoader classLoader) throws ClassNotFoundException {
|
||||
if (this.targetType == null) {
|
||||
return null;
|
||||
@@ -179,13 +181,14 @@ public class TypedStringValue implements BeanMetadataElement {
|
||||
/**
|
||||
* Set the type name as actually specified for this particular value, if any.
|
||||
*/
|
||||
public void setSpecifiedTypeName(String specifiedTypeName) {
|
||||
public void setSpecifiedTypeName(@Nullable String specifiedTypeName) {
|
||||
this.specifiedTypeName = specifiedTypeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type name as actually specified for this particular value, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String getSpecifiedTypeName() {
|
||||
return this.specifiedTypeName;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* SPI interfaces and configuration-related convenience classes for bean factories.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.beans.factory.config;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -9,4 +9,7 @@
|
||||
* <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/">Expert One-On-One J2EE Design and Development</a>
|
||||
* by Rod Johnson (Wrox, 2002).
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.beans.factory;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory.parsing;
|
||||
|
||||
import org.springframework.beans.BeanMetadataElement;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -50,7 +51,7 @@ public class AliasDefinition implements BeanMetadataElement {
|
||||
* @param alias the alias registered for the bean
|
||||
* @param source the source object (may be {@code null})
|
||||
*/
|
||||
public AliasDefinition(String beanName, String alias, Object source) {
|
||||
public AliasDefinition(String beanName, String alias, @Nullable Object source) {
|
||||
Assert.notNull(beanName, "Bean name must not be null");
|
||||
Assert.notNull(alias, "Alias must not be null");
|
||||
this.beanName = beanName;
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.beans.PropertyValues;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.BeanReference;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* ComponentDefinition based on a standard BeanDefinition, exposing the given bean
|
||||
@@ -56,7 +57,7 @@ public class BeanComponentDefinition extends BeanDefinitionHolder implements Com
|
||||
* @param beanName the name of the bean
|
||||
* @param aliases alias names for the bean, or {@code null} if none
|
||||
*/
|
||||
public BeanComponentDefinition(BeanDefinition beanDefinition, String beanName, String[] aliases) {
|
||||
public BeanComponentDefinition(BeanDefinition beanDefinition, String beanName, @Nullable String[] aliases) {
|
||||
super(beanDefinition, beanName, aliases);
|
||||
findInnerBeanDefinitionsAndBeanReferences(beanDefinition);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.beans.factory.parsing;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Simple {@link ProblemReporter} implementation that exhibits fail-fast
|
||||
* behavior when errors are encountered.
|
||||
@@ -45,7 +47,7 @@ public class FailFastProblemReporter implements ProblemReporter {
|
||||
* the name of the instance class will be used.
|
||||
* @param logger the {@link Log logger} that is to be used to report warnings
|
||||
*/
|
||||
public void setLogger(Log logger) {
|
||||
public void setLogger(@Nullable Log logger) {
|
||||
this.logger = (logger != null ? logger : LogFactory.getLog(getClass()));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.parsing;
|
||||
|
||||
import org.springframework.beans.BeanMetadataElement;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -49,7 +50,7 @@ public class ImportDefinition implements BeanMetadataElement {
|
||||
* @param importedResource the location of the imported resource
|
||||
* @param source the source object (may be {@code null})
|
||||
*/
|
||||
public ImportDefinition(String importedResource, Object source) {
|
||||
public ImportDefinition(String importedResource, @Nullable Object source) {
|
||||
this(importedResource, null, source);
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ public class ImportDefinition implements BeanMetadataElement {
|
||||
* @param importedResource the location of the imported resource
|
||||
* @param source the source object (may be {@code null})
|
||||
*/
|
||||
public ImportDefinition(String importedResource, Resource[] actualResources, Object source) {
|
||||
public ImportDefinition(String importedResource, Resource[] actualResources, @Nullable Object source) {
|
||||
Assert.notNull(importedResource, "Imported resource must not be null");
|
||||
this.importedResource = importedResource;
|
||||
this.actualResources = actualResources;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory.parsing;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -53,7 +54,7 @@ public class Location {
|
||||
* @param source the actual location within the associated resource
|
||||
* (may be {@code null})
|
||||
*/
|
||||
public Location(Resource resource, Object source) {
|
||||
public Location(Resource resource, @Nullable Object source) {
|
||||
Assert.notNull(resource, "Resource must not be null");
|
||||
this.resource = resource;
|
||||
this.source = source;
|
||||
@@ -73,6 +74,7 @@ public class Location {
|
||||
* <p>See the {@link Location class level javadoc for this class} for examples
|
||||
* of what the actual type of the returned object may be.
|
||||
*/
|
||||
@Nullable
|
||||
public Object getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.beans.factory.parsing;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Simple {@link Stack}-based structure for tracking the logical position during
|
||||
* a parsing process. {@link Entry entries} are added to the stack at
|
||||
@@ -78,6 +80,7 @@ public final class ParseState {
|
||||
* Return the {@link Entry} currently at the top of the {@link Stack} or
|
||||
* {@code null} if the {@link Stack} is empty.
|
||||
*/
|
||||
@Nullable
|
||||
public Entry peek() {
|
||||
return this.state.empty() ? null : this.state.peek();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.beans.factory.parsing;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -66,7 +67,7 @@ public class Problem {
|
||||
* @param parseState the {@link ParseState} at the time of the error
|
||||
* @param location the location within a bean configuration source that triggered the error
|
||||
*/
|
||||
public Problem(String message, Location location, ParseState parseState, Throwable rootCause) {
|
||||
public Problem(String message, Location location, ParseState parseState, @Nullable Throwable rootCause) {
|
||||
Assert.notNull(message, "Message must not be null");
|
||||
Assert.notNull(location, "Location must not be null");
|
||||
this.message = message;
|
||||
@@ -102,6 +103,7 @@ public class Problem {
|
||||
/**
|
||||
* Get the {@link ParseState} at the time of the error (may be {@code null}).
|
||||
*/
|
||||
@Nullable
|
||||
public ParseState getParseState() {
|
||||
return this.parseState;
|
||||
}
|
||||
@@ -109,6 +111,7 @@ public class Problem {
|
||||
/**
|
||||
* Get the underlying exception that caused the error (may be {@code null}).
|
||||
*/
|
||||
@Nullable
|
||||
public Throwable getRootCause() {
|
||||
return this.rootCause;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory.parsing;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Simple strategy allowing tools to control how source metadata is attached
|
||||
@@ -44,6 +45,7 @@ public interface SourceExtractor {
|
||||
* (may be {@code null})
|
||||
* @return the source metadata object to store (may be {@code null})
|
||||
*/
|
||||
Object extractSource(Object sourceCandidate, Resource definingResource);
|
||||
@Nullable
|
||||
Object extractSource(Object sourceCandidate, @Nullable Resource definingResource);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Support infrastructure for bean definition parsing.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.beans.factory.parsing;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/**
|
||||
* Support package for the Java 6 ServiceLoader facility.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.beans.factory.serviceloader;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -77,6 +77,7 @@ import org.springframework.core.NamedThreadLocal;
|
||||
import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.core.PriorityOrdered;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -175,7 +176,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* Create a new AbstractAutowireCapableBeanFactory with the given parent.
|
||||
* @param parentBeanFactory parent bean factory, or {@code null} if none
|
||||
*/
|
||||
public AbstractAutowireCapableBeanFactory(BeanFactory parentBeanFactory) {
|
||||
public AbstractAutowireCapableBeanFactory(@Nullable BeanFactory parentBeanFactory) {
|
||||
this();
|
||||
setParentBeanFactory(parentBeanFactory);
|
||||
}
|
||||
@@ -654,6 +655,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* (also signals that the returned {@code Class} will never be exposed to application code)
|
||||
* @return the type for the bean if determinable, or {@code null} otherwise
|
||||
*/
|
||||
@Nullable
|
||||
protected Class<?> determineTargetType(String beanName, RootBeanDefinition mbd, Class<?>... typesToMatch) {
|
||||
Class<?> targetType = mbd.getTargetType();
|
||||
if (targetType == null) {
|
||||
@@ -681,6 +683,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @return the type for the bean if determinable, or {@code null} otherwise
|
||||
* @see #createBean
|
||||
*/
|
||||
@Nullable
|
||||
protected Class<?> getTypeForFactoryMethod(String beanName, RootBeanDefinition mbd, Class<?>... typesToMatch) {
|
||||
ResolvableType cachedReturnType = mbd.factoryMethodReturnType;
|
||||
if (cachedReturnType != null) {
|
||||
@@ -858,6 +861,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @param factoryMethodName the name of the factory method
|
||||
* @return the common {@code FactoryBean} object type, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
private Class<?> getTypeForFactoryBeanFromMethod(Class<?> beanClass, final String factoryMethodName) {
|
||||
class Holder { Class<?> value = null; }
|
||||
final Holder objectType = new Holder();
|
||||
@@ -893,6 +897,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @param bean the raw bean instance
|
||||
* @return the object to expose as bean reference
|
||||
*/
|
||||
@Nullable
|
||||
protected Object getEarlyBeanReference(String beanName, RootBeanDefinition mbd, Object bean) {
|
||||
Object exposedObject = bean;
|
||||
if (bean != null && !mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) {
|
||||
@@ -922,6 +927,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @return the FactoryBean instance, or {@code null} to indicate
|
||||
* that we couldn't obtain a shortcut FactoryBean instance
|
||||
*/
|
||||
@Nullable
|
||||
private FactoryBean<?> getSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
|
||||
synchronized (getSingletonMutex()) {
|
||||
BeanWrapper bw = this.factoryBeanInstanceCache.get(beanName);
|
||||
@@ -965,6 +971,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @return the FactoryBean instance, or {@code null} to indicate
|
||||
* that we couldn't obtain a shortcut FactoryBean instance
|
||||
*/
|
||||
@Nullable
|
||||
private FactoryBean<?> getNonSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
|
||||
if (isPrototypeCurrentlyInCreation(beanName)) {
|
||||
return null;
|
||||
@@ -1021,6 +1028,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @param mbd the bean definition for the bean
|
||||
* @return the shortcut-determined bean instance, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
protected Object resolveBeforeInstantiation(String beanName, RootBeanDefinition mbd) {
|
||||
Object bean = null;
|
||||
if (!Boolean.FALSE.equals(mbd.beforeInstantiationResolved)) {
|
||||
@@ -1050,6 +1058,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @return the bean object to use instead of a default instance of the target bean, or {@code null}
|
||||
* @see InstantiationAwareBeanPostProcessor#postProcessBeforeInstantiation
|
||||
*/
|
||||
@Nullable
|
||||
protected Object applyBeanPostProcessorsBeforeInstantiation(Class<?> beanClass, String beanName) {
|
||||
for (BeanPostProcessor bp : getBeanPostProcessors()) {
|
||||
if (bp instanceof InstantiationAwareBeanPostProcessor) {
|
||||
@@ -1181,6 +1190,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @throws org.springframework.beans.BeansException in case of errors
|
||||
* @see org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor#determineCandidateConstructors
|
||||
*/
|
||||
@Nullable
|
||||
protected Constructor<?>[] determineConstructorsFromBeanPostProcessors(Class<?> beanClass, String beanName)
|
||||
throws BeansException {
|
||||
|
||||
@@ -1241,7 +1251,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @see #getBean(String, Object[])
|
||||
*/
|
||||
protected BeanWrapper instantiateUsingFactoryMethod(
|
||||
String beanName, RootBeanDefinition mbd, Object[] explicitArgs) {
|
||||
String beanName, RootBeanDefinition mbd, @Nullable Object[] explicitArgs) {
|
||||
|
||||
return new ConstructorResolver(this).instantiateUsingFactoryMethod(beanName, mbd, explicitArgs);
|
||||
}
|
||||
@@ -1261,7 +1271,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @return a BeanWrapper for the new instance
|
||||
*/
|
||||
protected BeanWrapper autowireConstructor(
|
||||
String beanName, RootBeanDefinition mbd, Constructor<?>[] ctors, Object[] explicitArgs) {
|
||||
String beanName, RootBeanDefinition mbd, Constructor<?>[] ctors, @Nullable Object[] explicitArgs) {
|
||||
|
||||
return new ConstructorResolver(this).autowireConstructor(beanName, mbd, ctors, explicitArgs);
|
||||
}
|
||||
@@ -1674,7 +1684,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @see #invokeInitMethods
|
||||
* @see #applyBeanPostProcessorsAfterInitialization
|
||||
*/
|
||||
protected Object initializeBean(final String beanName, final Object bean, RootBeanDefinition mbd) {
|
||||
protected Object initializeBean(final String beanName, final Object bean, @Nullable RootBeanDefinition mbd) {
|
||||
if (System.getSecurityManager() != null) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
@Override
|
||||
@@ -1734,7 +1744,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
||||
* @throws Throwable if thrown by init methods or by the invocation process
|
||||
* @see #invokeCustomInitMethod
|
||||
*/
|
||||
protected void invokeInitMethods(String beanName, final Object bean, RootBeanDefinition mbd)
|
||||
protected void invokeInitMethods(String beanName, final Object bean, @Nullable RootBeanDefinition mbd)
|
||||
throws Throwable {
|
||||
|
||||
boolean isInitializingBean = (bean instanceof InitializingBean);
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
||||
import org.springframework.core.io.DescriptiveResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -370,6 +371,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* @throws IllegalStateException if the bean definition does not define a bean class,
|
||||
* or a specified bean class name has not been resolved into an actual Class
|
||||
*/
|
||||
@Nullable
|
||||
public Class<?> getBeanClass() throws IllegalStateException {
|
||||
Object beanClassObject = this.beanClass;
|
||||
if (beanClassObject == null) {
|
||||
@@ -674,6 +676,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* Return a callback for creating an instance of the bean, if any.
|
||||
* @since 5.0
|
||||
*/
|
||||
@Nullable
|
||||
public Supplier<?> getInstanceSupplier() {
|
||||
return this.instanceSupplier;
|
||||
}
|
||||
@@ -821,6 +824,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
/**
|
||||
* Return the name of the initializer method.
|
||||
*/
|
||||
@Nullable
|
||||
public String getInitMethodName() {
|
||||
return this.initMethodName;
|
||||
}
|
||||
@@ -853,6 +857,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
/**
|
||||
* Return the name of the destroy method.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDestroyMethodName() {
|
||||
return this.destroyMethodName;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -119,7 +120,7 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable
|
||||
* @see org.springframework.core.io.support.ResourcePatternResolver
|
||||
* @see org.springframework.core.io.support.PathMatchingResourcePatternResolver
|
||||
*/
|
||||
public void setResourceLoader(ResourceLoader resourceLoader) {
|
||||
public void setResourceLoader(@Nullable ResourceLoader resourceLoader) {
|
||||
this.resourceLoader = resourceLoader;
|
||||
}
|
||||
|
||||
@@ -203,7 +204,7 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable
|
||||
* @see #loadBeanDefinitions(org.springframework.core.io.Resource)
|
||||
* @see #loadBeanDefinitions(org.springframework.core.io.Resource[])
|
||||
*/
|
||||
public int loadBeanDefinitions(String location, Set<Resource> actualResources) throws BeanDefinitionStoreException {
|
||||
public int loadBeanDefinitions(String location, @Nullable Set<Resource> actualResources) throws BeanDefinitionStoreException {
|
||||
ResourceLoader resourceLoader = getResourceLoader();
|
||||
if (resourceLoader == null) {
|
||||
throw new BeanDefinitionStoreException(
|
||||
|
||||
@@ -71,6 +71,7 @@ import org.springframework.core.DecoratingClassLoader;
|
||||
import org.springframework.core.NamedThreadLocal;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -179,7 +180,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
* @param parentBeanFactory parent bean factory, or {@code null} if none
|
||||
* @see #getBean
|
||||
*/
|
||||
public AbstractBeanFactory(BeanFactory parentBeanFactory) {
|
||||
public AbstractBeanFactory(@Nullable BeanFactory parentBeanFactory) {
|
||||
this.parentBeanFactory = parentBeanFactory;
|
||||
}
|
||||
|
||||
@@ -787,6 +788,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
* Return the custom TypeConverter to use, if any.
|
||||
* @return the custom TypeConverter, or {@code null} if none specified
|
||||
*/
|
||||
@Nullable
|
||||
protected TypeConverter getCustomTypeConverter() {
|
||||
return this.typeConverter;
|
||||
}
|
||||
@@ -1228,7 +1230,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
* @throws BeanDefinitionStoreException in case of an invalid bean definition
|
||||
*/
|
||||
protected RootBeanDefinition getMergedBeanDefinition(
|
||||
String beanName, BeanDefinition bd, BeanDefinition containingBd)
|
||||
String beanName, BeanDefinition bd, @Nullable BeanDefinition containingBd)
|
||||
throws BeanDefinitionStoreException {
|
||||
|
||||
synchronized (this.mergedBeanDefinitions) {
|
||||
@@ -1310,7 +1312,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
* @param args the arguments for bean creation, if any
|
||||
* @throws BeanDefinitionStoreException in case of validation failure
|
||||
*/
|
||||
protected void checkMergedBeanDefinition(RootBeanDefinition mbd, String beanName, Object[] args)
|
||||
protected void checkMergedBeanDefinition(RootBeanDefinition mbd, String beanName, @Nullable Object[] args)
|
||||
throws BeanDefinitionStoreException {
|
||||
|
||||
if (mbd.isAbstract()) {
|
||||
@@ -1355,6 +1357,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
* @return the resolved bean class (or {@code null} if none)
|
||||
* @throws CannotLoadBeanClassException if we failed to load the class
|
||||
*/
|
||||
@Nullable
|
||||
protected Class<?> resolveBeanClass(final RootBeanDefinition mbd, String beanName, final Class<?>... typesToMatch)
|
||||
throws CannotLoadBeanClassException {
|
||||
try {
|
||||
@@ -1460,6 +1463,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
* (also signals that the returned {@code Class} will never be exposed to application code)
|
||||
* @return the type of the bean, or {@code null} if not predictable
|
||||
*/
|
||||
@Nullable
|
||||
protected Class<?> predictBeanType(String beanName, RootBeanDefinition mbd, Class<?>... typesToMatch) {
|
||||
Class<?> targetType = mbd.getTargetType();
|
||||
if (targetType != null) {
|
||||
@@ -1496,6 +1500,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
|
||||
* @see #getBean(String)
|
||||
*/
|
||||
@Nullable
|
||||
protected Class<?> getTypeForFactoryBean(String beanName, RootBeanDefinition mbd) {
|
||||
if (!mbd.isSingleton()) {
|
||||
return null;
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.support;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.DependencyDescriptor;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Strategy interface for determining whether a specific bean definition
|
||||
@@ -64,6 +65,7 @@ public interface AutowireCandidateResolver {
|
||||
* or {@code null} if none found
|
||||
* @since 3.0
|
||||
*/
|
||||
@Nullable
|
||||
default Object getSuggestedValue(DependencyDescriptor descriptor) {
|
||||
return null;
|
||||
}
|
||||
@@ -78,6 +80,7 @@ public interface AutowireCandidateResolver {
|
||||
* or {@code null} if straight resolution is to be performed
|
||||
* @since 4.0
|
||||
*/
|
||||
@Nullable
|
||||
default Object getLazyResolutionProxyIfNecessary(DependencyDescriptor descriptor, String beanName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.beans.factory.support;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Simple interface for bean definition readers.
|
||||
@@ -70,6 +71,7 @@ public interface BeanDefinitionReader {
|
||||
* but rather to just register bean definitions with class names,
|
||||
* with the corresponding Classes to be resolved later (or never).
|
||||
*/
|
||||
@Nullable
|
||||
ClassLoader getBeanClassLoader();
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.beans.factory.BeanFactoryUtils;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -54,7 +55,7 @@ public class BeanDefinitionReaderUtils {
|
||||
* @throws ClassNotFoundException if the bean class could not be loaded
|
||||
*/
|
||||
public static AbstractBeanDefinition createBeanDefinition(
|
||||
String parentName, String className, ClassLoader classLoader) throws ClassNotFoundException {
|
||||
@Nullable String parentName, @Nullable String className, @Nullable ClassLoader classLoader) throws ClassNotFoundException {
|
||||
|
||||
GenericBeanDefinition bd = new GenericBeanDefinition();
|
||||
bd.setParentName(parentName);
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanNameReference;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.config.TypedStringValue;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -100,7 +101,7 @@ class BeanDefinitionValueResolver {
|
||||
* @param value the value object to resolve
|
||||
* @return the resolved object
|
||||
*/
|
||||
public Object resolveValueIfNecessary(Object argName, Object value) {
|
||||
public Object resolveValueIfNecessary(Object argName, @Nullable Object value) {
|
||||
// We must check each value to see whether it requires a runtime reference
|
||||
// to another bean to be resolved.
|
||||
if (value instanceof RuntimeBeanReference) {
|
||||
@@ -262,6 +263,7 @@ class BeanDefinitionValueResolver {
|
||||
* @throws ClassNotFoundException if the specified type cannot be resolved
|
||||
* @see TypedStringValue#resolveTargetType
|
||||
*/
|
||||
@Nullable
|
||||
protected Class<?> resolveTargetType(TypedStringValue value) throws ClassNotFoundException {
|
||||
if (value.hasTargetType()) {
|
||||
return value.getTargetType();
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.cglib.proxy.Factory;
|
||||
import org.springframework.cglib.proxy.MethodInterceptor;
|
||||
import org.springframework.cglib.proxy.MethodProxy;
|
||||
import org.springframework.cglib.proxy.NoOp;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -111,7 +112,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt
|
||||
* Ignored if the {@code ctor} parameter is {@code null}.
|
||||
* @return new instance of the dynamically generated subclass
|
||||
*/
|
||||
public Object instantiate(Constructor<?> ctor, Object... args) {
|
||||
public Object instantiate(@Nullable Constructor<?> ctor, Object... args) {
|
||||
Class<?> subclass = createEnhancedSubclass(this.beanDefinition);
|
||||
Object instance;
|
||||
if (ctor == null) {
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.NamedThreadLocal;
|
||||
import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.MethodInvoker;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -100,7 +101,7 @@ class ConstructorResolver {
|
||||
* @return a BeanWrapper for the new instance
|
||||
*/
|
||||
public BeanWrapper autowireConstructor(final String beanName, final RootBeanDefinition mbd,
|
||||
Constructor<?>[] chosenCtors, final Object[] explicitArgs) {
|
||||
@Nullable Constructor<?>[] chosenCtors, @Nullable final Object[] explicitArgs) {
|
||||
|
||||
BeanWrapperImpl bw = new BeanWrapperImpl();
|
||||
this.beanFactory.initBeanWrapper(bw);
|
||||
@@ -353,8 +354,9 @@ class ConstructorResolver {
|
||||
* method, or {@code null} if none (-> use constructor argument values from bean definition)
|
||||
* @return a BeanWrapper for the new instance
|
||||
*/
|
||||
@Nullable
|
||||
public BeanWrapper instantiateUsingFactoryMethod(
|
||||
final String beanName, final RootBeanDefinition mbd, final Object[] explicitArgs) {
|
||||
final String beanName, final RootBeanDefinition mbd, @Nullable final Object[] explicitArgs) {
|
||||
|
||||
BeanWrapperImpl bw = new BeanWrapperImpl();
|
||||
this.beanFactory.initBeanWrapper(bw);
|
||||
@@ -924,6 +926,7 @@ class ConstructorResolver {
|
||||
*/
|
||||
private static class ConstructorPropertiesChecker {
|
||||
|
||||
@Nullable
|
||||
public static String[] evaluate(Constructor<?> candidate, int paramCount) {
|
||||
ConstructorProperties cp = candidate.getAnnotation(ConstructorProperties.class);
|
||||
if (cp != null) {
|
||||
|
||||
@@ -41,6 +41,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -72,6 +73,7 @@ import org.springframework.beans.factory.config.NamedBeanHolder;
|
||||
import org.springframework.core.OrderComparator;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CompositeIterator;
|
||||
@@ -269,6 +271,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
* Return the dependency comparator for this BeanFactory (may be {@code null}.
|
||||
* @since 4.0
|
||||
*/
|
||||
@Nullable
|
||||
public Comparator<Object> getDependencyComparator() {
|
||||
return this.dependencyComparator;
|
||||
}
|
||||
@@ -987,6 +990,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
private <T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType, Object... args) throws BeansException {
|
||||
Assert.notNull(requiredType, "Required type must not be null");
|
||||
String[] candidateNames = getBeanNamesForType(requiredType);
|
||||
@@ -1059,6 +1063,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object doResolveDependency(DependencyDescriptor descriptor, String beanName,
|
||||
Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException {
|
||||
|
||||
@@ -1315,6 +1320,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
* @param descriptor the target dependency to match against
|
||||
* @return the name of the autowire candidate, or {@code null} if none found
|
||||
*/
|
||||
@Nullable
|
||||
protected String determineAutowireCandidate(Map<String, Object> candidates, DependencyDescriptor descriptor) {
|
||||
Class<?> requiredType = descriptor.getDependencyType();
|
||||
String primaryCandidate = determinePrimaryCandidate(candidates, requiredType);
|
||||
@@ -1345,6 +1351,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
* @return the name of the primary candidate, or {@code null} if none found
|
||||
* @see #isPrimary(String, Object)
|
||||
*/
|
||||
@Nullable
|
||||
protected String determinePrimaryCandidate(Map<String, Object> candidates, Class<?> requiredType) {
|
||||
String primaryBeanName = null;
|
||||
for (Map.Entry<String, Object> entry : candidates.entrySet()) {
|
||||
@@ -1382,6 +1389,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
* or {@code null} if none found
|
||||
* @see #getPriority(Object)
|
||||
*/
|
||||
@Nullable
|
||||
protected String determineHighestPriorityCandidate(Map<String, Object> candidates, Class<?> requiredType) {
|
||||
String highestPriorityBeanName = null;
|
||||
Integer highestPriority = null;
|
||||
@@ -1438,6 +1446,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
* @param beanInstance the bean instance to check (can be {@code null})
|
||||
* @return the priority assigned to that bean or {@code null} if none is set
|
||||
*/
|
||||
@Nullable
|
||||
protected Integer getPriority(Object beanInstance) {
|
||||
Comparator<Object> comparator = getDependencyComparator();
|
||||
if (comparator instanceof OrderComparator) {
|
||||
@@ -1727,6 +1736,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
return sources.toArray(new Object[sources.size()]);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RootBeanDefinition getRootBeanDefinition(String beanName) {
|
||||
if (beanName != null && containsBeanDefinition(beanName)) {
|
||||
BeanDefinition bd = getMergedBeanDefinition(beanName);
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.ObjectFactory;
|
||||
import org.springframework.beans.factory.config.SingletonBeanRegistry;
|
||||
import org.springframework.core.SimpleAliasRegistry;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -181,6 +182,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
|
||||
* @param allowEarlyReference whether early references should be created or not
|
||||
* @return the registered singleton object, or {@code null} if none found
|
||||
*/
|
||||
@Nullable
|
||||
protected Object getSingleton(String beanName, boolean allowEarlyReference) {
|
||||
Object singletonObject = this.singletonObjects.get(beanName);
|
||||
if (singletonObject == null && isSingletonCurrentlyInCreation(beanName)) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -175,6 +176,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||
* <p>Also processes the {@link java.io.Closeable} and {@link java.lang.AutoCloseable}
|
||||
* interfaces, reflectively calling the "close" method on implementing beans as well.
|
||||
*/
|
||||
@Nullable
|
||||
private String inferDestroyMethodIfNecessary(Object bean, RootBeanDefinition beanDefinition) {
|
||||
String destroyMethodName = beanDefinition.getDestroyMethodName();
|
||||
if (AbstractBeanDefinition.INFER_METHOD.equals(destroyMethodName) ||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.BeanCurrentlyInCreationException;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Support base class for singleton registries which need to handle
|
||||
@@ -52,6 +53,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
|
||||
* @return the FactoryBean's object type,
|
||||
* or {@code null} if the type cannot be determined yet
|
||||
*/
|
||||
@Nullable
|
||||
protected Class<?> getTypeForFactoryBean(final FactoryBean<?> factoryBean) {
|
||||
try {
|
||||
if (System.getSecurityManager() != null) {
|
||||
@@ -81,6 +83,7 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
|
||||
* @return the object obtained from the FactoryBean,
|
||||
* or {@code null} if not available
|
||||
*/
|
||||
@Nullable
|
||||
protected Object getCachedObjectForFactoryBean(String beanName) {
|
||||
Object object = this.factoryBeanObjectCache.get(beanName);
|
||||
return (object != NULL_OBJECT ? object : null);
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.DependencyDescriptor;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
@@ -131,6 +132,7 @@ public class GenericTypeAwareAutowireCandidateResolver extends SimpleAutowireCan
|
||||
return dependencyType.isAssignableFrom(targetType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected RootBeanDefinition getResolvedDecoratedDefinition(RootBeanDefinition rbd) {
|
||||
BeanDefinitionHolder decDef = rbd.getDecoratedDefinition();
|
||||
if (decDef != null && this.beanFactory instanceof ConfigurableListableBeanFactory) {
|
||||
@@ -145,6 +147,7 @@ public class GenericTypeAwareAutowireCandidateResolver extends SimpleAutowireCan
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ResolvableType getReturnTypeForFactoryMethod(RootBeanDefinition rbd, DependencyDescriptor descriptor) {
|
||||
// Should typically be set for any kind of factory method, since the BeanFactory
|
||||
// pre-resolves them before reaching out to the AutowireCandidateResolver...
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface responsible for creating instances corresponding to a root bean definition.
|
||||
@@ -44,7 +45,7 @@ public interface InstantiationStrategy {
|
||||
* @return a bean instance for this bean definition
|
||||
* @throws BeansException if the instantiation attempt failed
|
||||
*/
|
||||
Object instantiate(RootBeanDefinition bd, String beanName, BeanFactory owner)
|
||||
Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner)
|
||||
throws BeansException;
|
||||
|
||||
/**
|
||||
@@ -60,7 +61,7 @@ public interface InstantiationStrategy {
|
||||
* @return a bean instance for this bean definition
|
||||
* @throws BeansException if the instantiation attempt failed
|
||||
*/
|
||||
Object instantiate(RootBeanDefinition bd, String beanName, BeanFactory owner,
|
||||
Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner,
|
||||
Constructor<?> ctor, Object... args) throws BeansException;
|
||||
|
||||
/**
|
||||
@@ -78,7 +79,7 @@ public interface InstantiationStrategy {
|
||||
* @return a bean instance for this bean definition
|
||||
* @throws BeansException if the instantiation attempt failed
|
||||
*/
|
||||
Object instantiate(RootBeanDefinition bd, String beanName, BeanFactory owner,
|
||||
Object factoryBean, Method factoryMethod, Object... args) throws BeansException;
|
||||
Object instantiate(RootBeanDefinition bd, @Nullable String beanName, BeanFactory owner,
|
||||
@Nullable Object factoryBean, Method factoryMethod, Object... args) throws BeansException;
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.beans.factory.support;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -43,7 +44,7 @@ public class LookupOverride extends MethodOverride {
|
||||
* @param beanName the name of the bean in the current {@code BeanFactory}
|
||||
* that the overridden method should return (may be {@code null})
|
||||
*/
|
||||
public LookupOverride(String methodName, String beanName) {
|
||||
public LookupOverride(String methodName, @Nullable String beanName) {
|
||||
super(methodName);
|
||||
this.beanName = beanName;
|
||||
}
|
||||
@@ -54,7 +55,7 @@ public class LookupOverride extends MethodOverride {
|
||||
* @param beanName the name of the bean in the current {@code BeanFactory}
|
||||
* that the overridden method should return (may be {@code null})
|
||||
*/
|
||||
public LookupOverride(Method method, String beanName) {
|
||||
public LookupOverride(Method method, @Nullable String beanName) {
|
||||
super(method.getName());
|
||||
this.method = method;
|
||||
this.beanName = beanName;
|
||||
|
||||
@@ -21,6 +21,8 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Set of method overrides, determining which, if any, methods on a
|
||||
* managed object the Spring IoC container will override at runtime.
|
||||
@@ -95,6 +97,7 @@ public class MethodOverrides {
|
||||
* @param method method to check for overrides for
|
||||
* @return the method override, or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
public MethodOverride getOverride(Method method) {
|
||||
if (!this.modified) {
|
||||
return null;
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.EncodedResource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.DefaultPropertiesPersister;
|
||||
import org.springframework.util.PropertiesPersister;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -217,7 +218,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
|
||||
* @return the number of bean definitions found
|
||||
* @throws BeanDefinitionStoreException in case of loading or parsing errors
|
||||
*/
|
||||
public int loadBeanDefinitions(Resource resource, String prefix) throws BeanDefinitionStoreException {
|
||||
public int loadBeanDefinitions(Resource resource, @Nullable String prefix) throws BeanDefinitionStoreException {
|
||||
return loadBeanDefinitions(new EncodedResource(resource), prefix);
|
||||
}
|
||||
|
||||
@@ -241,7 +242,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
|
||||
* @return the number of bean definitions found
|
||||
* @throws BeanDefinitionStoreException in case of loading or parsing errors
|
||||
*/
|
||||
public int loadBeanDefinitions(EncodedResource encodedResource, String prefix)
|
||||
public int loadBeanDefinitions(EncodedResource encodedResource, @Nullable String prefix)
|
||||
throws BeanDefinitionStoreException {
|
||||
|
||||
Properties props = new Properties();
|
||||
@@ -287,7 +288,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
|
||||
* @return the number of bean definitions found
|
||||
* @throws BeanDefinitionStoreException in case of loading or parsing errors
|
||||
*/
|
||||
public int registerBeanDefinitions(ResourceBundle rb, String prefix) throws BeanDefinitionStoreException {
|
||||
public int registerBeanDefinitions(ResourceBundle rb, @Nullable String prefix) throws BeanDefinitionStoreException {
|
||||
// Simply create a map and call overloaded method.
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Enumeration<String> keys = rb.getKeys();
|
||||
@@ -324,7 +325,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
|
||||
* @return the number of bean definitions found
|
||||
* @throws BeansException in case of loading or parsing errors
|
||||
*/
|
||||
public int registerBeanDefinitions(Map<?, ?> map, String prefix) throws BeansException {
|
||||
public int registerBeanDefinitions(Map<?, ?> map, @Nullable String prefix) throws BeansException {
|
||||
return registerBeanDefinitions(map, prefix, "Map " + map);
|
||||
}
|
||||
|
||||
@@ -342,7 +343,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
|
||||
* @throws BeansException in case of loading or parsing errors
|
||||
* @see #registerBeanDefinitions(Map, String)
|
||||
*/
|
||||
public int registerBeanDefinitions(Map<?, ?> map, String prefix, String resourceDescription)
|
||||
public int registerBeanDefinitions(Map<?, ?> map, @Nullable String prefix, String resourceDescription)
|
||||
throws BeansException {
|
||||
|
||||
if (prefix == null) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -251,6 +252,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
|
||||
/**
|
||||
* Return the target definition that is being decorated by this bean definition, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public BeanDefinitionHolder getDecoratedDefinition() {
|
||||
return this.decoratedDefinition;
|
||||
}
|
||||
@@ -271,6 +273,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
|
||||
* Otherwise, the factory method and target class will be checked.
|
||||
* @since 4.3.3
|
||||
*/
|
||||
@Nullable
|
||||
public AnnotatedElement getQualifiedElement() {
|
||||
return this.qualifiedElement;
|
||||
}
|
||||
@@ -323,6 +326,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
|
||||
* Return the resolved factory method as a Java Method object, if available.
|
||||
* @return the factory method, or {@code null} if not found or not resolved yet
|
||||
*/
|
||||
@Nullable
|
||||
public Method getResolvedFactoryMethod() {
|
||||
synchronized (this.constructorArgumentLock) {
|
||||
Executable candidate = this.resolvedConstructorOrFactoryMethod;
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.beans.BeanInstantiationException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -50,6 +51,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
|
||||
* <p>Allows factory method implementations to determine whether the current
|
||||
* caller is the container itself as opposed to user code.
|
||||
*/
|
||||
@Nullable
|
||||
public static Method getCurrentlyInvokedFactoryMethod() {
|
||||
return currentlyInvokedFactoryMethod.get();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.beans.factory.support;
|
||||
import java.security.AccessControlContext;
|
||||
import java.security.AccessController;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Simple {@link SecurityContextProvider} implementation.
|
||||
*
|
||||
@@ -46,7 +48,7 @@ public class SimpleSecurityContextProvider implements SecurityContextProvider {
|
||||
* @param acc access control context (can be {@code null})
|
||||
* @see AccessController#getContext()
|
||||
*/
|
||||
public SimpleSecurityContextProvider(AccessControlContext acc) {
|
||||
public SimpleSecurityContextProvider(@Nullable AccessControlContext acc) {
|
||||
this.acc = acc;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Classes supporting the {@code org.springframework.beans.factory} package.
|
||||
* Contains abstract base classes for {@code BeanFactory} implementations.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.beans.factory.support;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -89,6 +90,7 @@ public class BeanConfigurerSupport implements BeanFactoryAware, InitializingBean
|
||||
* <p>The default implementation builds a {@link ClassNameBeanWiringInfoResolver}.
|
||||
* @return the default BeanWiringInfoResolver (never {@code null})
|
||||
*/
|
||||
@Nullable
|
||||
protected BeanWiringInfoResolver createDefaultBeanWiringInfoResolver() {
|
||||
return new ClassNameBeanWiringInfoResolver();
|
||||
}
|
||||
@@ -118,7 +120,7 @@ public class BeanConfigurerSupport implements BeanFactoryAware, InitializingBean
|
||||
* Typically called by an aspect, for all bean instances matched by a pointcut.
|
||||
* @param beanInstance the bean instance to configure (must <b>not</b> be {@code null})
|
||||
*/
|
||||
public void configureBean(Object beanInstance) {
|
||||
public void configureBean(@Nullable Object beanInstance) {
|
||||
if (this.beanFactory == null) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("BeanFactory has not been set on " + ClassUtils.getShortName(getClass()) + ": " +
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.factory.wiring;
|
||||
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -118,6 +119,7 @@ public class BeanWiringInfo {
|
||||
/**
|
||||
* Return the specific bean name that this BeanWiringInfo points to, if any.
|
||||
*/
|
||||
@Nullable
|
||||
public String getBeanName() {
|
||||
return this.beanName;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.beans.factory.wiring;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Strategy interface to be implemented by objects than can resolve bean name
|
||||
* information, given a newly instantiated bean object. Invocations to the
|
||||
@@ -39,6 +41,7 @@ public interface BeanWiringInfoResolver {
|
||||
* @param beanInstance the bean instance to resolve info for
|
||||
* @return the BeanWiringInfo, or {@code null} if not found
|
||||
*/
|
||||
@Nullable
|
||||
BeanWiringInfo resolveWiringInfo(Object beanInstance);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
* Mechanism to determine bean wiring metadata from a bean instance.
|
||||
* Foundation for aspect-driven bean configuration.
|
||||
*/
|
||||
@NonNullApi
|
||||
package org.springframework.beans.factory.wiring;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Base class for those {@link BeanDefinitionParser} implementations that
|
||||
@@ -95,6 +96,7 @@ public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef
|
||||
* @return the name of the parent bean for the currently parsed bean,
|
||||
* or {@code null} if none
|
||||
*/
|
||||
@Nullable
|
||||
protected String getParentName(Element element) {
|
||||
return null;
|
||||
}
|
||||
@@ -111,6 +113,7 @@ public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef
|
||||
* the supplied {@code Element}, or {@code null} if none
|
||||
* @see #getBeanClassName
|
||||
*/
|
||||
@Nullable
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return null;
|
||||
}
|
||||
@@ -122,6 +125,7 @@ public abstract class AbstractSingleBeanDefinitionParser extends AbstractBeanDef
|
||||
* the supplied {@code Element}, or {@code null} if none
|
||||
* @see #getBeanClass
|
||||
*/
|
||||
@Nullable
|
||||
protected String getBeanClassName(Element element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.beans.factory.xml;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Interface used by the {@link DefaultBeanDefinitionDocumentReader} to handle custom,
|
||||
@@ -51,6 +52,7 @@ public interface BeanDefinitionParser {
|
||||
* provides access to a {@link org.springframework.beans.factory.support.BeanDefinitionRegistry}
|
||||
* @return the primary {@link BeanDefinition}
|
||||
*/
|
||||
@Nullable
|
||||
BeanDefinition parse(Element element, ParserContext parserContext);
|
||||
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ import org.springframework.beans.factory.support.ManagedProperties;
|
||||
import org.springframework.beans.factory.support.ManagedSet;
|
||||
import org.springframework.beans.factory.support.MethodOverrides;
|
||||
import org.springframework.beans.factory.support.ReplaceOverride;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -322,7 +323,7 @@ public class BeanDefinitionParserDelegate {
|
||||
* @param parentDefaults the parent BeanDefinitionParserDelegate (if any) defaults to fall back to
|
||||
* @param root the root element of the current bean definition document (or nested beans element)
|
||||
*/
|
||||
protected void populateDefaults(DocumentDefaultsDefinition defaults, DocumentDefaultsDefinition parentDefaults, Element root) {
|
||||
protected void populateDefaults(DocumentDefaultsDefinition defaults, @Nullable DocumentDefaultsDefinition parentDefaults, Element root) {
|
||||
String lazyInit = root.getAttribute(DEFAULT_LAZY_INIT_ATTRIBUTE);
|
||||
if (DEFAULT_VALUE.equals(lazyInit)) {
|
||||
// Potentially inherited from outer <beans> sections, otherwise falling back to false.
|
||||
@@ -372,6 +373,7 @@ public class BeanDefinitionParserDelegate {
|
||||
* Return the defaults definition object, or {@code null} if the
|
||||
* defaults have been initialized yet.
|
||||
*/
|
||||
@Nullable
|
||||
public DocumentDefaultsDefinition getDefaults() {
|
||||
return this.defaults;
|
||||
}
|
||||
@@ -404,6 +406,7 @@ public class BeanDefinitionParserDelegate {
|
||||
* if there were errors during parse. Errors are reported to the
|
||||
* {@link org.springframework.beans.factory.parsing.ProblemReporter}.
|
||||
*/
|
||||
@Nullable
|
||||
public BeanDefinitionHolder parseBeanDefinitionElement(Element ele) {
|
||||
return parseBeanDefinitionElement(ele, null);
|
||||
}
|
||||
@@ -413,6 +416,7 @@ public class BeanDefinitionParserDelegate {
|
||||
* if there were errors during parse. Errors are reported to the
|
||||
* {@link org.springframework.beans.factory.parsing.ProblemReporter}.
|
||||
*/
|
||||
@Nullable
|
||||
public BeanDefinitionHolder parseBeanDefinitionElement(Element ele, BeanDefinition containingBean) {
|
||||
String id = ele.getAttribute(ID_ATTRIBUTE);
|
||||
String nameAttr = ele.getAttribute(NAME_ATTRIBUTE);
|
||||
@@ -498,6 +502,7 @@ public class BeanDefinitionParserDelegate {
|
||||
* Parse the bean definition itself, without regard to name or aliases. May return
|
||||
* {@code null} if problems occurred during the parsing of the bean definition.
|
||||
*/
|
||||
@Nullable
|
||||
public AbstractBeanDefinition parseBeanDefinitionElement(
|
||||
Element ele, String beanName, BeanDefinition containingBean) {
|
||||
|
||||
@@ -901,6 +906,7 @@ public class BeanDefinitionParserDelegate {
|
||||
* Get the value of a property element. May be a list etc.
|
||||
* Also used for constructor arguments, "propertyName" being null in this case.
|
||||
*/
|
||||
@Nullable
|
||||
public Object parsePropertyValue(Element ele, BeanDefinition bd, String propertyName) {
|
||||
String elementName = (propertyName != null) ?
|
||||
"<property> element for property '" + propertyName + "'" :
|
||||
@@ -966,6 +972,7 @@ public class BeanDefinitionParserDelegate {
|
||||
* @param defaultValueType the default type (class name) for any
|
||||
* {@code <value>} tag that might be created
|
||||
*/
|
||||
@Nullable
|
||||
public Object parsePropertySubElement(Element ele, BeanDefinition bd, String defaultValueType) {
|
||||
if (!isDefaultNamespace(ele)) {
|
||||
return parseNestedCustomElement(ele, bd);
|
||||
@@ -1035,6 +1042,7 @@ public class BeanDefinitionParserDelegate {
|
||||
/**
|
||||
* Return a typed String value Object for the given 'idref' element.
|
||||
*/
|
||||
@Nullable
|
||||
public Object parseIdRefElement(Element ele) {
|
||||
// A generic reference to any name of any bean.
|
||||
String refName = ele.getAttribute(BEAN_REF_ATTRIBUTE);
|
||||
@@ -1346,6 +1354,7 @@ public class BeanDefinitionParserDelegate {
|
||||
return parseCustomElement(ele, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BeanDefinition parseCustomElement(Element ele, BeanDefinition containingBd) {
|
||||
String namespaceUri = getNamespaceURI(ele);
|
||||
NamespaceHandler handler = this.readerContext.getNamespaceHandlerResolver().resolve(namespaceUri);
|
||||
@@ -1405,6 +1414,7 @@ public class BeanDefinitionParserDelegate {
|
||||
return originalDef;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private BeanDefinitionHolder parseNestedCustomElement(Element ele, BeanDefinition containingBd) {
|
||||
BeanDefinition innerDefinition = parseCustomElement(ele, containingBd);
|
||||
if (innerDefinition == null) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.xml.sax.InputSource;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* EntityResolver implementation for the Spring beans DTD,
|
||||
@@ -50,6 +51,7 @@ public class BeansDtdResolver implements EntityResolver {
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public InputSource resolveEntity(String publicId, String systemId) throws IOException {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Trying to resolve XML entity with public ID [" + publicId +
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user