Class CandidateComponentsIndexLoader
java.lang.Object
org.springframework.context.index.CandidateComponentsIndexLoader
Candidate components index loading mechanism for internal use within the framework.
- Since:
- 5.0
- Author:
- Stephane Nicoll, Juergen Hoeller
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addIndex
(ClassLoader classLoader, CandidateComponentsIndex index) Programmatically add the given index instance for the given ClassLoader, replacing a file-determined index with a programmatically composed index.static void
Clear the runtime index cache.loadIndex
(@Nullable ClassLoader classLoader) Load and instantiate theCandidateComponentsIndex
from "META-INF/spring.components", using the given class loader.
-
Field Details
-
COMPONENTS_RESOURCE_LOCATION
The location to look for components.Can be present in multiple JAR files.
- See Also:
-
IGNORE_INDEX
System property that instructs Spring to ignore the components index, i.e. to always returnnull
fromloadIndex(ClassLoader)
.The default is "false", allowing for regular use of the index. Switching this flag to
true
fulfills a corner case scenario when an index is partially available for some libraries (or use cases) but couldn't be built for the whole application. In this case, the application context fallbacks to a regular classpath arrangement (i.e. as though no index were present at all).- See Also:
-
-
Method Details
-
loadIndex
Load and instantiate theCandidateComponentsIndex
from "META-INF/spring.components", using the given class loader. If no index is available, returnnull
.- Parameters:
classLoader
- the ClassLoader to use for loading (can benull
to use the default)- Returns:
- the index to use or
null
if no index was found - Throws:
IllegalArgumentException
- if any module index cannot be loaded or if an error occurs while creatingCandidateComponentsIndex
-
addIndex
Programmatically add the given index instance for the given ClassLoader, replacing a file-determined index with a programmatically composed index.The index instance will usually be pre-populated for AOT runtime setups or test scenarios with pre-configured results for runtime-attempted scans. Alternatively, it may be empty for it to get populated during AOT processing or a test run, for subsequent introspection the index-recorded candidate types.
- Parameters:
classLoader
- the ClassLoader to add the index forindex
- the associated CandidateComponentsIndex instance- Since:
- 7.0
-
clearCache
public static void clearCache()Clear the runtime index cache.- Since:
- 7.0
-