Author: markt Date: Sun Sep 9 21:00:38 2012 New Revision: 1382579 URL: http://svn.apache.org/viewvc?rev=1382579&view=rev Log: I'm not convinced this is desirable or even necessary but the current unit tests expect to be able to list all matching resources even though only one of them will ever be used. I would prefer to never expose the others.
Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java tomcat/sandbox/trunk-resources/java/org/apache/catalina/loader/WebappClassLoader.java tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java?rev=1382579&r1=1382578&r2=1382579&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/WebResourceRoot.java Sun Sep 9 21:00:38 2012 @@ -98,6 +98,21 @@ public interface WebResourceRoot extends WebResource getResource(String path); /** + * Obtain the object(s) that represent the resource at the given path. Note + * that the resource at that path may not exist. If the path does not + * exist, the WebResource returned will be associated with the main + * WebResourceSet. This will include all matches even if the resource would + * not normally be accessible (e.g. because it was overridden by another + * resource) + * + * @param path The path for the resource of interest relative to the root + * of the web application. It must start with '/'. + * + * @return The object that represents the resource at the given path + */ + WebResource[] getResources(String path); + + /** * Obtain the list of the names of all of the files and directories located * in the specified directory. * Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/loader/WebappClassLoader.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/loader/WebappClassLoader.java?rev=1382579&r1=1382578&r2=1382579&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/loader/WebappClassLoader.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/loader/WebappClassLoader.java Sun Sep 9 21:00:38 2012 @@ -1086,12 +1086,11 @@ public class WebappClassLoader int jarFilesLength = jarFiles.length; // Looking at the repository - try { - if (resources.getResource(repository + name).exists()) { - result.add(getURI(new File(file, name))); + WebResource[] webResources = resources.getResources(repository + name); + for (WebResource webResource : webResources) { + if (webResource.exists()) { + result.add(webResource.getURL()); } - } catch (MalformedURLException e) { - // Ignore } // Looking at the JAR files Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java?rev=1382579&r1=1382578&r2=1382579&view=diff ============================================================================== --- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java (original) +++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/StandardRoot.java Sun Sep 9 21:00:38 2012 @@ -125,6 +125,27 @@ public class StandardRoot extends Lifecy } @Override + public WebResource[] getResources(String path) { + checkState(); + + ArrayList<WebResource> result = new ArrayList<>(); + for (ArrayList<WebResourceSet> list : allResources) { + for (WebResourceSet webResourceSet : list) { + WebResource webResource = webResourceSet.getResource(path); + if (webResource.exists()) { + result.add(webResource); + } + } + } + + if (result.size() == 0) { + result.add(main.getResource(path)); + } + + return result.toArray(new WebResource[result.size()]); + } + + @Override public WebResource[] listResources(String path) { checkState(); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org