Don't use BeanRegistrationExcludeFilter as an exclude signal
Closes gh-28833
This commit is contained in:
parent
472c23455a
commit
e928943d1a
|
|
@ -111,11 +111,14 @@ class BeanDefinitionMethodGeneratorFactory {
|
||||||
|
|
||||||
private boolean isImplicitlyExcluded(RegisteredBean registeredBean) {
|
private boolean isImplicitlyExcluded(RegisteredBean registeredBean) {
|
||||||
Class<?> beanClass = registeredBean.getBeanClass();
|
Class<?> beanClass = registeredBean.getBeanClass();
|
||||||
if (BeanRegistrationExcludeFilter.class.isAssignableFrom(beanClass)) {
|
if (BeanFactoryInitializationAotProcessor.class.isAssignableFrom(beanClass)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
return BeanFactoryInitializationAotProcessor.class.isAssignableFrom(beanClass)
|
if (BeanRegistrationAotProcessor.class.isAssignableFrom(beanClass)) {
|
||||||
|| BeanRegistrationAotProcessor.class.isAssignableFrom(beanClass);
|
BeanRegistrationAotProcessor processor = this.aotProcessors.findByBeanName(registeredBean.getBeanName());
|
||||||
|
return (processor == null) || processor.isBeanExcludedFromAotProcessing();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<BeanRegistrationAotContribution> getAotContributions(
|
private List<BeanRegistrationAotContribution> getAotContributions(
|
||||||
|
|
|
||||||
|
|
@ -47,4 +47,16 @@ public interface BeanRegistrationAotProcessor {
|
||||||
@Nullable
|
@Nullable
|
||||||
BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean);
|
BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return if the bean instance associated with this processor should be
|
||||||
|
* excluded from AOT processing itself. By default this method will return
|
||||||
|
* {@code true} to automatically exclude the bean, if the definition should
|
||||||
|
* be written then this method may be overridden to return {@code true}.
|
||||||
|
* @return if the bean should be excluded from AOT processing
|
||||||
|
* @see BeanRegistrationExcludeFilter
|
||||||
|
*/
|
||||||
|
default boolean isBeanExcludedFromAotProcessing() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,11 +127,11 @@ class BeanDefinitionMethodGeneratorFactoryTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getBeanDefinitionMethodGeneratorWhenRegisteredBeanIsAotProcessorAndFiltersBeanBeanRegistrationExcludeFilterDoesNotFilterBean() {
|
void getBeanDefinitionMethodGeneratorWhenRegisteredBeanIsAotProcessorAndIsNotExcludedAndBeanRegistrationExcludeFilterDoesNotFilterBean() {
|
||||||
MockSpringFactoriesLoader springFactoriesLoader = new MockSpringFactoriesLoader();
|
MockSpringFactoriesLoader springFactoriesLoader = new MockSpringFactoriesLoader();
|
||||||
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||||
beanFactory.registerBeanDefinition("test", BeanDefinitionBuilder
|
beanFactory.registerBeanDefinition("test", BeanDefinitionBuilder
|
||||||
.rootBeanDefinition(TestBeanRegistrationAotProcessorAndFilterBean.class).getBeanDefinition());
|
.rootBeanDefinition(TestBeanRegistrationAotProcessorAndNotExcluded.class).getBeanDefinition());
|
||||||
RegisteredBean registeredBean1 = RegisteredBean.of(beanFactory, "test");
|
RegisteredBean registeredBean1 = RegisteredBean.of(beanFactory, "test");
|
||||||
BeanDefinitionMethodGeneratorFactory methodGeneratorFactory = new BeanDefinitionMethodGeneratorFactory(
|
BeanDefinitionMethodGeneratorFactory methodGeneratorFactory = new BeanDefinitionMethodGeneratorFactory(
|
||||||
AotServices.factoriesAndBeans(springFactoriesLoader, beanFactory));
|
AotServices.factoriesAndBeans(springFactoriesLoader, beanFactory));
|
||||||
|
|
@ -197,12 +197,11 @@ class BeanDefinitionMethodGeneratorFactoryTests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TestBeanRegistrationAotProcessorAndFilterBean
|
static class TestBeanRegistrationAotProcessorAndNotExcluded
|
||||||
extends TestBeanRegistrationAotProcessorBean
|
extends TestBeanRegistrationAotProcessorBean {
|
||||||
implements BeanRegistrationExcludeFilter {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExcluded(RegisteredBean registeredBean) {
|
public boolean isBeanExcludedFromAotProcessing() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue