From: markt Date: Thu, 24 Dec 2009 11:14:46 +0000 (+0000) Subject: Move JAR scanning into a new JAR used by both Catalina and Jasper X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9a94c47e87aad9c383191632443d7e06d8d802d9;p=tomcat7.0 Move JAR scanning into a new JAR used by both Catalina and Jasper git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@893731 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/build.xml b/build.xml index 53e587cf3..fb80562dc 100644 --- a/build.xml +++ b/build.xml @@ -84,6 +84,7 @@ + @@ -228,7 +229,11 @@ - + + + + + @@ -261,6 +266,8 @@ + + @@ -399,6 +406,11 @@ filesDir="${tomcat.classes}" filesId="files.tomcat-api" /> + + + Context interface. Each diff --git a/java/org/apache/catalina/startup/DefaultJarScanner.java b/java/org/apache/catalina/startup/DefaultJarScanner.java deleted file mode 100644 index 331eee536..000000000 --- a/java/org/apache/catalina/startup/DefaultJarScanner.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * 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.catalina.startup; - -import java.io.File; -import java.io.IOException; -import java.net.JarURLConnection; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLClassLoader; -import java.net.URLConnection; -import java.util.Iterator; -import java.util.Set; - -import javax.servlet.ServletContext; - -import org.apache.juli.logging.Log; -import org.apache.juli.logging.LogFactory; -import org.apache.tomcat.JarScanner; -import org.apache.tomcat.JarScannerCallback; -import org.apache.tomcat.util.res.StringManager; - -/** - * The default {@link JarScanner} implementation scans the WEB-INF/lib directory - * followed by the provided classloader and then works up the classloader - * hierarchy. This implementation is sufficient to meet the requirements of the - * Servlet 3.0 specification as well as to provide a number of Tomcat specific - * extensions. The extensions are: - *
    - *
  • Scanning the classloader hierarchy (enabled by default)
  • - *
  • Testing all files to see if they are JARs (disabled by default)
  • - *
  • Testing all directories to see if they are exploded JARs - * (disabled by default)
  • - *
- * All of the extensions may be controlled via configuration. - * - * Keep in sync with org.apache.jasper.compiler.InternalJarScanner - */ -public class DefaultJarScanner implements JarScanner { - - private static final String JAR_EXT = ".jar"; - private static final String WEB_INF_LIB = "/WEB-INF/lib/"; - - private static final Log log = LogFactory.getLog(DefaultJarScanner.class); - - /** - * The string resources for this package. - */ - private static final StringManager sm = - StringManager.getManager(Constants.Package); - - - /** - * Controls the classpath scanning extension. - */ - private boolean scanClassPath = true; - public boolean isScanClassPath() { - return scanClassPath; - } - public void setScanClassPath(boolean scanClassPath) { - this.scanClassPath = scanClassPath; - } - - /** - * Controls the testing all files to see of they are JAR files extension. - */ - private boolean scanAllFiles = false; - public boolean isScanAllFiles() { - return scanAllFiles; - } - public void setScanAllFiles(boolean scanAllFiles) { - this.scanAllFiles = scanAllFiles; - } - - /** - * Controls the testing all directories to see of they are exploded JAR - * files extension. - */ - private boolean scanAllDirectories = false; - public boolean isScanAllDirectories() { - return scanAllDirectories; - } - public void setScanAllDirectories(boolean scanAllDirectories) { - this.scanAllDirectories = scanAllDirectories; - } - - /** - * {@inheritDoc} - */ - @Override - public void scan(ServletContext context, ClassLoader classloader, - JarScannerCallback callback, Set jarsToSkip) { - - if (log.isTraceEnabled()) { - log.trace(sm.getString("jarScan.webinflibStart")); - } - - // Scan WEB-INF/lib - Set dirList = context.getResourcePaths(WEB_INF_LIB); - if (dirList != null) { - Iterator it = dirList.iterator(); - while (it.hasNext()) { - String path = it.next(); - if (path.endsWith(JAR_EXT) && - !jarsToSkip.contains( - path.substring(path.lastIndexOf('/')))) { - // Need to scan this JAR - URL url = null; - try { - url = context.getResource(path); - process(callback, url); - } catch (IOException e) { - log.warn(sm.getString("jarScan.webinflibFail", url), e); - } - } - } - } - - // Scan the classpath - if (scanClassPath) { - if (log.isTraceEnabled()) { - log.trace(sm.getString("jarScan.classloaderStart")); - } - - ClassLoader loader = - Thread.currentThread().getContextClassLoader(); - - while (loader != null) { - if (loader instanceof URLClassLoader) { - URL[] urls = ((URLClassLoader) loader).getURLs(); - for (int i=0; i - *
  • Scanning the classloader hierarchy (enabled by default)
  • - *
  • Testing all files to see if they are JARs (disabled by default)
  • - *
  • Testing all directories to see if they are exploded JARs - * (disabled by default)
  • - * - * All of the extensions may be controlled via configuration. - * - * Keep in sync with org.apache.catalina.startup.DefaultJarScanner - */ -public class InternalJarScanner implements JarScanner { - - private static final String JAR_EXT = ".jar"; - private static final String WEB_INF_LIB = "/WEB-INF/lib/"; - - private static final Log log = LogFactory.getLog(InternalJarScanner.class); - - /** - * Controls the classpath scanning extension. - */ - private boolean scanClassPath = true; - public boolean isScanClassPath() { - return scanClassPath; - } - public void setScanClassPath(boolean scanClassPath) { - this.scanClassPath = scanClassPath; - } - - /** - * Controls the testing all files to see of they are JAR files extension. - */ - private boolean scanAllFiles = false; - public boolean isScanAllFiles() { - return scanAllFiles; - } - public void setScanAllFiles(boolean scanAllFiles) { - this.scanAllFiles = scanAllFiles; - } - - /** - * Controls the testing all directories to see of they are exploded JAR - * files extension. - */ - private boolean scanAllDirectories = false; - public boolean isScanAllDirectories() { - return scanAllDirectories; - } - public void setScanAllDirectories(boolean scanAllDirectories) { - this.scanAllDirectories = scanAllDirectories; - } - - /** - * {@inheritDoc} - */ - @Override - public void scan(ServletContext context, ClassLoader classloader, - JarScannerCallback callback, Set jarsToSkip) { - - if (log.isTraceEnabled()) { - log.trace(Localizer.getMessage("jsp.jarScan.webinflibStart")); - } - - // Scan WEB-INF/lib - Set dirList = context.getResourcePaths(WEB_INF_LIB); - if (dirList != null) { - Iterator it = dirList.iterator(); - while (it.hasNext()) { - String path = it.next(); - if (path.endsWith(JAR_EXT) && - !jarsToSkip.contains( - path.substring(path.lastIndexOf('/')))) { - // Need to scan this JAR - URL url = null; - try { - url = context.getResource(path); - process(callback, url); - } catch (IOException e) { - if (url == null) { - log.warn(Localizer.getMessage( - "jsp.jarScan.webinflibFail", - path), e); - } else { - log.warn(Localizer.getMessage( - "jsp.jarScan.webinflibFail", - url.toString()), e); - } - } - } - } - } - - // Scan the classpath - if (scanClassPath) { - if (log.isTraceEnabled()) { - log.trace(Localizer.getMessage("jsp.jarScan.classloaderStart")); - } - - ClassLoader loader = - Thread.currentThread().getContextClassLoader(); - - while (loader != null) { - if (loader instanceof URLClassLoader) { - URL[] urls = ((URLClassLoader) loader).getURLs(); - for (int i=0; i + *
  • Scanning the classloader hierarchy (enabled by default)
  • + *
  • Testing all files to see if they are JARs (disabled by default)
  • + *
  • Testing all directories to see if they are exploded JARs + * (disabled by default)
  • + * + * All of the extensions may be controlled via configuration. + */ +public class DefaultJarScanner implements JarScanner { + + private static final String JAR_EXT = ".jar"; + private static final String WEB_INF_LIB = "/WEB-INF/lib/"; + + private static final Log log = LogFactory.getLog(DefaultJarScanner.class); + + /** + * The string resources for this package. + */ + private static final StringManager sm = + StringManager.getManager(Constants.Package); + + + /** + * Controls the classpath scanning extension. + */ + private boolean scanClassPath = true; + public boolean isScanClassPath() { + return scanClassPath; + } + public void setScanClassPath(boolean scanClassPath) { + this.scanClassPath = scanClassPath; + } + + /** + * Controls the testing all files to see of they are JAR files extension. + */ + private boolean scanAllFiles = false; + public boolean isScanAllFiles() { + return scanAllFiles; + } + public void setScanAllFiles(boolean scanAllFiles) { + this.scanAllFiles = scanAllFiles; + } + + /** + * Controls the testing all directories to see of they are exploded JAR + * files extension. + */ + private boolean scanAllDirectories = false; + public boolean isScanAllDirectories() { + return scanAllDirectories; + } + public void setScanAllDirectories(boolean scanAllDirectories) { + this.scanAllDirectories = scanAllDirectories; + } + + /** + * {@inheritDoc} + */ + @Override + public void scan(ServletContext context, ClassLoader classloader, + JarScannerCallback callback, Set jarsToSkip) { + + if (log.isTraceEnabled()) { + log.trace(sm.getString("jarScan.webinflibStart")); + } + + // Scan WEB-INF/lib + Set dirList = context.getResourcePaths(WEB_INF_LIB); + if (dirList != null) { + Iterator it = dirList.iterator(); + while (it.hasNext()) { + String path = it.next(); + if (path.endsWith(JAR_EXT) && + !jarsToSkip.contains( + path.substring(path.lastIndexOf('/')))) { + // Need to scan this JAR + URL url = null; + try { + url = context.getResource(path); + process(callback, url); + } catch (IOException e) { + log.warn(sm.getString("jarScan.webinflibFail", url), e); + } + } + } + } + + // Scan the classpath + if (scanClassPath) { + if (log.isTraceEnabled()) { + log.trace(sm.getString("jarScan.classloaderStart")); + } + + ClassLoader loader = + Thread.currentThread().getContextClassLoader(); + + while (loader != null) { + if (loader instanceof URLClassLoader) { + URL[] urls = ((URLClassLoader) loader).getURLs(); + for (int i=0; i + + + + + +

    +This package contains the common classes used to perform configuration scanning +for Catalina and Jasper. +

    + + diff --git a/res/maven/mvn-pub.xml b/res/maven/mvn-pub.xml index 16144e7c8..cad825dfb 100644 --- a/res/maven/mvn-pub.xml +++ b/res/maven/mvn-pub.xml @@ -142,6 +142,7 @@ + diff --git a/res/maven/tomcat-catalina.pom b/res/maven/tomcat-catalina.pom index aec744755..563a39cba 100644 --- a/res/maven/tomcat-catalina.pom +++ b/res/maven/tomcat-catalina.pom @@ -46,5 +46,11 @@ @MAVEN.DEPLOY.VERSION@ compile + + org.apache.tomcat + tomcat-util + @MAVEN.DEPLOY.VERSION@ + compile + diff --git a/res/maven/tomcat-jasper.pom b/res/maven/tomcat-jasper.pom index 09e4e42ca..6238c90cf 100644 --- a/res/maven/tomcat-jasper.pom +++ b/res/maven/tomcat-jasper.pom @@ -70,5 +70,11 @@ @MAVEN.DEPLOY.VERSION@ compile + + org.apache.tomcat + tomcat-util + @MAVEN.DEPLOY.VERSION@ + compile + diff --git a/res/maven/tomcat-util.pom b/res/maven/tomcat-util.pom new file mode 100644 index 000000000..67e486fae --- /dev/null +++ b/res/maven/tomcat-util.pom @@ -0,0 +1,24 @@ + + + + 4.0.0 + org.apache.tomcat + tomcat-util + @MAVEN.DEPLOY.VERSION@ + Common code shared by Catalina and Jasper +