Description
Stéphane Nicoll opened SPR-14654 and commented
While working on #16509 I noticed that caching several ClassPathScanningCandidateComponentProvider
instances are instantiated when the application context is refreshed. With Spring Boot in particular, those instances are working on the same base package(s) with different filters.
In the end we scan the same Resources
, load the same meta-data and figure out based on that if we have to include the component.
It would be much nicer if that information was cached for the duration of the refresh. Also, creating a valid ClassPathScanningCandidateComponentProvider
requires you to pass the Environment
and the ResourceLoader
. Both of those are available from ApplicationContext
. Perhaps the latter could take care of providing a shared instance or something?
Affects: 5.0 M1
Issue Links:
- Spring-specific index file for component candidate classes [SPR-11890] #16509 Spring-specific index file for component candidate classes
- Allow for CachingMetadataReaderFactory cache size to be easily updated [SPR-15278] #19844 Allow for CachingMetadataReaderFactory cache size to be easily updated
- ConfigurationClassParser does not use ApplicationContext's ResourceLoader for its MetadataReaderFactory [SPR-14684] #19248 ConfigurationClassParser does not use ApplicationContext's ResourceLoader for its MetadataReaderFactory
- Backport streamlined ClassPathBeanDefinitionScanner setup [SPR-15061] #19627 Backport streamlined ClassPathBeanDefinitionScanner setup
Referenced from: commits 7818c65