Improve BeanDefinitionBuilder to handle the synthetic flag
Closes gh-27141
This commit is contained in:
parent
cf78895ba0
commit
fed1a426b6
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2019 the original author or authors.
|
* Copyright 2002-2021 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.
|
||||||
|
|
@ -331,6 +331,15 @@ public final class BeanDefinitionBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether this bean is 'synthetic', that is, not defined by
|
||||||
|
* the application itself.
|
||||||
|
*/
|
||||||
|
public BeanDefinitionBuilder setSynthetic(boolean synthetic) {
|
||||||
|
this.beanDefinition.setSynthetic(synthetic);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply the given customizers to the underlying bean definition.
|
* Apply the given customizers to the underlying bean definition.
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,12 @@ class BeanDefinitionBuilderTests {
|
||||||
.isEqualTo(BeanDefinition.ROLE_INFRASTRUCTURE);
|
.isEqualTo(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void builderWithSynthetic() {
|
||||||
|
assertThat(BeanDefinitionBuilder.rootBeanDefinition(TestBean.class)
|
||||||
|
.setSynthetic(true).getBeanDefinition().isSynthetic()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void builderWithCustomizers() {
|
void builderWithCustomizers() {
|
||||||
BeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class)
|
BeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue