result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern));
/** * Overridden version which checks for ServletContextResource * and uses {@code ServletContext.getResourcePaths} to find * matching resources below the web application root directory. * In case of other resources, delegates to the superclass version. * @see #doRetrieveMatchingServletContextResources * @see ServletContextResource * @see javax.servlet.ServletContext#getResourcePaths */ @Override protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { if (rootDirResource instanceof ServletContextResource) { ServletContextResource scResource = (ServletContextResource) rootDirResource; ServletContext sc = scResource.getServletContext(); String fullPattern = scResource.getPath() + subPattern; Set<Resource> result = new LinkedHashSet<>(8); doRetrieveMatchingServletContextResources(sc, fullPattern, scResource.getPath(), result); return result; } else { return super.doFindPathMatchingFileResources(rootDirResource, subPattern); } }
result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern));
/** * Overridden version which checks for ServletContextResource * and uses {@code ServletContext.getResourcePaths} to find * matching resources below the web application root directory. * In case of other resources, delegates to the superclass version. * @see #doRetrieveMatchingServletContextResources * @see ServletContextResource * @see javax.servlet.ServletContext#getResourcePaths */ @Override protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { if (rootDirResource instanceof ServletContextResource) { ServletContextResource scResource = (ServletContextResource) rootDirResource; ServletContext sc = scResource.getServletContext(); String fullPattern = scResource.getPath() + subPattern; Set<Resource> result = new LinkedHashSet<>(8); doRetrieveMatchingServletContextResources(sc, fullPattern, scResource.getPath(), result); return result; } else { return super.doFindPathMatchingFileResources(rootDirResource, subPattern); } }
result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern));
@Override @SuppressWarnings("unchecked") protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { ResourceLoadingService resourceLoadingService = getResourceLoadingService(); // 如果resource loading service不存在,或者resource不是从resource loading service取得的, // 则调用原来的装载机制来取得资源。 if (resourceLoadingService == null || !(rootDirResource instanceof ResourceAdapter)) { return super.doFindPathMatchingFileResources(rootDirResource, subPattern); } ResourceAdapter rootResource = (ResourceAdapter) rootDirResource; String path = rootResource.getPathWithinContext(); if (!path.endsWith("/")) { path += "/"; } String fullPattern = path + subPattern; Set<Resource> result = createLinkedHashSet(); findMatchingResources(resourceLoadingService, fullPattern, path, result); return result; }
@Override @SuppressWarnings("unchecked") protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { ResourceLoadingService resourceLoadingService = getResourceLoadingService(); // 如果resource loading service不存在,或者resource不是从resource loading service取得的, // 则调用原来的装载机制来取得资源。 if (resourceLoadingService == null || !(rootDirResource instanceof ResourceAdapter)) { return super.doFindPathMatchingFileResources(rootDirResource, subPattern); } ResourceAdapter rootResource = (ResourceAdapter) rootDirResource; String path = rootResource.getPathWithinContext(); if (!path.endsWith("/")) { path += "/"; } String fullPattern = path + subPattern; Set<Resource> result = createLinkedHashSet(); findMatchingResources(resourceLoadingService, fullPattern, path, result); return result; }
/** * Find all resources that match the given location pattern via the * Ant-style PathMatcher. Supports resources in jar files and zip files * and in the file system. * @param locationPattern the location pattern to match * @return the result as Resource array * @throws IOException in case of I/O errors * @see #doFindPathMatchingJarResources * @see #doFindPathMatchingFileResources * @see org.springframework.util.PathMatcher */ protected Resource[] findPathMatchingResources(String locationPattern) throws IOException { String rootDirPath = determineRootDir(locationPattern); String subPattern = locationPattern.substring(rootDirPath.length()); Resource[] rootDirResources = getResources(rootDirPath); Set result = CollectionFactory.createLinkedSetIfPossible(16); for (int i = 0; i < rootDirResources.length; i++) { Resource rootDirResource = rootDirResources[i]; if (isJarResource(rootDirResource)) { result.addAll(doFindPathMatchingJarResources(rootDirResource, subPattern)); } else { result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern)); } } if (logger.isDebugEnabled()) { logger.debug("Resolved location pattern [" + locationPattern + "] to resources " + result); } return (Resource[]) result.toArray(new Resource[result.size()]); }
return super.doFindPathMatchingFileResources(rootDirResource, subPattern);
/** * Based on the search type, uses the appropriate searching method. * * @see OsgiBundleResource#BUNDLE_URL_PREFIX * @see org.springframework.core.io.support.PathMatchingResourcePatternResolver#getResources(java.lang.String) */ private Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern, int searchType) throws IOException { String rootPath = null; if (rootDirResource instanceof OsgiBundleResource) { OsgiBundleResource bundleResource = (OsgiBundleResource) rootDirResource; rootPath = bundleResource.getPath(); searchType = bundleResource.getSearchType(); } else if (rootDirResource instanceof UrlResource) { rootPath = rootDirResource.getURL().getPath(); } if (rootPath != null) { String cleanPath = OsgiResourceUtils.stripPrefix(rootPath); // sanitize the root folder (since it's possible to not specify the root which fails any further matches) if (!cleanPath.endsWith(FOLDER_SEPARATOR)) { cleanPath = cleanPath + FOLDER_SEPARATOR; } String fullPattern = cleanPath + subPattern; Set<Resource> result = new LinkedHashSet<Resource>(); doRetrieveMatchingBundleEntries(bundle, fullPattern, cleanPath, result, searchType); return result; } else { return super.doFindPathMatchingFileResources(rootDirResource, subPattern); } }
result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern));
result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern));
/** * Overridden version which checks for PortletContextResource * and uses {@code PortletContext.getResourcePaths} to find * matching resources below the web application root directory. * In case of other resources, delegates to the superclass version. * @see #doRetrieveMatchingPortletContextResources * @see PortletContextResource * @see javax.portlet.PortletContext#getResourcePaths */ @Override protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { if (rootDirResource instanceof PortletContextResource) { PortletContextResource pcResource = (PortletContextResource) rootDirResource; PortletContext pc = pcResource.getPortletContext(); String fullPattern = pcResource.getPath() + subPattern; Set<Resource> result = new HashSet<Resource>(); doRetrieveMatchingPortletContextResources(pc, fullPattern, pcResource.getPath(), result); return result; } return super.doFindPathMatchingFileResources(rootDirResource, subPattern); }
@Override @SuppressWarnings("unchecked") protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { ResourceLoadingService resourceLoadingService = getResourceLoadingService(); // 如果resource loading service不存在,或者resource不是从resource loading service取得的, // 则调用原来的装载机制来取得资源。 if (resourceLoadingService == null || !(rootDirResource instanceof ResourceAdapter)) { return super.doFindPathMatchingFileResources(rootDirResource, subPattern); } ResourceAdapter rootResource = (ResourceAdapter) rootDirResource; String path = rootResource.getPathWithinContext(); if (!path.endsWith("/")) { path += "/"; } String fullPattern = path + subPattern; Set<Resource> result = createLinkedHashSet(); findMatchingResources(resourceLoadingService, fullPattern, path, result); return result; }
/** * Overridden version which checks for PortletContextResource * and uses <code>PortletContext.getResourcePaths</code> to find * matching resources below the web application root directory. * In case of other resources, delegates to the superclass version. * @see #doRetrieveMatchingPortletContextResources * @see org.springframework.web.portlet.context.PortletContextResource * @see javax.portlet.PortletContext#getResourcePaths */ @Override protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { if (rootDirResource instanceof PortletContextResource) { PortletContextResource pcResource = (PortletContextResource) rootDirResource; PortletContext pc = pcResource.getPortletContext(); String fullPattern = pcResource.getPath() + subPattern; Set<Resource> result = new HashSet<Resource>(); doRetrieveMatchingPortletContextResources(pc, fullPattern, pcResource.getPath(), result); return result; } return super.doFindPathMatchingFileResources(rootDirResource, subPattern); }
/** * Overridden version which checks for ServletContextResource * and uses {@code ServletContext.getResourcePaths} to find * matching resources below the web application root directory. * In case of other resources, delegates to the superclass version. * @see #doRetrieveMatchingServletContextResources * @see ServletContextResource * @see javax.servlet.ServletContext#getResourcePaths */ @Override protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { if (rootDirResource instanceof ServletContextResource) { ServletContextResource scResource = (ServletContextResource) rootDirResource; ServletContext sc = scResource.getServletContext(); String fullPattern = scResource.getPath() + subPattern; Set<Resource> result = new LinkedHashSet<>(8); doRetrieveMatchingServletContextResources(sc, fullPattern, scResource.getPath(), result); return result; } else { return super.doFindPathMatchingFileResources(rootDirResource, subPattern); } }
/** * Overridden version which checks for ServletContextResource * and uses {@code ServletContext.getResourcePaths} to find * matching resources below the web application root directory. * In case of other resources, delegates to the superclass version. * @see #doRetrieveMatchingServletContextResources * @see ServletContextResource * @see javax.servlet.ServletContext#getResourcePaths */ @Override protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { if (rootDirResource instanceof ServletContextResource) { ServletContextResource scResource = (ServletContextResource) rootDirResource; ServletContext sc = scResource.getServletContext(); String fullPattern = scResource.getPath() + subPattern; Set<Resource> result = new LinkedHashSet<>(8); doRetrieveMatchingServletContextResources(sc, fullPattern, scResource.getPath(), result); return result; } else { return super.doFindPathMatchingFileResources(rootDirResource, subPattern); } }
/** * Overridden version which checks for ServletContextResource * and uses <code>ServletContext.getResourcePaths</code> to find * matching resources below the web application root directory. * In case of other resources, delegates to the superclass version. * @see #doRetrieveMatchingServletContextResources * @see ServletContextResource * @see javax.servlet.ServletContext#getResourcePaths */ protected Set doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException { if (rootDirResource instanceof ServletContextResource) { ServletContextResource scResource = (ServletContextResource) rootDirResource; ServletContext sc = scResource.getServletContext(); if (sc.getMajorVersion() > 2 || (sc.getMajorVersion() == 2 && sc.getMinorVersion() > 2)) { // Only try the following on Servlet containers >= 2.3: // ServletContext.getResourcePaths() is not available before that version. String fullPattern = scResource.getPath() + subPattern; Set result = CollectionFactory.createLinkedSetIfPossible(8); doRetrieveMatchingServletContextResources(sc, fullPattern, scResource.getPath(), result); return result; } } return super.doFindPathMatchingFileResources(rootDirResource, subPattern); }