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 .