Class StandardJarScanner
java.lang.Object
org.apache.tomcat.util.scan.StandardJarScanner
- All Implemented Interfaces:
JarScanner
The default
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)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddClassPath(Deque<URL> classPathUrlsToProcess) Adds URLs from the system classpath to the processing queue.protected voiddoScanClassPath(JarScanType scanType, ServletContext context, JarScannerCallback callback, Set<URL> processedURLs) Scans the class path for JAR files.Get the JAR scan filter currently in use.booleanReturns whether scanning all directories for exploded JARs is enabled.booleanReturns whether scanning all files for JARs is enabled.booleanReturns whether scanning the bootstrap classpath is enabled.booleanReturns whether classpath scanning is enabled.booleanReturns whether manifest scanning is enabled.protected voidprocess(JarScanType scanType, JarScannerCallback callback, URL url, String webappPath, boolean isWebapp, Deque<URL> classPathUrlsToProcess) Scan a URL for JARs with the optional extensions to look at all files and all directories.protected voidprocessURLs(JarScanType scanType, JarScannerCallback callback, Set<URL> processedURLs, boolean isWebapp, Deque<URL> classPathUrlsToProcess) Processes URLs for JAR scanning.voidscan(JarScanType scanType, ServletContext context, JarScannerCallback callback) Scan the provided ServletContext and class loader for JAR files.voidsetJarScanFilter(JarScanFilter jarScanFilter) Set the JAR scan filter to use.voidsetScanAllDirectories(boolean scanAllDirectories) Sets whether scanning all directories for exploded JARs is enabled.voidsetScanAllFiles(boolean scanAllFiles) Sets whether scanning all files for JARs is enabled.voidsetScanBootstrapClassPath(boolean scanBootstrapClassPath) Sets whether scanning the bootstrap classpath is enabled.voidsetScanClassPath(boolean scanClassPath) Sets whether classpath scanning is enabled.voidsetScanManifest(boolean scanManifest) Sets whether manifest scanning is enabled.
-
Constructor Details
-
StandardJarScanner
public StandardJarScanner()Constructs a new StandardJarScanner instance.
-
-
Method Details
-
isScanClassPath
public boolean isScanClassPath()Returns whether classpath scanning is enabled.- Returns:
- true if classpath scanning is enabled
-
setScanClassPath
public void setScanClassPath(boolean scanClassPath) Sets whether classpath scanning is enabled.- Parameters:
scanClassPath- true to enable classpath scanning
-
isScanManifest
public boolean isScanManifest()Returns whether manifest scanning is enabled.- Returns:
- true if manifest scanning is enabled
-
setScanManifest
public void setScanManifest(boolean scanManifest) Sets whether manifest scanning is enabled.- Parameters:
scanManifest- true to enable manifest scanning
-
isScanAllFiles
public boolean isScanAllFiles()Returns whether scanning all files for JARs is enabled.- Returns:
- true if scanning all files is enabled
-
setScanAllFiles
public void setScanAllFiles(boolean scanAllFiles) Sets whether scanning all files for JARs is enabled.- Parameters:
scanAllFiles- true to enable scanning all files
-
isScanAllDirectories
public boolean isScanAllDirectories()Returns whether scanning all directories for exploded JARs is enabled.- Returns:
- true if scanning all directories is enabled
-
setScanAllDirectories
public void setScanAllDirectories(boolean scanAllDirectories) Sets whether scanning all directories for exploded JARs is enabled.- Parameters:
scanAllDirectories- true to enable scanning all directories
-
isScanBootstrapClassPath
public boolean isScanBootstrapClassPath()Returns whether scanning the bootstrap classpath is enabled.- Returns:
- true if scanning the bootstrap classpath is enabled
-
setScanBootstrapClassPath
public void setScanBootstrapClassPath(boolean scanBootstrapClassPath) Sets whether scanning the bootstrap classpath is enabled.- Parameters:
scanBootstrapClassPath- true to enable scanning the bootstrap classpath
-
getJarScanFilter
Description copied from interface:JarScannerGet the JAR scan filter currently in use.- Specified by:
getJarScanFilterin interfaceJarScanner- Returns:
- the JAR scan filter
-
setJarScanFilter
Description copied from interface:JarScannerSet the JAR scan filter to use.- Specified by:
setJarScanFilterin interfaceJarScanner- Parameters:
jarScanFilter- the JAR scan filter
-
scan
Scan the provided ServletContext and class loader for JAR files. Each JAR file found will be passed to the callback handler to be processed.- Specified by:
scanin interfaceJarScanner- Parameters:
scanType- The type of JAR scan to perform. This is passed to the filter which uses it to determine how to filter the resultscontext- The ServletContext - used to locate and access WEB-INF/libcallback- The handler to process any JARs found
-
doScanClassPath
protected void doScanClassPath(JarScanType scanType, ServletContext context, JarScannerCallback callback, Set<URL> processedURLs) Scans the class path for JAR files.- Parameters:
scanType- the type of scan to performcontext- the servlet contextcallback- the callback handler for found JARsprocessedURLs- the set of already processed URLs
-
processURLs
protected void processURLs(JarScanType scanType, JarScannerCallback callback, Set<URL> processedURLs, boolean isWebapp, Deque<URL> classPathUrlsToProcess) Processes URLs for JAR scanning.- Parameters:
scanType- the type of scan to performcallback- the callback handler for found JARsprocessedURLs- the set of already processed URLsisWebapp- true if processing webapp URLsclassPathUrlsToProcess- the queue of URLs to process
-
addClassPath
-
process
protected void process(JarScanType scanType, JarScannerCallback callback, URL url, String webappPath, boolean isWebapp, Deque<URL> classPathUrlsToProcess) throws IOException Scan a URL for JARs with the optional extensions to look at all files and all directories.- Parameters:
scanType- the type of scan to performcallback- the callback handler for found JARsurl- the URL to scanwebappPath- the web application pathisWebapp- true if the URL is part of a web applicationclassPathUrlsToProcess- the queue of URLs to process- Throws:
IOException- if an I/O error occurs during scanning
-