public static DelegateClassLoader forPlugins ( Stream < URL > urls , ClassLoader appClassLoader ) { Require . nonNull ( urls , "urls" ) ; Require . nonNull ( appClassLoader , "parent" ) ; final Collection < DependencyResolver > plugins = new ArrayList <> ( ) ; final Collection < PluginInformation > information = new ArrayList <> ( ) ; final DependencyResolver delegator = new DelegateDependencyResolver ( plugins ) ; final Iterator < URL > it = urls . iterator ( ) ; while ( it . hasNext ( ) ) { final URL pluginURL = it . next ( ) ; // Plugin classloaders must be created with the application // classloader as parent. This is mandatory for establishing a sound // locking strategy during class lookup. final PluginClassLoader pluginCl = PluginClassLoader . create ( pluginURL , appClassLoader , delegator ) ; plugins . add ( pluginCl ) ; information . add ( pluginCl . getPluginInformation ( ) ) ; } return AccessController . doPrivileged ( new PrivilegedAction < DelegateClassLoader > ( ) { @ Override public DelegateClassLoader run ( ) { return new DelegateClassLoader ( appClassLoader , delegator , information ) ; } } ) ; }
Creates a new ClassLoader which provides access to all plugins given by the collection of URLs .