use of org.apache.drill.common.scanner.persistence.ParentClassDescriptor in project drill by apache.
the class ClassPathScanner method scan.
/**
*
* @param pathsToScan the locations to scan for .class files
* @param packagePrefixes the whitelist of package prefixes to scan
* @param parentResult if there was a prescan, its result
* @return the merged scan
*/
static ScanResult scan(Collection<URL> pathsToScan, Collection<String> packagePrefixes, Collection<String> scannedClasses, Collection<String> scannedAnnotations, ScanResult parentResult) {
Stopwatch watch = Stopwatch.createStarted();
try {
AnnotationScanner annotationScanner = new AnnotationScanner(scannedAnnotations);
SubTypesScanner subTypesScanner = new SubTypesScanner(parentResult.getImplementations());
if (packagePrefixes.size() > 0) {
final FilterBuilder filter = new FilterBuilder();
for (String prefix : packagePrefixes) {
filter.include(FilterBuilder.prefix(prefix));
}
ConfigurationBuilder conf = new ConfigurationBuilder().setUrls(pathsToScan).setMetadataAdapter(// Scanners depend on this
METADATA_ADAPTER).filterInputsBy(filter).setScanners(annotationScanner, subTypesScanner);
// scans stuff, but don't use the funky storage layer
new Reflections(conf);
}
List<ParentClassDescriptor> implementations = new ArrayList<>();
for (String baseTypeName : scannedClasses) {
implementations.add(new ParentClassDescriptor(baseTypeName, new ArrayList<>(subTypesScanner.getChildrenOf(baseTypeName))));
}
List<AnnotatedClassDescriptor> annotated = annotationScanner.getAnnotatedClasses();
verifyClassUnicity(annotated, pathsToScan);
return new ScanResult(packagePrefixes, scannedClasses, scannedAnnotations, annotated, implementations);
} finally {
logger.info(format("Scanning packages %s in locations %s took %dms", packagePrefixes, pathsToScan, watch.elapsed(MILLISECONDS)));
}
}
Aggregations