Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 88782 invoked from network); 3 Aug 2010 19:40:57 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Aug 2010 19:40:57 -0000 Received: (qmail 14606 invoked by uid 500); 3 Aug 2010 19:40:57 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 14339 invoked by uid 500); 3 Aug 2010 19:40:56 -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 14324 invoked by uid 99); 3 Aug 2010 19:40:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Aug 2010 19:40:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Tue, 03 Aug 2010 19:40:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7E5B623889D5; Tue, 3 Aug 2010 19:39:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r982013 - in /tomcat/trunk/java/org/apache/tomcat/util: file/Constants.java file/LocalStrings.properties file/Matcher.java file/package.html scan/LocalStrings.properties scan/StandardJarScanner.java Date: Tue, 03 Aug 2010 19:39:38 -0000 To: dev@tomcat.apache.org From: rjung@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100803193938.7E5B623889D5@eris.apache.org> Author: rjung Date: Tue Aug 3 19:39:38 2010 New Revision: 982013 URL: http://svn.apache.org/viewvc?rev=982013&view=rev Log: - clean up Javadoc of new class - localize log messages - remove unused imports and members Added: tomcat/trunk/java/org/apache/tomcat/util/file/Constants.java (with props) tomcat/trunk/java/org/apache/tomcat/util/file/LocalStrings.properties (with props) tomcat/trunk/java/org/apache/tomcat/util/file/package.html (with props) Modified: tomcat/trunk/java/org/apache/tomcat/util/file/Matcher.java tomcat/trunk/java/org/apache/tomcat/util/scan/LocalStrings.properties tomcat/trunk/java/org/apache/tomcat/util/scan/StandardJarScanner.java Added: tomcat/trunk/java/org/apache/tomcat/util/file/Constants.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/file/Constants.java?rev=982013&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/file/Constants.java (added) +++ tomcat/trunk/java/org/apache/tomcat/util/file/Constants.java Tue Aug 3 19:39:38 2010 @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.tomcat.util.file; + +/** + * String constants for the file package. + */ +public final class Constants { + + public static final String Package = "org.apache.tomcat.util.file"; + +} Propchange: tomcat/trunk/java/org/apache/tomcat/util/file/Constants.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/trunk/java/org/apache/tomcat/util/file/Constants.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: tomcat/trunk/java/org/apache/tomcat/util/file/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/file/LocalStrings.properties?rev=982013&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/file/LocalStrings.properties (added) +++ tomcat/trunk/java/org/apache/tomcat/util/file/LocalStrings.properties Tue Aug 3 19:39:38 2010 @@ -0,0 +1,16 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +matcher.tokenize=Tokenizing path [{0}] Propchange: tomcat/trunk/java/org/apache/tomcat/util/file/LocalStrings.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/trunk/java/org/apache/tomcat/util/file/LocalStrings.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: tomcat/trunk/java/org/apache/tomcat/util/file/Matcher.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/file/Matcher.java?rev=982013&r1=982012&r2=982013&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/file/Matcher.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/file/Matcher.java Tue Aug 3 19:39:38 2010 @@ -21,16 +21,17 @@ package org.apache.tomcat.util.file; import java.io.File; import java.util.Locale; import java.util.Set; -import java.util.StringTokenizer; -import java.util.Vector; + +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; +import org.apache.tomcat.util.res.StringManager; /** - *

This is a utility class used by selectors and DirectoryScanner. The - * functionality more properly belongs just to selectors, but unfortunately - * DirectoryScanner exposed these as protected methods. Thus we have to - * support any subclasses of DirectoryScanner that may access these methods. + *

This is a utility class to match file globs. + * The class has been derived from + * org.apache.tools.ant.types.selectors.SelectorUtils. *

- *

This is a Singleton.

+ *

All methods are static.

