This commit is contained in:
Stephane Nicoll 2022-07-28 16:32:51 +02:00
parent 24fafc2fb7
commit 8e7faab4f6
4 changed files with 7 additions and 3 deletions

View File

@ -192,6 +192,7 @@ public final class AotServices<T> implements Iterable<T> {
private final SpringFactoriesLoader springFactoriesLoader; private final SpringFactoriesLoader springFactoriesLoader;
@Nullable
private final ListableBeanFactory beanFactory; private final ListableBeanFactory beanFactory;
@ -208,7 +209,7 @@ public final class AotServices<T> implements Iterable<T> {
* @return a new {@link AotServices} instance * @return a new {@link AotServices} instance
*/ */
public <T> AotServices<T> load(Class<T> type) { public <T> AotServices<T> load(Class<T> type) {
return new AotServices<T>(this.springFactoriesLoader.load(type), loadBeans(type)); return new AotServices<>(this.springFactoriesLoader.load(type), loadBeans(type));
} }
private <T> Map<String, T> loadBeans(Class<T> type) { private <T> Map<String, T> loadBeans(Class<T> type) {

View File

@ -60,7 +60,7 @@ public interface BeanRegistrationAotProcessor {
/** /**
* Return if the bean instance associated with this processor should be * Return if the bean instance associated with this processor should be
* excluded from AOT processing itself. By default this method will return * excluded from AOT processing itself. By default, this method returns
* {@code true} to automatically exclude the bean, if the definition should * {@code true} to automatically exclude the bean, if the definition should
* be written then this method may be overridden to return {@code true}. * be written then this method may be overridden to return {@code true}.
* @return if the bean should be excluded from AOT processing * @return if the bean should be excluded from AOT processing

View File

@ -24,6 +24,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RegisteredBean; import org.springframework.beans.factory.support.RegisteredBean;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.mock.MockSpringFactoriesLoader; import org.springframework.core.mock.MockSpringFactoriesLoader;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
@ -172,6 +173,7 @@ class BeanDefinitionMethodGeneratorFactoryTests {
private final int order; private final int order;
@Nullable
private RegisteredBean registeredBean; private RegisteredBean registeredBean;
MockBeanRegistrationExcludeFilter(boolean excluded, int order) { MockBeanRegistrationExcludeFilter(boolean excluded, int order) {
@ -234,6 +236,7 @@ class BeanDefinitionMethodGeneratorFactoryTests {
} }
@SuppressWarnings("unused")
static class InnerTestBean { static class InnerTestBean {
} }

View File

@ -75,7 +75,7 @@ class BeanDefinitionMethodGeneratorTests {
this.generationContext = new TestGenerationContext(); this.generationContext = new TestGenerationContext();
this.beanFactory = new DefaultListableBeanFactory(); this.beanFactory = new DefaultListableBeanFactory();
this.methodGeneratorFactory = new BeanDefinitionMethodGeneratorFactory( this.methodGeneratorFactory = new BeanDefinitionMethodGeneratorFactory(
AotServices.factoriesAndBeans( new MockSpringFactoriesLoader(), beanFactory)); AotServices.factoriesAndBeans(new MockSpringFactoriesLoader(), this.beanFactory));
this.beanRegistrationsCode = new MockBeanRegistrationsCode(this.generationContext); this.beanRegistrationsCode = new MockBeanRegistrationsCode(this.generationContext);
} }