ImportRegistry properly tracks excluded superclasses

Issue: SPR-14972
This commit is contained in:
Juergen Hoeller
2016-12-09 15:01:21 +01:00
parent e1b89c7f65
commit a7ec6dc0af
5 changed files with 84 additions and 24 deletions

View File

@@ -129,7 +129,7 @@ class ConfigurationClassBeanDefinitionReader {
if (StringUtils.hasLength(beanName) && this.registry.containsBeanDefinition(beanName)) {
this.registry.removeBeanDefinition(beanName);
}
this.importRegistry.removeImportingClassFor(configClass.getMetadata().getClassName());
this.importRegistry.removeImportingClass(configClass.getMetadata().getClassName());
return;
}

View File

@@ -643,23 +643,24 @@ class ConfigurationClassParser {
this.imports.add(importedClass, importingClass);
}
@Override
public void removeImportingClassFor(String importedClass) {
for (List<AnnotationMetadata> list : this.imports.values()) {
for (Iterator<AnnotationMetadata> iterator = list.iterator(); iterator.hasNext();) {
if (iterator.next().getClassName().equals(importedClass)) {
iterator.remove();
}
}
}
}
@Override
public AnnotationMetadata getImportingClassFor(String importedClass) {
List<AnnotationMetadata> list = this.imports.get(importedClass);
return (!CollectionUtils.isEmpty(list) ? list.get(list.size() - 1) : null);
}
@Override
public void removeImportingClass(String importingClass) {
for (List<AnnotationMetadata> list : this.imports.values()) {
for (Iterator<AnnotationMetadata> iterator = list.iterator(); iterator.hasNext();) {
if (iterator.next().getClassName().equals(importingClass)) {
iterator.remove();
break;
}
}
}
}
/**
* Given a stack containing (in order)
* <ul>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ public interface ConfigurationCondition extends Condition {
/**
* The various configuration phases where the condition could be evaluated.
*/
public static enum ConfigurationPhase {
enum ConfigurationPhase {
/**
* The {@link Condition} should be evaluated as a {@code @Configuration}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -26,6 +26,6 @@ interface ImportRegistry {
AnnotationMetadata getImportingClassFor(String importedClass);
void removeImportingClassFor(String importedClass);
void removeImportingClass(String importingClass);
}