Java Code Examples for org.apache.tomcat.JarScanType#PLUGGABILITY

The following examples show how to use org.apache.tomcat.JarScanType#PLUGGABILITY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FatJarScanner.java    From oxygen with Apache License 2.0 6 votes vote down vote up
private void processFile(JarScanType scanType, JarScannerCallback callback, URL url,
    String webappPath, boolean isWebapp, Deque<URL> classPathUrlsToProcess) throws IOException {
  try {
    File f = new File(url.toURI());
    if (f.isFile()) {
      // Treat this file as a JAR
      try (Jar jar = JarFactory.newInstance(UriUtil.buildJarUrl(f))) {
        processManifest(jar, isWebapp, classPathUrlsToProcess);
        callback.scan(jar, webappPath, isWebapp);
      }
    } else if (f.isDirectory()) {
      if (scanType == JarScanType.PLUGGABILITY) {
        callback.scan(f, webappPath, isWebapp);
      } else {
        if (new File(f.getAbsoluteFile(), TomcatConf.META_INF).isDirectory()) {
          callback.scan(f, webappPath, isWebapp);
        }
      }
    }
  } catch (URISyntaxException e) {
    throw new IOException(e);
  }
}
 
Example 2
Source File: TomEEJarScanner.java    From tomee with Apache License 2.0 6 votes vote down vote up
private void doScan(final JarScanType scanType, final JarScannerCallback callback, final Deque<URL> urls) {
    Method process = null;
    final boolean scanAllDirectories = isScanAllDirectories();
    for (final URL url : urls) {
        final File cpe = URLs.toFile(url);
        if ((cpe.getName().endsWith(".jar") ||
                scanType == JarScanType.PLUGGABILITY ||
                scanAllDirectories) &&
                getJarScanFilter().check(scanType, cpe.getName())) {
            try {
                if (process == null) {
                    process = StandardJarScanner.class.getDeclaredMethod("process",
                            JarScanType.class, JarScannerCallback.class, URL.class, String.class, boolean.class, Deque.class);
                    if (!process.isAccessible()) {
                        process.setAccessible(true);
                    }
                }
                process.invoke(this, scanType, callback, url, null, true, urls);
            } catch (final Exception ioe) {
                // no-op
            }
        }
    }
}
 
Example 3
Source File: StandardJarScanner.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected void processURLs(JarScanType scanType, JarScannerCallback callback,
        Set<URL> processedURLs, boolean isWebapp, Deque<URL> classPathUrlsToProcess) {
    while (!classPathUrlsToProcess.isEmpty()) {
        URL url = classPathUrlsToProcess.pop();

        if (processedURLs.contains(url)) {
            // Skip this URL it has already been processed
            continue;
        }

        ClassPathEntry cpe = new ClassPathEntry(url);

        // JARs are scanned unless the filter says not to.
        // Directories are scanned for pluggability scans or
        // if scanAllDirectories is enabled unless the
        // filter says not to.
        if ((cpe.isJar() ||
                scanType == JarScanType.PLUGGABILITY ||
                isScanAllDirectories()) &&
                        getJarScanFilter().check(scanType,
                                cpe.getName())) {
            if (log.isDebugEnabled()) {
                log.debug(sm.getString("jarScan.classloaderJarScan", url));
            }
            try {
                processedURLs.add(url);
                process(scanType, callback, url, null, isWebapp, classPathUrlsToProcess);
            } catch (IOException ioe) {
                log.warn(sm.getString("jarScan.classloaderFail", url), ioe);
            }
        } else {
            // JAR / directory has been skipped
            if (log.isTraceEnabled()) {
                log.trace(sm.getString("jarScan.classloaderJarNoScan", url));
            }
        }
    }
}