Properly evaluate @Conditional in case of multiple imports for same config class (fixing regression in Spring Boot)
Issue: SPR-11788
This commit is contained in:
parent
748167bfa3
commit
7d78c65187
|
@ -395,6 +395,7 @@ class ConfigurationClassBeanDefinitionReader {
|
||||||
for (ConfigurationClass importedBy : configClass.getImportedBy()) {
|
for (ConfigurationClass importedBy : configClass.getImportedBy()) {
|
||||||
if (!shouldSkip(importedBy)) {
|
if (!shouldSkip(importedBy)) {
|
||||||
allSkipped = false;
|
allSkipped = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (allSkipped) {
|
if (allSkipped) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -19,40 +19,40 @@ package org.springframework.context.annotation;
|
||||||
/**
|
/**
|
||||||
* A {@link Condition} that offers more fine-grained control when used with
|
* A {@link Condition} that offers more fine-grained control when used with
|
||||||
* {@code @Configuration}. Allows certain {@link Condition}s to adapt when they match
|
* {@code @Configuration}. Allows certain {@link Condition}s to adapt when they match
|
||||||
* based on the configuration phase. For example, a condition that checks if a bean has
|
* based on the configuration phase. For example, a condition that checks if a bean
|
||||||
* already been registered might choose to only be evaluated during the
|
* has already been registered might choose to only be evaluated during the
|
||||||
* {@link ConfigurationPhase#REGISTER_BEAN REGISTER_BEAN} {@link ConfigurationPhase}.
|
* {@link ConfigurationPhase#REGISTER_BEAN REGISTER_BEAN} {@link ConfigurationPhase}.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
|
* @see Configuration
|
||||||
*/
|
*/
|
||||||
public interface ConfigurationCondition extends Condition {
|
public interface ConfigurationCondition extends Condition {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link ConfigurationPhase} in which the condition should be evaluated.
|
* Return the {@link ConfigurationPhase} in which the condition should be evaluated.
|
||||||
*/
|
*/
|
||||||
ConfigurationPhase getConfigurationPhase();
|
ConfigurationPhase getConfigurationPhase();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The various configuration phases where the condition could be evaluated.
|
* The various configuration phases where the condition could be evaluated.
|
||||||
*/
|
*/
|
||||||
public static enum ConfigurationPhase {
|
public static enum ConfigurationPhase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link Condition} should be evaluated as a {@code @Configuration} class is
|
* The {@link Condition} should be evaluated as a {@code @Configuration}
|
||||||
* being parsed.
|
* class is being parsed.
|
||||||
*
|
* <p>If the condition does not match at this point, the {@code @Configuration}
|
||||||
* <p>If the condition does not match at this point the {@code @Configuration}
|
|
||||||
* class will not be added.
|
* class will not be added.
|
||||||
*/
|
*/
|
||||||
PARSE_CONFIGURATION,
|
PARSE_CONFIGURATION,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link Condition} should be evaluated when adding a regular (non
|
* The {@link Condition} should be evaluated when adding a regular
|
||||||
* {@code @Configuration}) bean. The condition will not prevent
|
* (non {@code @Configuration}) bean. The condition will not prevent
|
||||||
* {@code @Configuration} classes from being added.
|
* {@code @Configuration} classes from being added.
|
||||||
*
|
* <p>At the time that the condition is evaluated, all {@code @Configuration}s
|
||||||
* <p>At the time that the condition is evaluated all {@code @Configuration}s
|
|
||||||
* will have been parsed.
|
* will have been parsed.
|
||||||
*/
|
*/
|
||||||
REGISTER_BEAN
|
REGISTER_BEAN
|
||||||
|
|
Loading…
Reference in New Issue