optaplanner-core/src/main/java/org/optaplanner/core/config/domain/ReflectionsWorkaroundClasspathHelper.java
public static Collection<URL> forResource(String resourceName, ClassLoader... classLoaders) {
        final List<URL> result = new ArrayList<>();
        final ClassLoader[] loaders = classLoaders(classLoaders);
        for (ClassLoader classLoader : loaders) {
            try {
                final Enumeration<URL> urls = classLoader.getResources(resourceName);
                while (urls.hasMoreElements()) {
                    final URL url = urls.nextElement();
                    int index = url.toExternalForm().lastIndexOf(resourceName);
                    if (index != -1) {
                        String newUrlString = url.toExternalForm().substring(0, index);
                        // Use old url as context to support exotic url handlers
                        result.add(new URL(url, newUrlString));
                    } else {
                        result.add(url);
                    }
                }
            } catch (IOException e) {
                if (Reflections.log != null) {
                    Reflections.log.error("error getting resources for " + resourceName, e);
                }
            }
        }
        return distinctUrls(result);
    }
public static Collection<URL> forResource(String resourceName, ClassLoader... classLoaders) {
        final List<URL> result = new ArrayList<>();
        final ClassLoader[] loaders = classLoaders(classLoaders);
        for (ClassLoader classLoader : loaders) {
            try {
                final Enumeration<URL> urls = classLoader.getResources(resourceName);
                while (urls.hasMoreElements()) {
                    final URL url = urls.nextElement();
                    int index = url.toExternalForm().lastIndexOf(resourceName);
                    if (index != -1) {
                        String newUrlString = url.toExternalForm().substring(0, index);
                        // Use old url as context to support exotic url handlers
                        result.add(new URL(url, newUrlString));
                    } else {
                        result.add(url);
                    }
                }
            } catch (IOException e) {
                if (Reflections.log != null) {
                    Reflections.log.error("error getting resources for " + resourceName, e);
                }
            }
        }
        return distinctUrls(result);
    }
public static Collection < URL > forResource ( String resourceName , ClassLoader ... classLoaders ) { final List < URL > result = new ArrayList <> ( ) ; final ClassLoader [ ] loaders = classLoaders ( classLoaders ) ; for ( ClassLoader classLoader : loaders ) { try { final Enumeration < URL > urls = classLoader . getResources ( resourceName ) ; while ( urls . hasMoreElements ( ) ) { final URL url = urls . nextElement ( ) ; int index = url . toExternalForm ( ) . lastIndexOf ( resourceName ) ; if ( index != - 1 ) { String newUrlString = url . toExternalForm ( ) . substring ( 0 , index ) ; // Use old url as context to support exotic url handlers result . add ( new URL ( url , newUrlString ) ) ; } else { result . add ( url ) ; } } } catch ( IOException e ) { if ( Reflections . log != null ) { Reflections . log . error ( "error getting resources for " + resourceName , e ) ; } } } return distinctUrls ( result ) ; }
Returns a distinct collection of URLs based on a resource.
<p>
This searches for the resource name, using {@link ClassLoader#getResources(String)}.
For example, {@code forResource(test.properties)} effectively returns URLs from the
classpath containing files of that name.
<p>
If the optional {@link ClassLoader}s are not specified, then both {@link #contextClassLoader()}
and {@link #staticClassLoader()} are used for {@link ClassLoader#getResources(String)}.
<p>
The returned URLs retains the order of the given {@code classLoaders}.

@return the collection of URLs, not null
Returns a distinct collection of URLs based on a resource . <p > This searches for the resource name using { @link ClassLoader#getResources ( String ) } . For example { @code forResource ( test . properties ) } effectively returns URLs from the classpath containing files of that name . <p > If the optional { @link ClassLoader } s are not specified then both { @link #contextClassLoader () } and { @link #staticClassLoader () } are used for { @link ClassLoader#getResources ( String ) } . <p > The returned URLs retains the order of the given { @code classLoaders } .