@ -18,11 +18,13 @@ package org.springframework.boot.autoconfigure;
import java.util.function.Supplier ;
import java.util.function.Supplier ;
import org.springframework.aot.AotDetector ;
import org.springframework.beans.BeansException ;
import org.springframework.beans.BeansException ;
import org.springframework.beans.MutablePropertyValues ;
import org.springframework.beans.MutablePropertyValues ;
import org.springframework.beans.factory.BeanClassLoaderAware ;
import org.springframework.beans.factory.BeanClassLoaderAware ;
import org.springframework.beans.factory.FactoryBean ;
import org.springframework.beans.factory.FactoryBean ;
import org.springframework.beans.factory.NoSuchBeanDefinitionException ;
import org.springframework.beans.factory.NoSuchBeanDefinitionException ;
import org.springframework.beans.factory.aot.BeanRegistrationExcludeFilter ;
import org.springframework.beans.factory.config.BeanDefinition ;
import org.springframework.beans.factory.config.BeanDefinition ;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor ;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor ;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory ;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory ;
@ -31,6 +33,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder ;
import org.springframework.beans.factory.support.BeanDefinitionBuilder ;
import org.springframework.beans.factory.support.BeanDefinitionRegistry ;
import org.springframework.beans.factory.support.BeanDefinitionRegistry ;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor ;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor ;
import org.springframework.beans.factory.support.RegisteredBean ;
import org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory ;
import org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory ;
import org.springframework.context.ApplicationContextInitializer ;
import org.springframework.context.ApplicationContextInitializer ;
import org.springframework.context.ApplicationListener ;
import org.springframework.context.ApplicationListener ;
@ -51,14 +54,17 @@ import org.springframework.core.type.classreading.MetadataReaderFactory;
* @author Phillip Webb
* @author Phillip Webb
* @author Dave Syer
* @author Dave Syer
* /
* /
class SharedMetadataReaderFactoryContextInitializer
class SharedMetadataReaderFactoryContextInitializer implements
implements ApplicationContextInitializer < ConfigurableApplicationContext > , Ordered {
ApplicationContextInitializer < ConfigurableApplicationContext > , Ordered , BeanRegistrationExcludeFilter {
public static final String BEAN_NAME = "org.springframework.boot.autoconfigure."
public static final String BEAN_NAME = "org.springframework.boot.autoconfigure."
+ "internalCachingMetadataReaderFactory" ;
+ "internalCachingMetadataReaderFactory" ;
@Override
@Override
public void initialize ( ConfigurableApplicationContext applicationContext ) {
public void initialize ( ConfigurableApplicationContext applicationContext ) {
if ( AotDetector . useGeneratedArtifacts ( ) ) {
return ;
}
BeanFactoryPostProcessor postProcessor = new CachingMetadataReaderFactoryPostProcessor ( applicationContext ) ;
BeanFactoryPostProcessor postProcessor = new CachingMetadataReaderFactoryPostProcessor ( applicationContext ) ;
applicationContext . addBeanFactoryPostProcessor ( postProcessor ) ;
applicationContext . addBeanFactoryPostProcessor ( postProcessor ) ;
}
}
@ -68,6 +74,11 @@ class SharedMetadataReaderFactoryContextInitializer
return 0 ;
return 0 ;
}
}
@Override
public boolean isExcludedFromAotProcessing ( RegisteredBean registeredBean ) {
return BEAN_NAME . equals ( registeredBean . getBeanName ( ) ) ;
}
/ * *
/ * *
* { @link BeanDefinitionRegistryPostProcessor } to register the
* { @link BeanDefinitionRegistryPostProcessor } to register the
* { @link CachingMetadataReaderFactory } and configure the
* { @link CachingMetadataReaderFactory } and configure the