Bug 464442 - Enable parallel class loading
Change-Id: If23cc99214efe8d3a75d0ab0d337020524b6709f Signed-off-by: Philippe Marschall <philippe.marschall@netcetera.ch>
This commit is contained in:
parent
eee2a53197
commit
fb58ca79c0
|
@ -36,6 +36,11 @@ public class Classpath implements Iterable<File>
|
||||||
{
|
{
|
||||||
private static class Loader extends URLClassLoader
|
private static class Loader extends URLClassLoader
|
||||||
{
|
{
|
||||||
|
static
|
||||||
|
{
|
||||||
|
registerAsParallelCapable();
|
||||||
|
}
|
||||||
|
|
||||||
Loader(URL[] urls, ClassLoader parent)
|
Loader(URL[] urls, ClassLoader parent)
|
||||||
{
|
{
|
||||||
super(urls,parent);
|
super(urls,parent);
|
||||||
|
|
|
@ -65,6 +65,11 @@ import org.eclipse.jetty.util.resource.ResourceCollection;
|
||||||
*/
|
*/
|
||||||
public class WebAppClassLoader extends URLClassLoader
|
public class WebAppClassLoader extends URLClassLoader
|
||||||
{
|
{
|
||||||
|
static
|
||||||
|
{
|
||||||
|
registerAsParallelCapable();
|
||||||
|
}
|
||||||
|
|
||||||
private static final Logger LOG = Log.getLogger(WebAppClassLoader.class);
|
private static final Logger LOG = Log.getLogger(WebAppClassLoader.class);
|
||||||
|
|
||||||
private final Context _context;
|
private final Context _context;
|
||||||
|
@ -404,60 +409,63 @@ public class WebAppClassLoader extends URLClassLoader
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
|
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
|
||||||
{
|
{
|
||||||
Class<?> c= findLoadedClass(name);
|
synchronized (getClassLoadingLock(name))
|
||||||
ClassNotFoundException ex= null;
|
|
||||||
boolean tried_parent= false;
|
|
||||||
|
|
||||||
boolean system_class=_context.isSystemClass(name);
|
|
||||||
boolean server_class=_context.isServerClass(name);
|
|
||||||
|
|
||||||
if (system_class && server_class)
|
|
||||||
{
|
{
|
||||||
return null;
|
Class<?> c= findLoadedClass(name);
|
||||||
}
|
ClassNotFoundException ex= null;
|
||||||
|
boolean tried_parent= false;
|
||||||
if (c == null && _parent!=null && (_context.isParentLoaderPriority() || system_class) && !server_class)
|
|
||||||
{
|
boolean system_class=_context.isSystemClass(name);
|
||||||
tried_parent= true;
|
boolean server_class=_context.isServerClass(name);
|
||||||
try
|
|
||||||
|
if (system_class && server_class)
|
||||||
{
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == null && _parent!=null && (_context.isParentLoaderPriority() || system_class) && !server_class)
|
||||||
|
{
|
||||||
|
tried_parent= true;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
c= _parent.loadClass(name);
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("loaded " + c);
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException e)
|
||||||
|
{
|
||||||
|
ex= e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
c= this.findClass(name);
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException e)
|
||||||
|
{
|
||||||
|
ex= e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == null && _parent!=null && !tried_parent && !server_class )
|
||||||
c= _parent.loadClass(name);
|
c= _parent.loadClass(name);
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("loaded " + c);
|
if (c == null && ex!=null)
|
||||||
}
|
throw ex;
|
||||||
catch (ClassNotFoundException e)
|
|
||||||
{
|
if (resolve)
|
||||||
ex= e;
|
resolveClass(c);
|
||||||
}
|
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("loaded {} from {}",c,c==null?null:c.getClassLoader());
|
||||||
|
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
c= this.findClass(name);
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException e)
|
|
||||||
{
|
|
||||||
ex= e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c == null && _parent!=null && !tried_parent && !server_class )
|
|
||||||
c= _parent.loadClass(name);
|
|
||||||
|
|
||||||
if (c == null && ex!=null)
|
|
||||||
throw ex;
|
|
||||||
|
|
||||||
if (resolve)
|
|
||||||
resolveClass(c);
|
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("loaded {} from {}",c,c==null?null:c.getClassLoader());
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
Loading…
Reference in New Issue