Sebastian Sdorra avatar Sebastian Sdorra committed e18be8d Merge

merge with branch issue-111

Comments (0)

Files changed (2)

scm-webapp/src/main/java/sonia/scm/boot/BootstrapListener.java

           {
             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)
     {
   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)
       {
         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]),
 
     if (classLoader == null)
     {
+      if (logger.isWarnEnabled())
+      {
+        logger.warn("could not use context classloader, try to use default");
+      }
+
       classLoader = BootstrapListener.class.getClassLoader();
     }
 

scm-webapp/src/main/java/sonia/scm/plugin/DefaultPluginLoader.java

 
     for (Plugin plugin : installedPlugins)
     {
+      if (logger.isDebugEnabled())
+      {
+        logger.debug("search extensions from plugin {}",
+                     plugin.getInformation().getId());
+      }
+
       InputStream input = null;
 
       try
 
         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,
       }
     }
 
+    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());
     }
   }
       }
       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;
   }
 
         loadPlugin(url);
       }
+
+      if (logger.isDebugEnabled())
+      {
+        logger.debug("loaded {} plugins", installedPlugins.size());
+      }
+    }
+    else if (logger.isWarnEnabled())
+    {
+      logger.warn("no plugin descriptor found");
     }
   }
 
   {
     String path = url.toExternalForm();
 
+    if (logger.isTraceEnabled())
+    {
+      logger.trace("try to load plugin from {}", path);
+    }
+
     try
     {
       if (path.startsWith("file:"))
       if (logger.isInfoEnabled())
       {
         logger.info("load {}plugin {}", corePlugin
-                                        ? "core "
-                                        : " ", path);
+                                         ? "core "
+                                         : " ", path);
       }
 
       Plugin plugin = JAXB.unmarshal(url, Plugin.class);
       }
 
       plugin.setPath(path);
+
+      if (logger.isDebugEnabled())
+      {
+        logger.debug("add plugin {} to installed plugins", info.getId());
+      }
+
       installedPlugins.add(plugin);
     }
     catch (Exception ex)
   //~--- get methods ----------------------------------------------------------
 
   /**
-   * Method description
+   * TODO create util method
    *
    *
    * @return
 
     if (classLoader == null)
     {
+      if (logger.isWarnEnabled())
+      {
+        logger.warn("could not use context classloader, try to use default");
+      }
+
       classLoader = DefaultPluginManager.class.getClassLoader();
     }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.