@ThreadSafe public class CentralAnalyzer extends AbstractFileTypeAnalyzer
Constructor and Description |
---|
CentralAnalyzer() |
Modifier and Type | Method and Description |
---|---|
void |
analyzeDependency(Dependency dependency,
Engine engine)
Performs the analysis.
|
protected java.util.List<MavenArtifact> |
fetchMavenArtifacts(Dependency dependency)
Downloads the corresponding list of MavenArtifacts of the given
dependency from MavenCentral.
|
AnalysisPhase |
getAnalysisPhase()
Returns the analysis phase under which the analyzer runs.
|
protected java.lang.String |
getAnalyzerEnabledSettingKey()
Returns the key used in the properties file to to reference the
analyzer's enabled property.
|
protected java.io.FileFilter |
getFileFilter()
Returns the
FileFilter used to determine which files are
to be analyzed. |
java.lang.String |
getName()
Returns the analyzer's name.
|
void |
initialize(Settings settings)
Initializes the analyzer with the configured settings.
|
void |
prepareFileTypeAnalyzer(Engine engine)
Initializes the analyzer once before any analysis is performed.
|
protected void |
setCentralSearch(CentralSearch searcher)
Method used by unit tests to setup the analyzer.
|
boolean |
supportsParallelProcessing()
Whether the analyzer is configured to support parallel processing.
|
accept, getFilesMatched, newHashSet, prepareAnalyzer, setFilesMatched
analyze, close, closeAnalyzer, getSettings, isEnabled, prepare, setEnabled
public void initialize(Settings settings)
initialize
in interface Analyzer
initialize
in class AbstractAnalyzer
settings
- the configured settings to usepublic boolean supportsParallelProcessing()
supportsParallelProcessing
in interface Analyzer
supportsParallelProcessing
in class AbstractAnalyzer
public void prepareFileTypeAnalyzer(Engine engine) throws InitializationException
prepareFileTypeAnalyzer
in class AbstractFileTypeAnalyzer
engine
- a reference to the dependency-check engineInitializationException
- if there's an error during initializationpublic java.lang.String getName()
protected java.lang.String getAnalyzerEnabledSettingKey()
getAnalyzerEnabledSettingKey
in class AbstractAnalyzer
public AnalysisPhase getAnalysisPhase()
protected java.io.FileFilter getFileFilter()
AbstractFileTypeAnalyzer
Returns the FileFilter
used to determine which files are
to be analyzed. An example would be an analyzer that inspected Java jar
files. Implementors may use
FileFilterBuilder
.
If the analyzer returns null it will not cause additional files to be analyzed, but will be executed against every file loaded.
getFileFilter
in class AbstractFileTypeAnalyzer
public void analyzeDependency(Dependency dependency, Engine engine) throws AnalysisException
analyzeDependency
in class AbstractAnalyzer
dependency
- the dependency to analyzeengine
- the engineAnalysisException
- when there's an exception during analysisprotected java.util.List<MavenArtifact> fetchMavenArtifacts(Dependency dependency) throws java.io.IOException, TooManyRequestsException
As the connection to MavenCentral is known to be unreliable, we implement a simple retry logic in order to compensate for 99% of the issues.
dependency
- the dependency to analyzejava.io.FileNotFoundException
- if the specified artifact is not foundjava.io.IOException
- if connecting to MavenCentral finally failedTooManyRequestsException
- if Central has received too many
requests.protected void setCentralSearch(CentralSearch searcher)
searcher
- the Central Search object to use.Copyright© 2012-21 Jeremy Long. All Rights Reserved.