Skip to content

Commit

Permalink
Improve BeanDefinitionBuilder to handle the synthetic flag
Browse files Browse the repository at this point in the history
Closes gh-27141
  • Loading branch information
snicoll committed Jul 7, 2021
1 parent cf78895 commit fed1a42
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
@@ -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");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -331,6 +331,15 @@ public BeanDefinitionBuilder setRole(int role) {
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.
* @since 5.0
Expand Down
Expand Up @@ -110,6 +110,12 @@ void builderWithRole() {
.isEqualTo(BeanDefinition.ROLE_INFRASTRUCTURE);
}

@Test
void builderWithSynthetic() {
assertThat(BeanDefinitionBuilder.rootBeanDefinition(TestBean.class)
.setSynthetic(true).getBeanDefinition().isSynthetic()).isTrue();
}

@Test
void builderWithCustomizers() {
BeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class)
Expand Down

0 comments on commit fed1a42

Please sign in to comment.