Backport selected refinements from the nullability efforts
Issue: SPR-15656
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -81,8 +81,6 @@ public interface PropertyAccessor {
|
||||
* (may be a nested path and/or an indexed/mapped property)
|
||||
* @return the property type for the particular property,
|
||||
* or {@code null} if not determinable
|
||||
* @throws InvalidPropertyException if there is no such property or
|
||||
* if the property isn't readable
|
||||
* @throws PropertyAccessException if the property was valid but the
|
||||
* accessor method failed
|
||||
*/
|
||||
@@ -95,8 +93,8 @@ public interface PropertyAccessor {
|
||||
* (may be a nested path and/or an indexed/mapped property)
|
||||
* @return the property type for the particular property,
|
||||
* or {@code null} if not determinable
|
||||
* @throws InvalidPropertyException if there is no such property or
|
||||
* if the property isn't readable
|
||||
* @throws PropertyAccessException if the property was valid but the
|
||||
* accessor method failed
|
||||
*/
|
||||
TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -158,6 +158,22 @@ public interface BeanFactory {
|
||||
*/
|
||||
<T> T getBean(String name, Class<T> requiredType) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return an instance, which may be shared or independent, of the specified bean.
|
||||
* <p>Allows for specifying explicit constructor arguments / factory method arguments,
|
||||
* overriding the specified default arguments (if any) in the bean definition.
|
||||
* @param name the name of the bean to retrieve
|
||||
* @param args arguments to use when creating a bean instance using explicit arguments
|
||||
* (only applied when creating a new instance as opposed to retrieving an existing one)
|
||||
* @return an instance of the bean
|
||||
* @throws NoSuchBeanDefinitionException if there is no such bean definition
|
||||
* @throws BeanDefinitionStoreException if arguments have been given but
|
||||
* the affected bean isn't a prototype
|
||||
* @throws BeansException if the bean could not be created
|
||||
* @since 2.5
|
||||
*/
|
||||
Object getBean(String name, Object... args) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return the bean instance that uniquely matches the given object type, if any.
|
||||
* <p>This method goes into {@link ListableBeanFactory} by-type lookup territory
|
||||
@@ -175,22 +191,6 @@ public interface BeanFactory {
|
||||
*/
|
||||
<T> T getBean(Class<T> requiredType) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return an instance, which may be shared or independent, of the specified bean.
|
||||
* <p>Allows for specifying explicit constructor arguments / factory method arguments,
|
||||
* overriding the specified default arguments (if any) in the bean definition.
|
||||
* @param name the name of the bean to retrieve
|
||||
* @param args arguments to use when creating a bean instance using explicit arguments
|
||||
* (only applied when creating a new instance as opposed to retrieving an existing one)
|
||||
* @return an instance of the bean
|
||||
* @throws NoSuchBeanDefinitionException if there is no such bean definition
|
||||
* @throws BeanDefinitionStoreException if arguments have been given but
|
||||
* the affected bean isn't a prototype
|
||||
* @throws BeansException if the bean could not be created
|
||||
* @since 2.5
|
||||
*/
|
||||
Object getBean(String name, Object... args) throws BeansException;
|
||||
|
||||
/**
|
||||
* Return an instance, which may be shared or independent, of the specified bean.
|
||||
* <p>Allows for specifying explicit constructor arguments / factory method arguments,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -281,15 +281,15 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Constructor<Exception> determineServiceLocatorExceptionConstructor(Class<? extends Exception> exceptionClass) {
|
||||
try {
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {String.class, Throwable.class});
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(String.class, Throwable.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
try {
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {Throwable.class});
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(Throwable.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex2) {
|
||||
try {
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(new Class<?>[] {String.class});
|
||||
return (Constructor<Exception>) exceptionClass.getConstructor(String.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex3) {
|
||||
throw new IllegalArgumentException(
|
||||
@@ -357,7 +357,7 @@ public class ServiceLocatorFactoryBean implements FactoryBean<Object>, BeanFacto
|
||||
return System.identityHashCode(proxy);
|
||||
}
|
||||
else if (ReflectionUtils.isToStringMethod(method)) {
|
||||
return "Service locator: " + serviceLocatorInterface.getName();
|
||||
return "Service locator: " + serviceLocatorInterface;
|
||||
}
|
||||
else {
|
||||
return invokeServiceLocatorMethod(method, args);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,6 +37,13 @@ public class ReaderContext {
|
||||
private final SourceExtractor sourceExtractor;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new {@code ReaderContext}.
|
||||
* @param resource the XML bean definition resource
|
||||
* @param problemReporter the problem reporter in use
|
||||
* @param eventListener the event listener in use
|
||||
* @param sourceExtractor the source extractor in use
|
||||
*/
|
||||
public ReaderContext(Resource resource, ProblemReporter problemReporter,
|
||||
ReaderEventListener eventListener, SourceExtractor sourceExtractor) {
|
||||
|
||||
@@ -51,83 +58,150 @@ public class ReaderContext {
|
||||
}
|
||||
|
||||
|
||||
// Errors and warnings
|
||||
|
||||
/**
|
||||
* Raise a fatal error.
|
||||
*/
|
||||
public void fatal(String message, Object source) {
|
||||
fatal(message, source, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a fatal error.
|
||||
*/
|
||||
public void fatal(String message, Object source, Throwable ex) {
|
||||
fatal(message, source, null, ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a fatal error.
|
||||
*/
|
||||
public void fatal(String message, Object source, ParseState parseState) {
|
||||
fatal(message, source, parseState, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a fatal error.
|
||||
*/
|
||||
public void fatal(String message, Object source, ParseState parseState, Throwable cause) {
|
||||
Location location = new Location(getResource(), source);
|
||||
this.problemReporter.fatal(new Problem(message, location, parseState, cause));
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a regular error.
|
||||
*/
|
||||
public void error(String message, Object source) {
|
||||
error(message, source, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a regular error.
|
||||
*/
|
||||
public void error(String message, Object source, Throwable ex) {
|
||||
error(message, source, null, ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a regular error.
|
||||
*/
|
||||
public void error(String message, Object source, ParseState parseState) {
|
||||
error(message, source, parseState, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a regular error.
|
||||
*/
|
||||
public void error(String message, Object source, ParseState parseState, Throwable cause) {
|
||||
Location location = new Location(getResource(), source);
|
||||
this.problemReporter.error(new Problem(message, location, parseState, cause));
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a non-critical warning.
|
||||
*/
|
||||
public void warning(String message, Object source) {
|
||||
warning(message, source, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a non-critical warning.
|
||||
*/
|
||||
public void warning(String message, Object source, Throwable ex) {
|
||||
warning(message, source, null, ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a non-critical warning.
|
||||
*/
|
||||
public void warning(String message, Object source, ParseState parseState) {
|
||||
warning(message, source, parseState, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a non-critical warning.
|
||||
*/
|
||||
public void warning(String message, Object source, ParseState parseState, Throwable cause) {
|
||||
Location location = new Location(getResource(), source);
|
||||
this.problemReporter.warning(new Problem(message, location, parseState, cause));
|
||||
}
|
||||
|
||||
|
||||
// Explicit parse events
|
||||
|
||||
/**
|
||||
* Fire an defaults-registered event.
|
||||
*/
|
||||
public void fireDefaultsRegistered(DefaultsDefinition defaultsDefinition) {
|
||||
this.eventListener.defaultsRegistered(defaultsDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an component-registered event.
|
||||
*/
|
||||
public void fireComponentRegistered(ComponentDefinition componentDefinition) {
|
||||
this.eventListener.componentRegistered(componentDefinition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an alias-registered event.
|
||||
*/
|
||||
public void fireAliasRegistered(String beanName, String alias, Object source) {
|
||||
this.eventListener.aliasRegistered(new AliasDefinition(beanName, alias, source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an import-processed event.
|
||||
*/
|
||||
public void fireImportProcessed(String importedResource, Object source) {
|
||||
this.eventListener.importProcessed(new ImportDefinition(importedResource, source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an import-processed event.
|
||||
*/
|
||||
public void fireImportProcessed(String importedResource, Resource[] actualResources, Object source) {
|
||||
this.eventListener.importProcessed(new ImportDefinition(importedResource, actualResources, source));
|
||||
}
|
||||
|
||||
|
||||
// Source extraction
|
||||
|
||||
/**
|
||||
* Return the source extractor in use.
|
||||
*/
|
||||
public SourceExtractor getSourceExtractor() {
|
||||
return this.sourceExtractor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the source extractor for the given source object.
|
||||
* @param sourceCandidate the original source object
|
||||
* @return the source object to store, or {@code null} for none.
|
||||
* @see #getSourceExtractor()
|
||||
* @see SourceExtractor#extractSource
|
||||
*/
|
||||
public Object extractSource(Object sourceCandidate) {
|
||||
return this.sourceExtractor.extractSource(sourceCandidate, this.resource);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,7 +62,7 @@ public class BeanDefinitionDefaults {
|
||||
}
|
||||
|
||||
public void setInitMethodName(String initMethodName) {
|
||||
this.initMethodName = (StringUtils.hasText(initMethodName)) ? initMethodName : null;
|
||||
this.initMethodName = (StringUtils.hasText(initMethodName) ? initMethodName : null);
|
||||
}
|
||||
|
||||
public String getInitMethodName() {
|
||||
@@ -70,7 +70,7 @@ public class BeanDefinitionDefaults {
|
||||
}
|
||||
|
||||
public void setDestroyMethodName(String destroyMethodName) {
|
||||
this.destroyMethodName = (StringUtils.hasText(destroyMethodName)) ? destroyMethodName : null;
|
||||
this.destroyMethodName = (StringUtils.hasText(destroyMethodName) ? destroyMethodName : null);
|
||||
}
|
||||
|
||||
public String getDestroyMethodName() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -96,8 +96,7 @@ public class ResourceBundleEditor extends PropertyEditorSupport {
|
||||
}
|
||||
String localeString = name.substring(separator + 1);
|
||||
Locale locale = StringUtils.parseLocaleString(localeString);
|
||||
setValue((StringUtils.hasText(localeString)) ? ResourceBundle.getBundle(baseName, locale) :
|
||||
ResourceBundle.getBundle(baseName));
|
||||
setValue(locale != null ? ResourceBundle.getBundle(baseName, locale) : ResourceBundle.getBundle(baseName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user