mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
improve logging for loading of plugins
This commit is contained in:
@@ -126,13 +126,21 @@ public class BootstrapListener implements ServletContextListener
|
|||||||
{
|
{
|
||||||
classLoader = createClassLoader(pluginDirectory, classpath);
|
classLoader = createClassLoader(pluginDirectory, classpath);
|
||||||
}
|
}
|
||||||
|
else if (logger.isErrorEnabled())
|
||||||
|
{
|
||||||
|
logger.error("classloader is null");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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)
|
if (classLoader != null)
|
||||||
{
|
{
|
||||||
@@ -173,6 +181,11 @@ public class BootstrapListener implements ServletContextListener
|
|||||||
private ClassLoader createClassLoader(File pluginDirectory,
|
private ClassLoader createClassLoader(File pluginDirectory,
|
||||||
Classpath classpath)
|
Classpath classpath)
|
||||||
{
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("create classloader from plugin classpath");
|
||||||
|
}
|
||||||
|
|
||||||
List<URL> classpathURLs = new LinkedList<URL>();
|
List<URL> classpathURLs = new LinkedList<URL>();
|
||||||
|
|
||||||
for (String path : classpath)
|
for (String path : classpath)
|
||||||
@@ -188,18 +201,24 @@ public class BootstrapListener implements ServletContextListener
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
URL url = file.toURI().toURL();
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
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)
|
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]),
|
return new URLClassLoader(classpathURLs.toArray(new URL[0]),
|
||||||
@@ -220,6 +239,11 @@ public class BootstrapListener implements ServletContextListener
|
|||||||
|
|
||||||
if (classLoader == null)
|
if (classLoader == null)
|
||||||
{
|
{
|
||||||
|
if (logger.isWarnEnabled())
|
||||||
|
{
|
||||||
|
logger.warn("could not use context classloader, try to use default");
|
||||||
|
}
|
||||||
|
|
||||||
classLoader = BootstrapListener.class.getClassLoader();
|
classLoader = BootstrapListener.class.getClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,12 @@ public class DefaultPluginLoader implements PluginLoader
|
|||||||
|
|
||||||
for (Plugin plugin : installedPlugins)
|
for (Plugin plugin : installedPlugins)
|
||||||
{
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("search extensions from plugin {}",
|
||||||
|
plugin.getInformation().getId());
|
||||||
|
}
|
||||||
|
|
||||||
InputStream input = null;
|
InputStream input = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -136,6 +142,17 @@ public class DefaultPluginLoader implements PluginLoader
|
|||||||
|
|
||||||
if (pluginFile.exists())
|
if (pluginFile.exists())
|
||||||
{
|
{
|
||||||
|
if (logger.isTraceEnabled())
|
||||||
|
{
|
||||||
|
String type = pluginFile.isDirectory()
|
||||||
|
? "directory"
|
||||||
|
: "jar";
|
||||||
|
|
||||||
|
logger.trace("search extensions in packages {} of {} plugin {}",
|
||||||
|
new Object[] { extensions,
|
||||||
|
type, pluginFile });
|
||||||
|
}
|
||||||
|
|
||||||
if (pluginFile.isDirectory())
|
if (pluginFile.isDirectory())
|
||||||
{
|
{
|
||||||
scanner.processExtensions(classLoader, extensions, pluginFile,
|
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)
|
for (ExtensionObject exo : extensions)
|
||||||
{
|
{
|
||||||
|
if (logger.isTraceEnabled())
|
||||||
|
{
|
||||||
|
logger.trace("process extension {}", exo.getExtensionClass());
|
||||||
|
}
|
||||||
|
|
||||||
processor.processExtension(exo.getExtension(), exo.getExtensionClass());
|
processor.processExtension(exo.getExtension(), exo.getExtensionClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,9 +232,14 @@ public class DefaultPluginLoader implements PluginLoader
|
|||||||
}
|
}
|
||||||
catch (IOException ex)
|
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;
|
return path;
|
||||||
}
|
}
|
||||||
@@ -232,6 +264,15 @@ public class DefaultPluginLoader implements PluginLoader
|
|||||||
|
|
||||||
loadPlugin(url);
|
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();
|
String path = url.toExternalForm();
|
||||||
|
|
||||||
|
if (logger.isTraceEnabled())
|
||||||
|
{
|
||||||
|
logger.trace("try to load plugin from {}", path);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (path.startsWith("file:"))
|
if (path.startsWith("file:"))
|
||||||
@@ -265,7 +311,7 @@ public class DefaultPluginLoader implements PluginLoader
|
|||||||
|
|
||||||
if (logger.isInfoEnabled())
|
if (logger.isInfoEnabled())
|
||||||
{
|
{
|
||||||
logger.info("load {}plugin {}", corePlugin
|
logger.info("load {} plugin {}", corePlugin
|
||||||
? "core "
|
? "core "
|
||||||
: " ", path);
|
: " ", path);
|
||||||
}
|
}
|
||||||
@@ -287,6 +333,12 @@ public class DefaultPluginLoader implements PluginLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugin.setPath(path);
|
plugin.setPath(path);
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("add plugin {} to installed plugins", info.getId());
|
||||||
|
}
|
||||||
|
|
||||||
installedPlugins.add(plugin);
|
installedPlugins.add(plugin);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -298,7 +350,7 @@ public class DefaultPluginLoader implements PluginLoader
|
|||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* TODO create util method
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
@@ -309,6 +361,11 @@ public class DefaultPluginLoader implements PluginLoader
|
|||||||
|
|
||||||
if (classLoader == null)
|
if (classLoader == null)
|
||||||
{
|
{
|
||||||
|
if (logger.isWarnEnabled())
|
||||||
|
{
|
||||||
|
logger.warn("could not use context classloader, try to use default");
|
||||||
|
}
|
||||||
|
|
||||||
classLoader = DefaultPluginManager.class.getClassLoader();
|
classLoader = DefaultPluginManager.class.getClassLoader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user