提交 1947de33 编写于 作者: P Phillip Webb

Provide subclass hooks in path matching resolver

Update PathMatchingResourcePatternResolver to include additional
protected methods that can be used by subclasses to optimize which
JARs are searched.

Issue: SPR-12231
上级 4aa97f89
......@@ -35,7 +35,6 @@ import java.util.jar.JarFile;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
......@@ -317,9 +316,19 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
// We need to have pointers to each of the jar files on the classpath as well...
addAllClassLoaderJarRoots(cl, result);
}
postProcessFindAllClassPathResourcesResult(location, result);
return result.toArray(new Resource[result.size()]);
}
/**
* Subclass hook allowing for post processing of a
* {@link #findAllClassPathResources(String) findAllClassPathResources} result.
* @param location the absolute path within the classpath
* @param result a mutable set of the results which can be post processed
*/
protected void postProcessFindAllClassPathResourcesResult(String location, Set<Resource> result) {
}
/**
* Convert the given URL as returned from the ClassLoader into a {@link Resource}.
* <p>The default implementation simply creates a {@link UrlResource} instance.
......@@ -338,7 +347,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
* @param classLoader the ClassLoader to search (including its ancestors)
* @param result the set of resources to add jar roots to
*/
private void addAllClassLoaderJarRoots(ClassLoader classLoader, Set<Resource> result) {
protected void addAllClassLoaderJarRoots(ClassLoader classLoader, Set<Resource> result) {
if (classLoader instanceof URLClassLoader) {
try {
for (URL url : ((URLClassLoader) classLoader).getURLs()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册