use of org.apache.webbeans.corespi.scanner.xbean.OwbAnnotationFinder in project meecrowave by apache.
the class OWBJarScanner method scan.
@Override
public void scan(final JarScanType jarScanType, final ServletContext servletContext, final JarScannerCallback callback) {
switch(jarScanType) {
case PLUGGABILITY:
final WebBeansContext owb = WebBeansContext.getInstance();
final ScannerService scannerService = owb.getScannerService();
if (!WebScannerService.class.isInstance(scannerService)) {
return;
}
final OwbAnnotationFinder finder = WebScannerService.class.cast(scannerService).getFinder();
if (finder == null) {
return;
}
CdiArchive.class.cast(finder.getArchive()).classesByUrl().keySet().stream().filter(// not a fake in memory url
u -> !"jar:file://!/".equals(u)).forEach(u -> {
try {
final URL url = new URL(u);
final File asFile = Files.toFile(url);
if (!asFile.exists()) {
return;
}
if (filter != null && !filter.check(jarScanType, asFile.getName())) {
return;
}
if (asFile.getName().endsWith(Constants.JAR_EXT)) {
try (final Jar jar = JarFactory.newInstance(asFile.toURI().toURL())) {
callback.scan(jar, u, true);
}
} else if (asFile.isDirectory()) {
callback.scan(asFile, asFile.getAbsolutePath(), true);
}
} catch (final MalformedURLException e) {
// skip
} catch (final IOException ioe) {
throw new IllegalArgumentException(ioe);
}
});
return;
case TLD:
default:
}
}
Aggregations