Add AotServices class to replace AotFactoriesLoader

Add an `AotServices` class to replace `AotFactoriesLoader`. The
replacement class allow instances to be loaded from just the
`aot.factories` file if required. It also retains a link to the bean
names so that a `findByBeanName(...)` method can be provided.

See gh-28833
This commit is contained in:
Phillip Webb
2022-07-27 14:46:49 +01:00
parent 498668fc57
commit 472c23455a
14 changed files with 451 additions and 227 deletions

View File

@@ -29,7 +29,7 @@ import org.springframework.aot.generate.MethodReference;
import org.springframework.aot.test.generator.compile.Compiled;
import org.springframework.aot.test.generator.compile.TestCompiler;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.aot.AotFactoriesLoader;
import org.springframework.beans.factory.aot.AotServices;
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution;
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
import org.springframework.beans.factory.aot.TestBeanRegistrationsAotProcessor;
@@ -77,7 +77,7 @@ class ScopedProxyBeanRegistrationAotProcessorTests {
@Test
void scopedProxyBeanRegistrationAotProcessorIsRegistered() {
assertThat(new AotFactoriesLoader(this.beanFactory).load(BeanRegistrationAotProcessor.class))
assertThat(AotServices.factoriesAndBeans(this.beanFactory).load(BeanRegistrationAotProcessor.class))
.anyMatch(ScopedProxyBeanRegistrationAotProcessor.class::isInstance);
}