public void visitResourceNames(String packageName, boolean includeSubPackages, ClassLoader classLoader, ResourceVisitor visitor) {

    try {
      String path = packageName.replace('.', '/');
      if (path.isEmpty()) {
        LOG.debug("Scanning entire classpath...");
      } else {
        LOG.trace("Scanning for resources on classpath for {}", path);
      }
      StringBuilder qualifiedNameBuilder = new StringBuilder(path);
      if (qualifiedNameBuilder.length() > 0) {
        qualifiedNameBuilder.append('/');
      }
      String pathWithPrefix = qualifiedNameBuilder.toString();
      int qualifiedNamePrefixLength = qualifiedNameBuilder.length();
      Enumeration<URL> urls = classLoader.getResources(path);
      Set<String> urlSet = new HashSet<>();
      while (urls.hasMoreElements()) {
        URL url = urls.nextElement();
        visitResourceUrl(includeSubPackages, visitor, pathWithPrefix, qualifiedNameBuilder, qualifiedNamePrefixLength, url, urlSet);
      }
      if (path.isEmpty()) {
        visitResourceClassloader(includeSubPackages, classLoader, visitor, pathWithPrefix, qualifiedNameBuilder, qualifiedNamePrefixLength, urlSet);
        visitResourceClasspath(includeSubPackages, visitor, qualifiedNameBuilder, pathWithPrefix, qualifiedNamePrefixLength, urlSet);
      }
    } catch (IOException e) {
      throw new IllegalStateException("Error reading resources.", e);
    }
  }
public void visitResourceNames ( String packageName , boolean includeSubPackages , ClassLoader classLoader , ResourceVisitor visitor ) { try { String path = packageName . replace ( '.' , '/' ) ; if ( path . isEmpty ( ) ) { LOG . debug ( "Scanning entire classpath..." ) ; } else { LOG . trace ( "Scanning for resources on classpath for {}" , path ) ; } StringBuilder qualifiedNameBuilder = new StringBuilder ( path ) ; if ( qualifiedNameBuilder . length ( ) > 0 ) { qualifiedNameBuilder . append ( '/' ) ; } String pathWithPrefix = qualifiedNameBuilder . toString ( ) ; int qualifiedNamePrefixLength = qualifiedNameBuilder . length ( ) ; Enumeration < URL > urls = classLoader . getResources ( path ) ; Set < String > urlSet = new HashSet < > ( ) ; while ( urls . hasMoreElements ( ) ) { URL url = urls . nextElement ( ) ; visitResourceUrl ( includeSubPackages , visitor , pathWithPrefix , qualifiedNameBuilder , qualifiedNamePrefixLength , url , urlSet ) ; } if ( path . isEmpty ( ) ) { visitResourceClassloader ( includeSubPackages , classLoader , visitor , pathWithPrefix , qualifiedNameBuilder , qualifiedNamePrefixLength , urlSet ) ; visitResourceClasspath ( includeSubPackages , visitor , qualifiedNameBuilder , pathWithPrefix , qualifiedNamePrefixLength , urlSet ) ; } } catch ( IOException e ) { throw new IllegalStateException ( "Error reading resources." , e ) ; } }
This method does the actual magic to locate resources on the classpath.

@param packageName is the name of the {@link Package} to scan. Both "." and "/" are accepted as separator (e.g.
"net.sf.mmm.util.reflect).
@param includeSubPackages - if {@code true} all sub-packages of the specified {@link Package} will be included in
the search.
@param classLoader is the explicit {@link ClassLoader} to use.
@param visitor is the {@link ResourceVisitor}.
@if the operation failed with an I/O error.