libs/gretty-runner-tomcat7/src/main/groovy/org/akhikhl/gretty/JarScannerEx.java
private void process(JarScannerCallback callback, URL url)
          throws IOException {

    if (log.isTraceEnabled()) {
      log.trace(sm.getString("jarScan.jarUrlStart", url));
    }

    URLConnection conn = url.openConnection();
    if (conn instanceof JarURLConnection) {
      callback.scan((JarURLConnection) conn);
    } else {
      String urlStr = url.toString();
      if (urlStr.startsWith("file:") || urlStr.startsWith("jndi:")
              || urlStr.startsWith("http:") || urlStr.startsWith("https:")) {
        if (urlStr.endsWith(Constants.JAR_EXT)) {
          URL jarURL = new URL("jar:" + urlStr + "!/");
          callback.scan((JarURLConnection) jarURL.openConnection());
        } else {
          File f;
          try {
            f = new File(url.toURI());
            if (f.isFile() && scanAllFiles) {
              // Treat this file as a JAR
              URL jarURL = new URL("jar:" + urlStr + "!/");
              callback.scan((JarURLConnection) jarURL.openConnection());
            } else if (f.isDirectory() && scanAllDirectories) {
              File metainf = new File(f, "META-INF");
              if (metainf.isDirectory()) {
                callback.scan(f);
              }
            }
          } catch (URISyntaxException e) {
            // Wrap the exception and re-throw
            IOException ioe = new IOException();
            ioe.initCause(e);
            throw ioe;
          }
        }
      }
    }

  }
private void process(JarScannerCallback callback, URL url)
          throws IOException {

    if (log.isTraceEnabled()) {
      log.trace(sm.getString("jarScan.jarUrlStart", url));
    }

    URLConnection conn = url.openConnection();
    if (conn instanceof JarURLConnection) {
      callback.scan((JarURLConnection) conn);
    } else {
      String urlStr = url.toString();
      if (urlStr.startsWith("file:") || urlStr.startsWith("jndi:")
              || urlStr.startsWith("http:") || urlStr.startsWith("https:")) {
        if (urlStr.endsWith(Constants.JAR_EXT)) {
          URL jarURL = new URL("jar:" + urlStr + "!/");
          callback.scan((JarURLConnection) jarURL.openConnection());
        } else {
          File f;
          try {
            f = new File(url.toURI());
            if (f.isFile() && scanAllFiles) {
              // Treat this file as a JAR
              URL jarURL = new URL("jar:" + urlStr + "!/");
              callback.scan((JarURLConnection) jarURL.openConnection());
            } else if (f.isDirectory() && scanAllDirectories) {
              File metainf = new File(f, "META-INF");
              if (metainf.isDirectory()) {
                callback.scan(f);
              }
            }
          } catch (URISyntaxException e) {
            // Wrap the exception and re-throw
            IOException ioe = new IOException();
            ioe.initCause(e);
            throw ioe;
          }
        }
      }
    }

  }
private void process ( JarScannerCallback callback , URL url ) throws IOException { if ( log . isTraceEnabled ( ) ) { log . trace ( sm . getString ( "jarScan.jarUrlStart" , url ) ) ; } URLConnection conn = url . openConnection ( ) ; if ( conn instanceof JarURLConnection ) { callback . scan ( ( JarURLConnection ) conn ) ; } else { String urlStr = url . toString ( ) ; if ( urlStr . startsWith ( "file:" ) || urlStr . startsWith ( "jndi:" ) || urlStr . startsWith ( "http:" ) || urlStr . startsWith ( "https:" ) ) { if ( urlStr . endsWith ( Constants . JAR_EXT ) ) { URL jarURL = new URL ( "jar:" + urlStr + "!/" ) ; callback . scan ( ( JarURLConnection ) jarURL . openConnection ( ) ) ; } else { File f ; try { f = new File ( url . toURI ( ) ) ; if ( f . isFile ( ) && scanAllFiles ) { // Treat this file as a JAR URL jarURL = new URL ( "jar:" + urlStr + "!/" ) ; callback . scan ( ( JarURLConnection ) jarURL . openConnection ( ) ) ; } else if ( f . isDirectory ( ) && scanAllDirectories ) { File metainf = new File ( f , "META-INF" ) ; if ( metainf . isDirectory ( ) ) { callback . scan ( f ) ; } } } catch ( URISyntaxException e ) { // Wrap the exception and re-throw IOException ioe = new IOException ( ) ; ioe . initCause ( e ) ; throw ioe ; } } } } }
/*
Scan a URL for JARs with the optional extensions to look at all files
and all directories.
/ * Scan a URL for JARs with the optional extensions to look at all files and all directories .