Merge branch '1.5.x'
This commit is contained in:
@@ -151,7 +151,7 @@ public class EndpointWebMvcChildContextConfiguration {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass({ EnableWebSecurity.class, Filter.class })
|
||||
@ConditionalOnBean(name = "springSecurityFilterChain", search = SearchStrategy.PARENTS)
|
||||
@ConditionalOnBean(name = "springSecurityFilterChain", search = SearchStrategy.ANCESTORS)
|
||||
public static class EndpointWebMvcChildContextSecurityConfiguration {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -126,7 +126,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
||||
private List<String> getMatchingBeans(ConditionContext context,
|
||||
BeanSearchSpec beans) {
|
||||
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
|
||||
if (beans.getStrategy() == SearchStrategy.PARENTS) {
|
||||
if (beans.getStrategy() == SearchStrategy.ANCESTORS) {
|
||||
BeanFactory parent = beanFactory.getParentBeanFactory();
|
||||
Assert.isInstanceOf(ConfigurableListableBeanFactory.class, parent,
|
||||
"Unable to use SearchStrategy.PARENTS");
|
||||
|
||||
@@ -29,9 +29,9 @@ public enum SearchStrategy {
|
||||
CURRENT,
|
||||
|
||||
/**
|
||||
* Search all parents and ancestors, but not the current context.
|
||||
* Search all ancestors, but not the current context.
|
||||
*/
|
||||
PARENTS,
|
||||
ANCESTORS,
|
||||
|
||||
/**
|
||||
* Search the entire hierarchy.
|
||||
|
||||
@@ -258,7 +258,7 @@ public class ConditionalOnMissingBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void grandparentIsConsideredWhenUsingParentsStrategy() {
|
||||
public void grandparentIsConsideredWhenUsingAncestorsStrategy() {
|
||||
this.context.register(ExampleBeanConfiguration.class);
|
||||
this.context.refresh();
|
||||
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
|
||||
@@ -267,7 +267,7 @@ public class ConditionalOnMissingBeanTests {
|
||||
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
|
||||
child.setParent(parent);
|
||||
child.register(ExampleBeanConfiguration.class,
|
||||
OnBeanInParentsConfiguration.class);
|
||||
OnBeanInAncestorsConfiguration.class);
|
||||
child.refresh();
|
||||
assertThat(child.getBeansOfType(ExampleBean.class)).hasSize(1);
|
||||
child.close();
|
||||
@@ -275,21 +275,21 @@ public class ConditionalOnMissingBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void currentContextIsIgnoredWhenUsingParentsStrategy() {
|
||||
public void currentContextIsIgnoredWhenUsingAncestorsStrategy() {
|
||||
this.context.refresh();
|
||||
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
|
||||
child.register(ExampleBeanConfiguration.class,
|
||||
OnBeanInParentsConfiguration.class);
|
||||
OnBeanInAncestorsConfiguration.class);
|
||||
child.setParent(this.context);
|
||||
child.refresh();
|
||||
assertThat(child.getBeansOfType(ExampleBean.class)).hasSize(2);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
protected static class OnBeanInParentsConfiguration {
|
||||
protected static class OnBeanInAncestorsConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(search = SearchStrategy.PARENTS)
|
||||
@ConditionalOnMissingBean(search = SearchStrategy.ANCESTORS)
|
||||
public ExampleBean exampleBean2() {
|
||||
return new ExampleBean("test");
|
||||
}
|
||||
|
||||
@@ -63,11 +63,11 @@ public class ConditionalOnSingleCandidateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singleCandidateInParentsOneCandidateInCurrent() {
|
||||
public void singleCandidateInAncestorsOneCandidateInCurrent() {
|
||||
load();
|
||||
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
|
||||
child.register(FooConfiguration.class,
|
||||
OnBeanSingleCandidateInParentsConfiguration.class);
|
||||
OnBeanSingleCandidateInAncestorsConfiguration.class);
|
||||
child.setParent(this.context);
|
||||
child.refresh();
|
||||
assertThat(child.containsBean("baz")).isFalse();
|
||||
@@ -75,10 +75,10 @@ public class ConditionalOnSingleCandidateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singleCandidateInParentsOneCandidateInParent() {
|
||||
public void singleCandidateInAncestorsOneCandidateInParent() {
|
||||
load(FooConfiguration.class);
|
||||
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
|
||||
child.register(OnBeanSingleCandidateInParentsConfiguration.class);
|
||||
child.register(OnBeanSingleCandidateInAncestorsConfiguration.class);
|
||||
child.setParent(this.context);
|
||||
child.refresh();
|
||||
assertThat(child.containsBean("baz")).isTrue();
|
||||
@@ -87,13 +87,13 @@ public class ConditionalOnSingleCandidateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singleCandidateInParentsOneCandidateInGrandparent() {
|
||||
public void singleCandidateInAncestorsOneCandidateInGrandparent() {
|
||||
load(FooConfiguration.class);
|
||||
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
|
||||
parent.setParent(this.context);
|
||||
parent.refresh();
|
||||
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
|
||||
child.register(OnBeanSingleCandidateInParentsConfiguration.class);
|
||||
child.register(OnBeanSingleCandidateInAncestorsConfiguration.class);
|
||||
child.setParent(parent);
|
||||
child.refresh();
|
||||
assertThat(child.containsBean("baz")).isTrue();
|
||||
@@ -177,8 +177,8 @@ public class ConditionalOnSingleCandidateTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnSingleCandidate(value = String.class, search = SearchStrategy.PARENTS)
|
||||
protected static class OnBeanSingleCandidateInParentsConfiguration {
|
||||
@ConditionalOnSingleCandidate(value = String.class, search = SearchStrategy.ANCESTORS)
|
||||
protected static class OnBeanSingleCandidateInAncestorsConfiguration {
|
||||
|
||||
@Bean
|
||||
public String baz(String s) {
|
||||
|
||||
Reference in New Issue
Block a user