mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 06:55:47 +01:00
merge with branch issue-111
This commit is contained in:
@@ -126,13 +126,21 @@ public class BootstrapListener implements ServletContextListener
|
||||
{
|
||||
classLoader = createClassLoader(pluginDirectory, classpath);
|
||||
}
|
||||
else if (logger.isErrorEnabled())
|
||||
{
|
||||
logger.error("classloader is null");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.error(ex.getMessage(), ex);
|
||||
logger.error("could not load classpath from plugin folder", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("no plugin directory found");
|
||||
}
|
||||
|
||||
if (classLoader != null)
|
||||
{
|
||||
@@ -173,6 +181,11 @@ public class BootstrapListener implements ServletContextListener
|
||||
private ClassLoader createClassLoader(File pluginDirectory,
|
||||
Classpath classpath)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("create classloader from plugin classpath");
|
||||
}
|
||||
|
||||
List<URL> classpathURLs = new LinkedList<URL>();
|
||||
|
||||
for (String path : classpath)
|
||||
@@ -188,18 +201,24 @@ public class BootstrapListener implements ServletContextListener
|
||||
{
|
||||
try
|
||||
{
|
||||
URL url = file.toURI().toURL();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("append {} to classpath", file.getPath());
|
||||
logger.debug("append {} to classpath", url.toExternalForm());
|
||||
}
|
||||
|
||||
classpathURLs.add(file.toURI().toURL());
|
||||
classpathURLs.add(url);
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
logger.error(ex.getMessage(), ex);
|
||||
logger.error("could not append url to classpath", ex);
|
||||
}
|
||||
}
|
||||
else if (logger.isErrorEnabled())
|
||||
{
|
||||
logger.error("plugin file {} does not exists", file);
|
||||
}
|
||||
}
|
||||
|
||||
return new URLClassLoader(classpathURLs.toArray(new URL[0]),
|
||||
@@ -220,6 +239,11 @@ public class BootstrapListener implements ServletContextListener
|
||||
|
||||
if (classLoader == null)
|
||||
{
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("could not use context classloader, try to use default");
|
||||
}
|
||||
|
||||
classLoader = BootstrapListener.class.getClassLoader();
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,12 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
|
||||
for (Plugin plugin : installedPlugins)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("search extensions from plugin {}",
|
||||
plugin.getInformation().getId());
|
||||
}
|
||||
|
||||
InputStream input = null;
|
||||
|
||||
try
|
||||
@@ -136,6 +142,17 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
|
||||
if (pluginFile.exists())
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
String type = pluginFile.isDirectory()
|
||||
? "directory"
|
||||
: "jar";
|
||||
|
||||
logger.trace("search extensions in packages {} of {} plugin {}",
|
||||
new Object[] { packageSet,
|
||||
type, pluginFile });
|
||||
}
|
||||
|
||||
if (pluginFile.isDirectory())
|
||||
{
|
||||
scanner.processExtensions(classLoader, extensions, pluginFile,
|
||||
@@ -163,8 +180,18 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("start processing {} extensions", extensions.size());
|
||||
}
|
||||
|
||||
for (ExtensionObject exo : extensions)
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("process extension {}", exo.getExtensionClass());
|
||||
}
|
||||
|
||||
processor.processExtension(exo.getExtension(), exo.getExtensionClass());
|
||||
}
|
||||
}
|
||||
@@ -205,9 +232,14 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.error(ex.getMessage(), ex);
|
||||
logger.error("could not decode path ".concat(path), ex);
|
||||
}
|
||||
}
|
||||
else if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace(
|
||||
"{} seems not to be a file path or the file does not exists", path);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
@@ -232,6 +264,15 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
|
||||
loadPlugin(url);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("loaded {} plugins", installedPlugins.size());
|
||||
}
|
||||
}
|
||||
else if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("no plugin descriptor found");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,6 +286,11 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
{
|
||||
String path = url.toExternalForm();
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("try to load plugin from {}", path);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (path.startsWith("file:"))
|
||||
@@ -266,8 +312,8 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
if (logger.isInfoEnabled())
|
||||
{
|
||||
logger.info("load {}plugin {}", corePlugin
|
||||
? "core "
|
||||
: " ", path);
|
||||
? "core "
|
||||
: " ", path);
|
||||
}
|
||||
|
||||
Plugin plugin = JAXB.unmarshal(url, Plugin.class);
|
||||
@@ -287,6 +333,12 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
}
|
||||
|
||||
plugin.setPath(path);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("add plugin {} to installed plugins", info.getId());
|
||||
}
|
||||
|
||||
installedPlugins.add(plugin);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -298,7 +350,7 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
* TODO create util method
|
||||
*
|
||||
*
|
||||
* @return
|
||||
@@ -309,6 +361,11 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
|
||||
if (classLoader == null)
|
||||
{
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("could not use context classloader, try to use default");
|
||||
}
|
||||
|
||||
classLoader = DefaultPluginManager.class.getClassLoader();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user