Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B2BE0D100 for ; Sun, 9 Sep 2012 21:01:26 +0000 (UTC) Received: (qmail 97311 invoked by uid 500); 9 Sep 2012 21:01:26 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 97241 invoked by uid 500); 9 Sep 2012 21:01:25 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 97229 invoked by uid 99); 9 Sep 2012 21:01:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Sep 2012 21:01:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Sep 2012 21:01:23 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1DA6B2388A6E for ; Sun, 9 Sep 2012 21:00:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1382579 - in /tomcat/sandbox/trunk-resources/java/org/apache/catalina: WebResourceRoot.java loader/WebappClassLoader.java webresources/StandardRoot.java Date: Sun, 09 Sep 2012 21:00:38 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120909210039.1DA6B2388A6E@eris.apache.org> 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 result = new ArrayList<>(); + for (ArrayList 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-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org