Improve ImportStack#toString output
This commit is contained in:
parent
7b491370a3
commit
40798bd48f
|
|
@ -248,14 +248,22 @@ class ConfigurationClassParser {
|
||||||
// the candidate class is an ImportSelector -> delegate to it to determine imports
|
// the candidate class is an ImportSelector -> delegate to it to determine imports
|
||||||
try {
|
try {
|
||||||
ImportSelector selector = BeanUtils.instantiateClass(Class.forName(candidate), ImportSelector.class);
|
ImportSelector selector = BeanUtils.instantiateClass(Class.forName(candidate), ImportSelector.class);
|
||||||
ImportSelectorContext context = new ImportSelectorContext(importingClassMetadata, this.registry);
|
processImport(configClass, selector.selectImports(importingClassMetadata), false);
|
||||||
processImport(configClass, selector.selectImports(context), false);
|
} catch (ClassNotFoundException ex) {
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (new AssignableTypeFilter(ImportBeanDefinitionRegistrar.class).match(reader, metadataReaderFactory)) {
|
||||||
|
// the candidate class is an ImportBeanDefinitionRegistrar -> delegate to it to register additional bean definitions
|
||||||
|
try {
|
||||||
|
ImportBeanDefinitionRegistrar registrar = BeanUtils.instantiateClass(Class.forName(candidate), ImportBeanDefinitionRegistrar.class);
|
||||||
|
registrar.registerBeanDefinitions(importingClassMetadata, registry);
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
throw new IllegalStateException(ex);
|
throw new IllegalStateException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// the candidate class not an ImportSelector -> process it as a @Configuration class
|
// the candidate class not an ImportSelector or ImportBeanDefinitionRegistrar -> process it as a @Configuration class
|
||||||
this.importStack.registerImport(importingClassMetadata.getClassName(), candidate);
|
this.importStack.registerImport(importingClassMetadata.getClassName(), candidate);
|
||||||
processConfigurationClass(new ConfigurationClass(reader, null));
|
processConfigurationClass(new ConfigurationClass(reader, null));
|
||||||
}
|
}
|
||||||
|
|
@ -323,16 +331,16 @@ class ConfigurationClassParser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a stack containing (in order)
|
* Given a stack containing (in order)
|
||||||
* <ol>
|
* <ul>
|
||||||
* <li>com.acme.Foo</li>
|
* <li>com.acme.Foo</li>
|
||||||
* <li>com.acme.Bar</li>
|
* <li>com.acme.Bar</li>
|
||||||
* <li>com.acme.Baz</li>
|
* <li>com.acme.Baz</li>
|
||||||
* </ol>
|
* </ul>
|
||||||
* Returns "Foo->Bar->Baz". In the case of an empty stack, returns empty string.
|
* return "ImportStack: [Foo->Bar->Baz]".
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder("ImportStack: [");
|
||||||
Iterator<ConfigurationClass> iterator = iterator();
|
Iterator<ConfigurationClass> iterator = iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
builder.append(iterator.next().getSimpleName());
|
builder.append(iterator.next().getSimpleName());
|
||||||
|
|
@ -340,7 +348,7 @@ class ConfigurationClassParser {
|
||||||
builder.append("->");
|
builder.append("->");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.append(']').toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue