Example usage for org.springframework.context.annotation ConfigurationClass mergeImportedBy

List of usage examples for org.springframework.context.annotation ConfigurationClass mergeImportedBy

Introduction

In this page you can find the example usage for org.springframework.context.annotation ConfigurationClass mergeImportedBy.

Prototype

public void mergeImportedBy(ConfigurationClass otherConfigClass) 

Source Link

Document

Merge the imported-by declarations from the given configuration class into this one.

Usage

From source file:org.springframework.context.annotation.ConfigurationClassParser.java

protected void processConfigurationClass(ConfigurationClass configClass) throws IOException {
    if (this.conditionEvaluator.shouldSkip(configClass.getMetadata(), ConfigurationPhase.PARSE_CONFIGURATION)) {
        return;//www .j  av a2  s. c  om
    }

    ConfigurationClass existingClass = this.configurationClasses.get(configClass);
    if (existingClass != null) {
        if (configClass.isImported()) {
            if (existingClass.isImported()) {
                existingClass.mergeImportedBy(configClass);
            }
            // Otherwise ignore new imported config class; existing non-imported class overrides it.
            return;
        } else {
            // Explicit bean definition found, probably replacing an import.
            // Let's remove the old one and go with the new one.
            this.configurationClasses.remove(configClass);
            this.knownSuperclasses.values().removeIf(configClass::equals);
        }
    }

    // Recursively process the configuration class and its superclass hierarchy.
    SourceClass sourceClass = asSourceClass(configClass);
    do {
        sourceClass = doProcessConfigurationClass(configClass, sourceClass);
    } while (sourceClass != null);

    this.configurationClasses.put(configClass, configClass);
}