PathMatchingResourcePatternResolver consistently logs retrieval results
Issue: SPR-13923
(cherry picked from commit 449f704)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -156,9 +156,9 @@ import org.springframework.util.StringUtils;
|
||||
* classpath:com/mycompany/**/service-context.xml
|
||||
* </pre>
|
||||
* is used to try to resolve it, the resolver will work off the (first) URL
|
||||
* returned by {@code getResource("com/mycompany");}. If this base package
|
||||
* node exists in multiple classloader locations, the actual end resource may
|
||||
* not be underneath. Therefore, preferably, use "{@code classpath*:}" with the same
|
||||
* returned by {@code getResource("com/mycompany");}. If this base package node
|
||||
* exists in multiple classloader locations, the actual end resource may not be
|
||||
* underneath. Therefore, preferably, use "{@code classpath*:}" with the same
|
||||
* Ant-style pattern in such a case, which will search <i>all</i> class path
|
||||
* locations that contain the root package.
|
||||
*
|
||||
@@ -308,6 +308,9 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
path = path.substring(1);
|
||||
}
|
||||
Set<Resource> result = doFindAllClassPathResources(path);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Resolved classpath location [" + location + "] to resources " + result);
|
||||
}
|
||||
return result.toArray(new Resource[result.size()]);
|
||||
}
|
||||
|
||||
@@ -316,6 +319,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
* Called by {@link #findAllClassPathResources(String)}.
|
||||
* @param path the absolute path within the classpath (never a leading slash)
|
||||
* @return a mutable Set of matching Resource instances
|
||||
* @since 4.1.1
|
||||
*/
|
||||
protected Set<Resource> doFindAllClassPathResources(String path) throws IOException {
|
||||
Set<Resource> result = new LinkedHashSet<Resource>(16);
|
||||
@@ -350,6 +354,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
* given set of resources in the form of pointers to the root of the jar file content.
|
||||
* @param classLoader the ClassLoader to search (including its ancestors)
|
||||
* @param result the set of resources to add jar roots to
|
||||
* @since 4.1.1
|
||||
*/
|
||||
protected void addAllClassLoaderJarRoots(ClassLoader classLoader, Set<Resource> result) {
|
||||
if (classLoader instanceof URLClassLoader) {
|
||||
@@ -381,6 +386,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
||||
}
|
||||
if (classLoader != null) {
|
||||
try {
|
||||
// Hierarchy traversal...
|
||||
addAllClassLoaderJarRoots(classLoader.getParent(), result);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
Reference in New Issue
Block a user