Interface ClassPathResourceLoader
- All Superinterfaces:
ResourceLoader
- All Known Implementing Classes:
ClassClassPathResourceLoader, ClassLoaderClassPathResourceLoader, CombinedClassPathResourceLoader, DefaultClassPathResourceLoader
Abstraction to load resources from the classpath.
- Since:
- 1.0
- Author:
- James Kleeh, Graeme Rocher
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClassPathResourceLoaderdefaultLoader(@Nullable ClassLoader classLoader) Return the defaultClassPathResourceLoaderfor the given class loader.Returns the underlying classloader used by thisClassPathResourceLoader.default voidhandleResourceDuplicates(String resourceName, URL chosen, List<URL> duplicates) Hook to handle duplicate resources forResourceLoadStrategyType.FIRST_MATCH.listUniqueResources(ResourceLoader resourceLoader, String name) List resources for the given name, handling duplicate URLs and implementations that may returnnull.resolveResources(ResourceLoader resourceLoader, String name, ResourceLoadStrategy strategy) Resolve resources for the given name, applying the configured strategy.default booleansupportsPrefix(String path) Methods inherited from interface ResourceLoader
forBase, getResource, getResourceAsStream, getResources, reportResourceDuplicates
-
Method Details
-
handleResourceDuplicates
Hook to handle duplicate resources forResourceLoadStrategyType.FIRST_MATCH. Default implementation is a no-op.- Parameters:
resourceName- The resource namechosen- The chosen resource URLduplicates- The duplicate resource URLs- Since:
- 5.0.0
-
getClassLoader
ClassLoader getClassLoader()Returns the underlying classloader used by thisClassPathResourceLoader.- Returns:
- The underlying classloader used by this
ClassPathResourceLoader
-
supportsPrefix
- Specified by:
supportsPrefixin interfaceResourceLoader- Parameters:
path- The path to a resource including a prefix appended by a colon. Ex (classpath:, file:)- Returns:
- Whether the given resource loader supports the prefix
-
defaultLoader
Return the defaultClassPathResourceLoaderfor the given class loader.- Parameters:
classLoader- The classloader- Returns:
- The default loader
-
listUniqueResources
List resources for the given name, handling duplicate URLs and implementations that may returnnull.- Parameters:
resourceLoader- The resource loadername- The resource name- Returns:
- An immutable list of unique URLs in encounter order
- Since:
- 5.0.0
-
resolveResources
static List<URL> resolveResources(ResourceLoader resourceLoader, String name, ResourceLoadStrategy strategy) Resolve resources for the given name, applying the configured strategy.- Parameters:
resourceLoader- The resource loadername- The resource namestrategy- The strategy- Returns:
- An immutable list of unique URLs in encounter order
- Throws:
ResourceDuplicateException- If multiple resources are found and the configured strategy isResourceLoadStrategyType.FAIL_ON_DUPLICATEResourceConflictException- If multiple resources are found and the configured strategy isResourceLoadStrategyType.MERGE_ALL- Since:
- 5.0.0
-