Exclude bean definition from AOT processing using an attribute
This commits allows a particular bean definition to be excluded from AOT processing using an attribute. If BeanRegistrationAotProcessor#IGNORE_REGISTRATION_ATTRIBUTE is set to `true`, then the bean definition is excluded. This complement the existing BeanRegistrationExcludeFilter capability. Closes gh-33243
This commit is contained in:
@@ -133,6 +133,10 @@ class BeanDefinitionMethodGeneratorFactory {
|
||||
}
|
||||
|
||||
private boolean isImplicitlyExcluded(RegisteredBean registeredBean) {
|
||||
if (Boolean.TRUE.equals(registeredBean.getMergedBeanDefinition()
|
||||
.getAttribute(BeanRegistrationAotProcessor.IGNORE_REGISTRATION_ATTRIBUTE))) {
|
||||
return true;
|
||||
}
|
||||
Class<?> beanClass = registeredBean.getBeanClass();
|
||||
if (BeanFactoryInitializationAotProcessor.class.isAssignableFrom(beanClass)) {
|
||||
return true;
|
||||
|
||||
@@ -49,6 +49,15 @@ import org.springframework.lang.Nullable;
|
||||
@FunctionalInterface
|
||||
public interface BeanRegistrationAotProcessor {
|
||||
|
||||
/**
|
||||
* The name of an attribute that can be
|
||||
* {@link org.springframework.core.AttributeAccessor#setAttribute set} on a
|
||||
* {@link org.springframework.beans.factory.config.BeanDefinition} to signal
|
||||
* that its registration should not be processed.
|
||||
* @since 6.2
|
||||
*/
|
||||
String IGNORE_REGISTRATION_ATTRIBUTE = "aotProcessingIgnoreRegistration";
|
||||
|
||||
/**
|
||||
* Process the given {@link RegisteredBean} instance ahead-of-time and
|
||||
* return a contribution or {@code null}.
|
||||
|
||||
Reference in New Issue
Block a user