@Import detects and accepts existing configuration class in any order of processing
This commit is contained in:
@@ -34,9 +34,7 @@ import org.springframework.util.ClassUtils;
|
||||
/**
|
||||
* Represents a user-defined {@link Configuration @Configuration} class.
|
||||
* Includes a set of {@link Bean} methods, including all such methods defined in the
|
||||
* ancestry of the class, in a 'flattened-out' manner. Note that each {@link ConfigurationClassMethod}
|
||||
* representation contains source information about where it was originally detected
|
||||
* (for the purpose of tooling with Spring IDE).
|
||||
* ancestry of the class, in a 'flattened-out' manner.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
@@ -131,14 +129,8 @@ final class ConfigurationClass {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof ConfigurationClass)) {
|
||||
return false;
|
||||
}
|
||||
ConfigurationClass otherCc = (ConfigurationClass) other;
|
||||
return getMetadata().getClassName().equals(otherCc.getMetadata().getClassName());
|
||||
return (this == other || (other instanceof ConfigurationClass &&
|
||||
getMetadata().getClassName().equals(((ConfigurationClass) other).getMetadata().getClassName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.0
|
||||
* @see ConfigurationClassParser
|
||||
*/
|
||||
class ConfigurationClassBeanDefinitionReader {
|
||||
|
||||
|
||||
@@ -37,12 +37,12 @@ import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
|
||||
/**
|
||||
* Parses a {@link Configuration} class definition, populating a configuration model.
|
||||
* This ASM-based implementation avoids reflection and eager classloading in order to
|
||||
* interoperate effectively with tooling (Spring IDE) and OSGi environments.
|
||||
* This ASM-based implementation avoids reflection and eager class loading in order to
|
||||
* interoperate effectively with lazy class loading in a Spring ApplicationContext.
|
||||
*
|
||||
* <p>This class helps separate the concern of parsing the structure of a Configuration class
|
||||
* from the concern of registering {@link BeanDefinition} objects based on the content of
|
||||
* that model.
|
||||
* <p>This class helps separate the concern of parsing the structure of a Configuration
|
||||
* class from the concern of registering {@link BeanDefinition} objects based on the
|
||||
* content of that model.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @author Juergen Hoeller
|
||||
@@ -112,7 +112,12 @@ class ConfigurationClassParser {
|
||||
metadata = null;
|
||||
}
|
||||
}
|
||||
model.add(configClass);
|
||||
if (this.model.contains(configClass) && configClass.getBeanName() != null) {
|
||||
// Explicit bean definition found, probably replacing an import.
|
||||
// Let's remove the old one and go with the new one.
|
||||
this.model.remove(configClass);
|
||||
}
|
||||
this.model.add(configClass);
|
||||
}
|
||||
|
||||
protected void doProcessConfigurationClass(ConfigurationClass configClass, AnnotationMetadata metadata) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user