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;
/**
- * <p>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.
+ * <p>This is a utility class to match file globs.
+ * The class has been derived from
+ * org.apache.tools.ant.types.selectors.SelectorUtils.
* </p>
- * <p>This is a Singleton.</p>
+ * <p>All methods are static.</p>
*/
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
* <code>null</code>.
@@ -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
* <code>null</code>.
@@ -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
* <code>null</code>.
@@ -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
* <code>File.separator</code>.
*
* @param path Path to tokenize. Must not be <code>null</code>.
@@ -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 @@
+<!--
+ 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.
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+$Id$
+-->
+</head>
+<body bgcolor="white">
+<p>
+This package contains utility classes for file handling.
+</p>
+</body>
+</html>
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<String[]> ignoredJarsTokens = new HashSet<String[]>();
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<String> 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: [email protected]
For additional commands, e-mail: [email protected]