Change ConcurrentReferenceCachingMetadataReaderFactory to use application's resource loader

See gh-39321
This commit is contained in:
junhyung 2024-01-28 01:47:08 +09:00 committed by Moritz Halbritter
parent 03dfc3bbd1
commit 8fee77761d

View File

@ -21,7 +21,6 @@ import java.util.function.Supplier;
import org.springframework.aot.AotDetector; 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.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.aot.BeanRegistrationExcludeFilter;
@ -38,11 +37,13 @@ import org.springframework.boot.type.classreading.ConcurrentReferenceCachingMeta
import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.context.annotation.AnnotationConfigUtils; import org.springframework.context.annotation.AnnotationConfigUtils;
import org.springframework.context.annotation.ConfigurationClassPostProcessor; import org.springframework.context.annotation.ConfigurationClassPostProcessor;
import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered; import org.springframework.core.PriorityOrdered;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.classreading.CachingMetadataReaderFactory; import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.classreading.MetadataReaderFactory;
@ -187,14 +188,14 @@ class SharedMetadataReaderFactoryContextInitializer implements
* {@link FactoryBean} to create the shared {@link MetadataReaderFactory}. * {@link FactoryBean} to create the shared {@link MetadataReaderFactory}.
*/ */
static class SharedMetadataReaderFactoryBean static class SharedMetadataReaderFactoryBean
implements FactoryBean<ConcurrentReferenceCachingMetadataReaderFactory>, BeanClassLoaderAware, implements FactoryBean<ConcurrentReferenceCachingMetadataReaderFactory>, ResourceLoaderAware,
ApplicationListener<ContextRefreshedEvent> { ApplicationListener<ContextRefreshedEvent> {
private ConcurrentReferenceCachingMetadataReaderFactory metadataReaderFactory; private ConcurrentReferenceCachingMetadataReaderFactory metadataReaderFactory;
@Override @Override
public void setBeanClassLoader(ClassLoader classLoader) { public void setResourceLoader(ResourceLoader resourceLoader) {
this.metadataReaderFactory = new ConcurrentReferenceCachingMetadataReaderFactory(classLoader); this.metadataReaderFactory = new ConcurrentReferenceCachingMetadataReaderFactory(resourceLoader);
} }
@Override @Override