*/ public final class Matcher { @@ -39,7 +40,6 @@ public final class Matcher { */ public static final String DEEP_TREE_MATCH = "**"; - private static final Matcher instance = new Matcher(); private static final String OS_NAME = System.getProperty("os.name").toLowerCase(Locale.ENGLISH); private static final String PATH_SEP = @@ -48,26 +48,20 @@ public final class Matcher { private static final boolean ON_DOS = isDos(); /** - * Private Constructor + * The string resources for this package. */ - private Matcher() { - } + private static final StringManager sm = + StringManager.getManager(Constants.Package); - /** - * Retrieves the instance of the Singleton. - * @return singleton instance - */ - public static Matcher getInstance() { - return instance; - } + private static final Log log = LogFactory.getLog(Matcher.class); /** * Tests whether or not a given path matches any pattern in the given set. * * If you need to call this method multiple times with the same - * pattern you should rather use TokenizedPath + * pattern you should rather pre parse the pattern using tokenizePathAsArray. * - * @see TokenizedPath + * @see #tokenizePathAsArray * * @param patternSet The pattern set to match against. Must not be * null. @@ -91,9 +85,9 @@ public final class Matcher { * Tests whether or not a given path matches a given pattern. * * If you need to call this method multiple times with the same - * pattern you should rather use TokenizedPath + * pattern you should rather pre parse the pattern using tokenizePathAsArray. * - * @see TokenizedPath + * @see #tokenizePathAsArray * * @param pattern The pattern to match against. Must not be * null. @@ -112,9 +106,9 @@ public final class Matcher { * Tests whether or not a given path matches a given pattern. * * If you need to call this method multiple times with the same - * pattern you should rather use TokenizedPattern + * pattern you should rather pre parse the pattern using tokenizePathAsArray. * - * @see TokenizedPattern + * @see #tokenizePathAsArray * * @param pattern The pattern to match against. Must not be * null. @@ -133,10 +127,9 @@ public final class Matcher { } /** - * Core implementation of matchPath. It is isolated so that it - * can be called from TokenizedPattern. + * Core implementation of matchPath using an already tokenized pattern. */ - static boolean matchPath(String[] tokenizedPattern, String[] strDirs, + public static boolean matchPath(String[] tokenizedPattern, String[] strDirs, boolean isCaseSensitive) { int patIdxStart = 0; int patIdxEnd = tokenizedPattern.length - 1; @@ -420,7 +413,7 @@ public final class Matcher { } /** - * Breaks a path up into a Vector of path elements, tokenizing on + * Breaks a path up into a array of path elements, tokenizing on * File.separator. * * @param path Path to tokenize. Must not be null. @@ -428,6 +421,9 @@ public final class Matcher { * @return a String array of path elements from the tokenized path */ public static String[] tokenizePathAsArray(String path) { + if (log.isTraceEnabled()) { + log.trace(sm.getString("matcher.tokenize", path)); + } String root = null; if (isAbsolutePath(path)) { String[] s = dissect(path); Added: tomcat/trunk/java/org/apache/tomcat/util/file/package.html URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/file/package.html?rev=982013&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/file/package.html (added) +++ tomcat/trunk/java/org/apache/tomcat/util/file/package.html Tue Aug 3 19:39:38 2010 @@ -0,0 +1,29 @@ + + + + + + + +

+This package contains utility classes for file handling. +

+ + Propchange: tomcat/trunk/java/org/apache/tomcat/util/file/package.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: tomcat/trunk/java/org/apache/tomcat/util/file/package.html ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: tomcat/trunk/java/org/apache/tomcat/util/scan/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/scan/LocalStrings.properties?rev=982013&r1=982012&r2=982013&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/scan/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/tomcat/util/scan/LocalStrings.properties Tue Aug 3 19:39:38 2010 @@ -15,6 +15,10 @@ jarScan.classloaderFail=Failed to scan [{0}] from classloader hierarchy jarScan.classloaderStart=Scanning for JARs in classloader hierarchy +jarScan.classloaderJarScan=Scanning JAR [{0}] from classpath +jarScan.classloaderJarNoScan=Not scanning JAR [{0}] from classpath jarScan.jarUrlStart=Scanning JAR at URL [{0}] jarScan.webinflibFail=Failed to scan JAR [{0}] from WEB-INF/lib jarScan.webinflibStart=Scanning WEB-INF/lib for JARs +jarScan.webinflibJarScan=Scanning JAR [{0}] from WEB-INF/lib +jarScan.webinflibJarNoScan=Not scanning JAR [{0}] from WEB-INF/lib Modified: tomcat/trunk/java/org/apache/tomcat/util/scan/StandardJarScanner.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/scan/StandardJarScanner.java?rev=982013&r1=982012&r2=982013&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/scan/StandardJarScanner.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/scan/StandardJarScanner.java Tue Aug 3 19:39:38 2010 @@ -137,9 +137,6 @@ public class StandardJarScanner implemen } Set ignoredJarsTokens = new HashSet(); for (String pattern: ignoredJars) { - if (log.isDebugEnabled()) { - log.debug("Tokenizing " + pattern); - } ignoredJarsTokens.add(Matcher.tokenizePathAsArray(pattern)); } @@ -149,15 +146,12 @@ public class StandardJarScanner implemen Iterator it = dirList.iterator(); while (it.hasNext()) { String path = it.next(); - if (log.isDebugEnabled()) { - log.debug("Matching path '" + path + "'"); - } if (path.endsWith(Constants.JAR_EXT) && - !Matcher.matchPath(ignoredJarsTokens, - path.substring(path.lastIndexOf('/')+1))) { + !Matcher.matchPath(ignoredJarsTokens, + path.substring(path.lastIndexOf('/')+1))) { // Need to scan this JAR if (log.isDebugEnabled()) { - log.debug("Scanning jar " + path); + log.debug(sm.getString("jarScan.webinflibJarScan", path)); } URL url = null; try { @@ -167,8 +161,8 @@ public class StandardJarScanner implemen log.warn(sm.getString("jarScan.webinflibFail", url), e); } } else { - if (log.isDebugEnabled()) { - log.debug("Didn't scan jar " + path); + if (log.isTraceEnabled()) { + log.trace(sm.getString("jarScan.webinflibJarNoScan", path)); } } } @@ -192,15 +186,12 @@ public class StandardJarScanner implemen // Skip JARs with known not to be interesting and JARs // in WEB-INF/lib we have already scanned - if (log.isDebugEnabled()) { - log.debug("Matching jar '" + jarName + "'"); - } if (jarName != null && !(Matcher.matchPath(ignoredJarsTokens, jarName) || urls[i].toString().contains( Constants.WEB_INF_LIB + jarName))) { if (log.isDebugEnabled()) { - log.debug("Scanning jar " + jarName); + log.debug(sm.getString("jarScan.classloaderJarScan", jarName)); } try { process(callback, urls[i]); @@ -209,8 +200,8 @@ public class StandardJarScanner implemen "jarScan.classloaderFail",urls[i]), ioe); } } else { - if (log.isDebugEnabled()) { - log.debug("Didn't scan jar " + jarName); + if (log.isTraceEnabled()) { + log.trace(sm.getString("jarScan.classloaderJarNoScan", jarName)); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org