public ThreadContextClassLoaderBuilder addURL ( final URL anURL ) { // Check sanity Validate . notNull ( anURL , "anURL" ) ; // Add the segment unless already added. for ( URL current : urlList ) { if ( current . toString ( ) . equalsIgnoreCase ( anURL . toString ( ) ) ) { if ( log . isWarnEnabled ( ) ) { log . warn ( "Not adding URL [" + anURL . toString ( ) + "] twice. Check your plugin configuration." ) ; } // Don't re-add the supplied URL. return this ; } } // Add the supplied URL to the urlList if ( log . isDebugEnabled ( ) ) { log . debug ( "Adding URL [" + anURL . toString ( ) + "]" ) ; } // // According to the URLClassLoader's documentation: // "Any URL that ends with a '/' is assumed to refer to a directory. // Otherwise, the URL is assumed to refer to a JAR file which will be downloaded and opened as needed." // // ... uhm ... instead of using the 'protocol' property of the URL itself? // // So ... we need to ensure that any file-protocol URLs which point to directories are actually // terminated with a '/'. Otherwise the URLClassLoader treats those URLs as JARs - and hence ignores them. // urlList . add ( addSlashToDirectoryUrlIfRequired ( anURL ) ) ; return this ; }
Adds the supplied anURL to the list of internal URLs which should be used to build an URLClassLoader . Will only add an URL once and warns about trying to re - add an URL .