Skip to content

Commit b4eb895

Browse files
snicollwilkinsona
andcommitted
Polish naming
Co-authored-by: Andy Wilkinson <wilkinsona@vmware.com>
1 parent e85001f commit b4eb895

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
5757
import org.springframework.beans.factory.config.DependencyDescriptor;
5858
import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
59-
import org.springframework.beans.factory.generator.BeanInstanceAotPostProcessor;
60-
import org.springframework.beans.factory.generator.BeanInstanceContributor;
59+
import org.springframework.beans.factory.generator.AotContributingBeanPostProcessor;
60+
import org.springframework.beans.factory.generator.BeanInstantiationContributor;
6161
import org.springframework.beans.factory.generator.InjectionGenerator;
6262
import org.springframework.beans.factory.support.LookupOverride;
6363
import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor;
@@ -140,7 +140,7 @@
140140
* @see Value
141141
*/
142142
public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationAwareBeanPostProcessor,
143-
MergedBeanDefinitionPostProcessor, BeanInstanceAotPostProcessor, PriorityOrdered, BeanFactoryAware {
143+
MergedBeanDefinitionPostProcessor, AotContributingBeanPostProcessor, PriorityOrdered, BeanFactoryAware {
144144

145145
protected final Log logger = LogFactory.getLog(getClass());
146146

@@ -268,12 +268,12 @@ public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, C
268268
}
269269

270270
@Override
271-
public BeanInstanceContributor buildAotContributor(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
271+
public BeanInstantiationContributor buildAotContributor(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
272272
InjectionMetadata metadata = findInjectionMetadata(beanName, beanType, beanDefinition);
273273
Collection<InjectedElement> injectedElements = metadata.getInjectedElements();
274274
return (!ObjectUtils.isEmpty(injectedElements)
275-
? new AutowiredAnnotationBeanInstanceContributor(injectedElements)
276-
: BeanInstanceContributor.NO_OP);
275+
? new AutowiredAnnotationBeanInstantiationContributor(injectedElements)
276+
: BeanInstantiationContributor.NO_OP);
277277
}
278278

279279
private InjectionMetadata findInjectionMetadata(String beanName, Class<?> beanType, RootBeanDefinition beanDefinition) {
@@ -821,13 +821,13 @@ private Object[] resolveMethodArguments(Method method, Object bean, @Nullable St
821821
}
822822
}
823823

824-
private static final class AutowiredAnnotationBeanInstanceContributor implements BeanInstanceContributor {
824+
private static final class AutowiredAnnotationBeanInstantiationContributor implements BeanInstantiationContributor {
825825

826826
private final Collection<InjectedElement> injectedElements;
827827

828828
private final InjectionGenerator generator;
829829

830-
AutowiredAnnotationBeanInstanceContributor(Collection<InjectedElement> injectedElements) {
830+
AutowiredAnnotationBeanInstantiationContributor(Collection<InjectedElement> injectedElements) {
831831
this.injectedElements = injectedElements;
832832
this.generator = new InjectionGenerator();
833833
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import org.springframework.beans.factory.support.RootBeanDefinition;
2121

2222
/**
23-
* Strategy interface to be implemented by a {@link BeanPostProcessor} that
24-
* participates in a bean instance setup and can provide an equivalent setup
25-
* using generated code.
23+
* Specialization of {@link BeanPostProcessor} that contributes to bean
24+
* instantiation ahead of time, providing generated code that is equivalent to
25+
* its runtime behavior.
2626
*
2727
* <p>Contrary to other bean post processors, implementations of this interface
2828
* are instantiated at build-time and should not rely on other beans in the
@@ -32,15 +32,15 @@
3232
* @since 6.0
3333
*/
3434
@FunctionalInterface
35-
public interface BeanInstanceAotPostProcessor extends BeanPostProcessor {
35+
public interface AotContributingBeanPostProcessor extends BeanPostProcessor {
3636

3737
/**
38-
* Build a {@link BeanInstanceContributor} for the given bean definition.
38+
* Build a {@link BeanInstantiationContributor} for the given bean definition.
3939
* @param beanDefinition the merged bean definition for the bean
40-
* @param beanType the actual type of the managed bean instance
40+
* @param beanType the inferred type of the bean
4141
* @param beanName the name of the bean
4242
* @return the contributor to use
4343
*/
44-
BeanInstanceContributor buildAotContributor(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName);
44+
BeanInstantiationContributor buildAotContributor(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName);
4545

4646
}

spring-beans/src/main/java/org/springframework/beans/factory/generator/BeanInstanceContributor.java renamed to spring-beans/src/main/java/org/springframework/beans/factory/generator/BeanInstantiationContributor.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,20 @@
1919
import org.springframework.aot.generator.CodeContribution;
2020

2121
/**
22-
* Strategy interface to be implemented by components that participates in a
23-
* bean instance setup so that the generated code provides an equivalent
24-
* setup.
22+
* Contributor to the code that instantiates a bean following ahead of time
23+
* processing.
2524
*
2625
* @author Stephane Nicoll
2726
* @since 6.0
2827
*/
2928
@FunctionalInterface
30-
public interface BeanInstanceContributor {
29+
public interface BeanInstantiationContributor {
3130

3231
/**
33-
* A {@link BeanInstanceContributor} that does not contribute anything
32+
* A {@link BeanInstantiationContributor} that does not contribute anything
3433
* to the {@link CodeContribution}.
3534
*/
36-
BeanInstanceContributor NO_OP = contribution -> { };
35+
BeanInstantiationContributor NO_OP = contribution -> { };
3736

3837
/**
3938
* Contribute to the specified {@link CodeContribution}.

spring-beans/src/main/java/org/springframework/beans/factory/generator/DefaultBeanInstanceGenerator.java renamed to spring-beans/src/main/java/org/springframework/beans/factory/generator/DefaultBeanInstantiationGenerator.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,20 @@
3636
* Write the necessary statements to instantiate a bean.
3737
*
3838
* @author Stephane Nicoll
39+
* @see BeanInstantiationContributor
3940
*/
40-
class DefaultBeanInstanceGenerator {
41+
class DefaultBeanInstantiationGenerator {
4142

4243
private final Executable instanceCreator;
4344

44-
private final List<BeanInstanceContributor> contributors;
45+
private final List<BeanInstantiationContributor> contributors;
4546

4647
private final InjectionGenerator injectionGenerator;
4748

4849
private final Options beanInstanceOptions;
4950

5051

51-
DefaultBeanInstanceGenerator(Executable instanceCreator, List<BeanInstanceContributor> contributors) {
52+
DefaultBeanInstantiationGenerator(Executable instanceCreator, List<BeanInstantiationContributor> contributors) {
5253
this.instanceCreator = instanceCreator;
5354
this.contributors = List.copyOf(contributors);
5455
this.injectionGenerator = new InjectionGenerator();
@@ -62,7 +63,7 @@ class DefaultBeanInstanceGenerator {
6263
* @param runtimeHints the runtime hints instance to use
6364
* @return a code contribution that provides an initialized bean instance
6465
*/
65-
public CodeContribution generateBeanInstance(RuntimeHints runtimeHints) {
66+
public CodeContribution generateBeanInstantiation(RuntimeHints runtimeHints) {
6667
DefaultCodeContribution contribution = new DefaultCodeContribution(runtimeHints);
6768
contribution.protectedAccess().analyze(this.instanceCreator, this.beanInstanceOptions);
6869
if (this.instanceCreator instanceof Constructor<?> constructor) {
@@ -109,7 +110,7 @@ private void writeBeanInstantiation(CodeContribution contribution, Constructor<?
109110
contribution.statements().addStatement(code.build());
110111

111112
if (multiStatements) {
112-
for (BeanInstanceContributor contributor : this.contributors) {
113+
for (BeanInstantiationContributor contributor : this.contributors) {
113114
contributor.contribute(contribution);
114115
}
115116
contribution.statements().addStatement("return bean")
@@ -147,7 +148,7 @@ private void writeBeanInstantiation(CodeContribution contribution, Method method
147148
code.add(this.injectionGenerator.writeInstantiation(method));
148149
contribution.statements().addStatement(code.build());
149150
if (multiStatements) {
150-
for (BeanInstanceContributor contributor : this.contributors) {
151+
for (BeanInstantiationContributor contributor : this.contributors) {
151152
contributor.contribute(contribution);
152153
}
153154
contribution.statements().addStatement("return bean")
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.springframework.aot.hint.RuntimeHints;
2525
import org.springframework.aot.hint.TypeReference;
2626
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorTests.ResourceInjectionBean;
27-
import org.springframework.beans.factory.generator.BeanInstanceContributor;
27+
import org.springframework.beans.factory.generator.BeanInstantiationContributor;
2828
import org.springframework.beans.factory.support.RootBeanDefinition;
2929
import org.springframework.beans.testfixture.beans.TestBean;
3030
import org.springframework.core.env.Environment;
@@ -37,7 +37,7 @@
3737
*
3838
* @author Stephane Nicoll
3939
*/
40-
class AutowiredAnnotationBeanInstanceContributorTests {
40+
class AutowiredAnnotationBeanInstantiationContributorTests {
4141

4242
@Test
4343
void buildAotContributorWithPackageProtectedFieldInjection() {
@@ -63,7 +63,7 @@ void buildAotContributorWithPrivateFieldInjection() {
6363
assertThat(CodeSnippet.process(contribution.statements().toCodeBlock())).isEqualTo("""
6464
instanceContext.field("environment", Environment.class)
6565
.invoke(beanFactory, (attributes) -> {
66-
Field environmentField = ReflectionUtils.findField(AutowiredAnnotationBeanInstanceContributorTests.PrivateFieldInjectionSample.class, "environment", Environment.class);
66+
Field environmentField = ReflectionUtils.findField(AutowiredAnnotationBeanInstantiationContributorTests.PrivateFieldInjectionSample.class, "environment", Environment.class);
6767
ReflectionUtils.makeAccessible(environmentField);
6868
ReflectionUtils.setField(environmentField, bean, attributes.get(0));
6969
})""");
@@ -117,19 +117,19 @@ void buildAotContributorWithInjectionPoints() {
117117

118118
@Test
119119
void buildAotContributorWithoutInjectionPoints() {
120-
BeanInstanceContributor contributor = createAotContributor(String.class);
121-
assertThat(contributor).isNotNull().isSameAs(BeanInstanceContributor.NO_OP);
120+
BeanInstantiationContributor contributor = createAotContributor(String.class);
121+
assertThat(contributor).isNotNull().isSameAs(BeanInstantiationContributor.NO_OP);
122122
}
123123

124124
private DefaultCodeContribution contribute(Class<?> type) {
125-
BeanInstanceContributor contributor = createAotContributor(type);
125+
BeanInstantiationContributor contributor = createAotContributor(type);
126126
assertThat(contributor).isNotNull();
127127
DefaultCodeContribution contribution = new DefaultCodeContribution(new RuntimeHints());
128128
contributor.contribute(contribution);
129129
return contribution;
130130
}
131131

132-
private BeanInstanceContributor createAotContributor(Class<?> type) {
132+
private BeanInstantiationContributor createAotContributor(Class<?> type) {
133133
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
134134
RootBeanDefinition beanDefinition = new RootBeanDefinition(type);
135135
return bpp.buildAotContributor(beanDefinition, type, "test");
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
import static org.assertj.core.api.Assertions.assertThat;
4949

5050
/**
51-
* Tests for {@link DefaultBeanInstanceGenerator}.
51+
* Tests for {@link DefaultBeanInstantiationGenerator}.
5252
*
5353
* @author Stephane Nicoll
5454
*/
55-
class DefaultBeanInstanceGeneratorTests {
55+
class DefaultBeanInstantiationGeneratorTests {
5656

5757
@Test
5858
void generateUsingDefaultConstructorUsesMethodReference() {
@@ -109,7 +109,7 @@ void generateUsingConstructorOfTypeWithGeneric() {
109109
void generateUsingNoArgConstructorAndContributorsDoesNotUseMethodReference() {
110110
CodeContribution contribution = generate(SimpleConfiguration.class.getDeclaredConstructors()[0],
111111
contrib -> contrib.statements().add(CodeBlock.of("// hello\n")),
112-
BeanInstanceContributor.NO_OP);
112+
BeanInstantiationContributor.NO_OP);
113113
assertThat(code(contribution)).isEqualTo("""
114114
(instanceContext) -> {
115115
SimpleConfiguration bean = new SimpleConfiguration();
@@ -240,10 +240,10 @@ private Consumer<ExecutableHint> match(Executable executable, String name, Execu
240240
}
241241

242242
private CodeContribution generate(Executable executable,
243-
BeanInstanceContributor... beanInstanceContributors) {
244-
DefaultBeanInstanceGenerator generator = new DefaultBeanInstanceGenerator(executable,
245-
Arrays.asList(beanInstanceContributors));
246-
return generator.generateBeanInstance(new RuntimeHints());
243+
BeanInstantiationContributor... beanInstantiationContributors) {
244+
DefaultBeanInstantiationGenerator generator = new DefaultBeanInstantiationGenerator(executable,
245+
Arrays.asList(beanInstantiationContributors));
246+
return generator.generateBeanInstantiation(new RuntimeHints());
247247
}
248248

249249
private static Method method(Class<?> type, String methodName, Class<?>... parameterTypes) {

0 commit comments

Comments
 (0)