use ClassLoaders util class to get context classloader

This commit is contained in:
Sebastian Sdorra
2014-03-18 16:22:38 +01:00
parent b069cb2041
commit 3f6f08fda4

View File

@@ -54,6 +54,7 @@ import sonia.scm.plugin.ext.Extension;
import sonia.scm.plugin.ext.ExtensionBinder;
import sonia.scm.plugin.ext.ExtensionProcessor;
import sonia.scm.plugin.ext.Extensions;
import sonia.scm.util.ClassLoaders;
import sonia.scm.util.IOUtil;
import sonia.scm.web.security.DefaultAuthenticationHandler;
@@ -123,7 +124,8 @@ public class DefaultPluginLoader implements PluginLoader
this.servletContext = servletContext;
this.annotationScannerFactory = new DefaultAnnotationScannerFactory();
ClassLoader classLoader = getClassLoader();
ClassLoader classLoader =
ClassLoaders.getContextClassLoader(DefaultPluginLoader.class);
try
{
@@ -502,7 +504,8 @@ public class DefaultPluginLoader implements PluginLoader
*/
private void scanForAnnotations()
{
ClassLoader classLoader = getClassLoader();
ClassLoader classLoader =
ClassLoaders.getContextClassLoader(DefaultPluginLoader.class);
AnnotationCollector<ExtensionPoint> extensionPointCollector =
new AnnotationCollector<ExtensionPoint>();
@@ -610,31 +613,6 @@ public class DefaultPluginLoader implements PluginLoader
}
}
//~--- get methods ----------------------------------------------------------
/**
* TODO create util method
*
*
* @return
*/
private ClassLoader getClassLoader()
{
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null)
{
if (logger.isWarnEnabled())
{
logger.warn("could not use context classloader, try to use default");
}
classLoader = DefaultPluginManager.class.getClassLoader();
}
return classLoader;
}
//~--- fields ---------------------------------------------------------------
/** Field description */