# Class StandardJarScanner

java.lang.Object
org.apache.tomcat.util.scan.StandardJarScanner

All Implemented Interfaces:
  `JarScanner`

public class StandardJarScanner extends Object implements 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)

All of the extensions may be controlled via configuration.

## Constructor Summary

Constructors
Constructor
Description
`StandardJarScanner()`
Constructs a new StandardJarScanner instance.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`addClassPath(Deque<URL> classPathUrlsToProcess)`
Adds URLs from the system classpath to the processing queue.
`protected void`
`doScanClassPath(JarScanType scanType, ServletContext context, JarScannerCallback callback, Set<URL> processedURLs)`
Scans the class path for JAR files.
`JarScanFilter`
`getJarScanFilter()`
Get the JAR scan filter currently in use.
`boolean`
`isScanAllDirectories()`
Returns whether scanning all directories for exploded JARs is enabled.
`boolean`
`isScanAllFiles()`
Returns whether scanning all files for JARs is enabled.
`boolean`
`isScanBootstrapClassPath()`
Returns whether scanning the bootstrap classpath is enabled.
`boolean`
`isScanClassPath()`
Returns whether classpath scanning is enabled.
`boolean`
`isScanManifest()`
Returns whether manifest scanning is enabled.
`protected void`
`process(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 void`
`processURLs(JarScanType scanType, JarScannerCallback callback, Set<URL> processedURLs, boolean isWebapp, Deque<URL> classPathUrlsToProcess)`
Processes URLs for JAR scanning.
`void`
`scan(JarScanType scanType, ServletContext context, JarScannerCallback callback)`
Scan the provided ServletContext and class loader for JAR files.
`void`
`setJarScanFilter(JarScanFilter jarScanFilter)`
Set the JAR scan filter to use.
`void`
`setScanAllDirectories(boolean scanAllDirectories)`
Sets whether scanning all directories for exploded JARs is enabled.
`void`
`setScanAllFiles(boolean scanAllFiles)`
Sets whether scanning all files for JARs is enabled.
`void`
`setScanBootstrapClassPath(boolean scanBootstrapClassPath)`
Sets whether scanning the bootstrap classpath is enabled.
`void`
`setScanClassPath(boolean scanClassPath)`
Sets whether classpath scanning is enabled.
`void`
`setScanManifest(boolean scanManifest)`
Sets whether manifest scanning is enabled.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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

public JarScanFilter getJarScanFilter()
Description copied from interface: `JarScanner`
Get the JAR scan filter currently in use.

Specified by:
  `getJarScanFilter` in interface `JarScanner`
Returns:
  the JAR scan filter

### setJarScanFilter

public void setJarScanFilter(JarScanFilter jarScanFilter)
Description copied from interface: `JarScanner`
Set the JAR scan filter to use.

Specified by:
  `setJarScanFilter` in interface `JarScanner`
Parameters:
  `jarScanFilter` - the JAR scan filter

### scan

public void scan(JarScanType scanType, ServletContext context, JarScannerCallback callback)
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:
  `scan` in interface `JarScanner`
Parameters:
  `scanType` - The type of JAR scan to perform. This is passed to the filter which uses it to determine how to filter the results
  `context` - The ServletContext - used to locate and access WEB-INF/lib
  `callback` - 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 perform
  `context` - the servlet context
  `callback` - the callback handler for found JARs
  `processedURLs` - 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 perform
  `callback` - the callback handler for found JARs
  `processedURLs` - the set of already processed URLs
  `isWebapp` - true if processing webapp URLs
  `classPathUrlsToProcess` - the queue of URLs to process

### addClassPath

protected void addClassPath(Deque<URL> classPathUrlsToProcess)
Adds URLs from the system classpath to the processing queue.

Parameters:
  `classPathUrlsToProcess` - the queue to add URLs to

### 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 perform
  `callback` - the callback handler for found JARs
  `url` - the URL to scan
  `webappPath` - the web application path
  `isWebapp` - true if the URL is part of a web application
  `classPathUrlsToProcess` - the queue of URLs to process
Throws:
  `IOException` - if an I/O error occurs during scanning