Polish
This commit is contained in:
parent
35efb251e0
commit
f96dea7011
|
|
@ -57,6 +57,7 @@ public interface Banner {
|
||||||
* Print the banner to the log file.
|
* Print the banner to the log file.
|
||||||
*/
|
*/
|
||||||
LOG
|
LOG
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -183,10 +183,8 @@ class BeanDefinitionLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int load(CharSequence source) {
|
private int load(CharSequence source) {
|
||||||
|
|
||||||
String resolvedSource = this.xmlReader.getEnvironment()
|
String resolvedSource = this.xmlReader.getEnvironment()
|
||||||
.resolvePlaceholders(source.toString());
|
.resolvePlaceholders(source.toString());
|
||||||
|
|
||||||
// Attempt as a Class
|
// Attempt as a Class
|
||||||
try {
|
try {
|
||||||
return load(ClassUtils.forName(resolvedSource, null));
|
return load(ClassUtils.forName(resolvedSource, null));
|
||||||
|
|
@ -197,7 +195,6 @@ class BeanDefinitionLoader {
|
||||||
catch (ClassNotFoundException ex) {
|
catch (ClassNotFoundException ex) {
|
||||||
// swallow exception and continue
|
// swallow exception and continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt as resources
|
// Attempt as resources
|
||||||
Resource[] resources = findResources(resolvedSource);
|
Resource[] resources = findResources(resolvedSource);
|
||||||
int loadCount = 0;
|
int loadCount = 0;
|
||||||
|
|
@ -211,13 +208,11 @@ class BeanDefinitionLoader {
|
||||||
if (atLeastOneResourceExists) {
|
if (atLeastOneResourceExists) {
|
||||||
return loadCount;
|
return loadCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt as package
|
// Attempt as package
|
||||||
Package packageResource = findPackage(resolvedSource);
|
Package packageResource = findPackage(resolvedSource);
|
||||||
if (packageResource != null) {
|
if (packageResource != null) {
|
||||||
return load(packageResource);
|
return load(packageResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalArgumentException("Invalid source '" + resolvedSource + "'");
|
throw new IllegalArgumentException("Invalid source '" + resolvedSource + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -383,17 +383,23 @@ public class SpringApplication {
|
||||||
return getSpringFactoriesInstances(type, new Class<?>[] {});
|
return getSpringFactoriesInstances(type, new Class<?>[] {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private <T> Collection<? extends T> getSpringFactoriesInstances(Class<T> type,
|
private <T> Collection<? extends T> getSpringFactoriesInstances(Class<T> type,
|
||||||
Class<?>[] parameterTypes, Object... args) {
|
Class<?>[] parameterTypes, Object... args) {
|
||||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
||||||
// Use names and ensure unique to protect against duplicates
|
// Use names and ensure unique to protect against duplicates
|
||||||
Set<String> names = new LinkedHashSet<String>(
|
Set<String> names = new LinkedHashSet<String>(
|
||||||
SpringFactoriesLoader.loadFactoryNames(type, classLoader));
|
SpringFactoriesLoader.loadFactoryNames(type, classLoader));
|
||||||
List<T> instances = new ArrayList<T>(names.size());
|
List<T> instances = createSpringFactoriesInstances(type, parameterTypes,
|
||||||
|
classLoader, args, names);
|
||||||
|
AnnotationAwareOrderComparator.sort(instances);
|
||||||
|
return instances;
|
||||||
|
}
|
||||||
|
|
||||||
// Create instances from the names
|
@SuppressWarnings("unchecked")
|
||||||
|
private <T> List<T> createSpringFactoriesInstances(Class<T> type,
|
||||||
|
Class<?>[] parameterTypes, ClassLoader classLoader, Object[] args,
|
||||||
|
Set<String> names) {
|
||||||
|
List<T> instances = new ArrayList<T>(names.size());
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
try {
|
try {
|
||||||
Class<?> instanceClass = ClassUtils.forName(name, classLoader);
|
Class<?> instanceClass = ClassUtils.forName(name, classLoader);
|
||||||
|
|
@ -407,8 +413,6 @@ public class SpringApplication {
|
||||||
"Cannot instantiate " + type + " : " + name, ex);
|
"Cannot instantiate " + type + " : " + name, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AnnotationAwareOrderComparator.sort(instances);
|
|
||||||
return instances;
|
return instances;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -420,7 +424,6 @@ public class SpringApplication {
|
||||||
return new StandardServletEnvironment();
|
return new StandardServletEnvironment();
|
||||||
}
|
}
|
||||||
return new StandardEnvironment();
|
return new StandardEnvironment();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -608,7 +611,6 @@ public class SpringApplication {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.resourceLoader != null) {
|
if (this.resourceLoader != null) {
|
||||||
if (context instanceof GenericApplicationContext) {
|
if (context instanceof GenericApplicationContext) {
|
||||||
((GenericApplicationContext) context)
|
((GenericApplicationContext) context)
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ public class SpringApplicationAdminMXBeanRegistrar
|
||||||
logger.info("Application shutdown requested.");
|
logger.info("Application shutdown requested.");
|
||||||
SpringApplicationAdminMXBeanRegistrar.this.applicationContext.close();
|
SpringApplicationAdminMXBeanRegistrar.this.applicationContext.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,9 @@ class RelaxedConversionService implements ConversionService {
|
||||||
throw new IllegalArgumentException("No enum constant "
|
throw new IllegalArgumentException("No enum constant "
|
||||||
+ this.enumType.getCanonicalName() + "." + source);
|
+ this.enumType.getCanonicalName() + "." + source);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -629,6 +629,7 @@ public class RelaxedDataBinder extends DataBinder {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[" + this.name + "]";
|
return "[" + this.name + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PropertyNode extends PathNode {
|
private static class PropertyNode extends PathNode {
|
||||||
|
|
@ -645,6 +646,7 @@ public class RelaxedDataBinder extends DataBinder {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "." + this.name;
|
return "." + this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ public class YamlJavaBeanPropertyConstructor extends Constructor {
|
||||||
*/
|
*/
|
||||||
protected final void addPropertyAlias(String alias, Class<?> type, String name) {
|
protected final void addPropertyAlias(String alias, Class<?> type, String name) {
|
||||||
Map<String, Property> typeMap = this.properties.get(type);
|
Map<String, Property> typeMap = this.properties.get(type);
|
||||||
|
|
||||||
if (typeMap == null) {
|
if (typeMap == null) {
|
||||||
typeMap = new HashMap<String, Property>();
|
typeMap = new HashMap<String, Property>();
|
||||||
this.properties.put(type, typeMap);
|
this.properties.put(type, typeMap);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue