diff --git a/plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitWebPlugin.java b/plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitWebPlugin.java
index c7eb3113cf..bdc41f58e1 100644
--- a/plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitWebPlugin.java
+++ b/plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitWebPlugin.java
@@ -9,6 +9,9 @@ package sonia.scm.web;
//~--- non-JDK imports --------------------------------------------------------
+import sonia.scm.web.plugin.ClasspathWebResource;
+import sonia.scm.web.plugin.ScmWebPlugin;
+import sonia.scm.web.plugin.ScmWebPluginContext;
import com.google.inject.servlet.ServletModule;
import sonia.scm.web.filter.BasicAuthenticationFilter;
diff --git a/plugins/scm-git-plugin/src/main/resources/META-INF/scm/plugin.xml b/plugins/scm-git-plugin/src/main/resources/META-INF/scm/plugin.xml
index b9f1986fe8..a69719cad1 100644
--- a/plugins/scm-git-plugin/src/main/resources/META-INF/scm/plugin.xml
+++ b/plugins/scm-git-plugin/src/main/resources/META-INF/scm/plugin.xml
@@ -10,8 +10,10 @@
-
- sonia.scm.repository.GitRepositoryHandler
-
+ sonia.scm.web.GitWebPlugin
+
+
+ sonia.scm.repository.GitRepositoryHandler
+
diff --git a/plugins/scm-hg-plugin/src/main/java/sonia/scm/web/HgWebPlugin.java b/plugins/scm-hg-plugin/src/main/java/sonia/scm/web/HgWebPlugin.java
index dea962509a..b5f794d7f3 100644
--- a/plugins/scm-hg-plugin/src/main/java/sonia/scm/web/HgWebPlugin.java
+++ b/plugins/scm-hg-plugin/src/main/java/sonia/scm/web/HgWebPlugin.java
@@ -7,6 +7,10 @@
package sonia.scm.web;
+import sonia.scm.web.plugin.ScmWebPluginContext;
+import sonia.scm.web.plugin.ScmWebPlugin;
+import sonia.scm.web.plugin.ClasspathWebResource;
+
/**
*
* @author Sebastian Sdorra
diff --git a/plugins/scm-hg-plugin/src/main/resources/META-INF/scm/plugin.xml b/plugins/scm-hg-plugin/src/main/resources/META-INF/scm/plugin.xml
index 2ade20e967..467dcebdd7 100644
--- a/plugins/scm-hg-plugin/src/main/resources/META-INF/scm/plugin.xml
+++ b/plugins/scm-hg-plugin/src/main/resources/META-INF/scm/plugin.xml
@@ -10,8 +10,10 @@
-
- sonia.scm.repository.HgRepositoryHandler
-
+ sonia.scm.web.HgWebPlugin
+
+
+ sonia.scm.repository.HgRepositoryHandler
+
diff --git a/plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnWebPlugin.java b/plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnWebPlugin.java
index d61927c9c3..4041fc1efe 100644
--- a/plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnWebPlugin.java
+++ b/plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnWebPlugin.java
@@ -7,6 +7,10 @@
package sonia.scm.web;
+import sonia.scm.web.plugin.ScmWebPlugin;
+import sonia.scm.web.plugin.ScmWebPluginContext;
+import sonia.scm.web.plugin.ClasspathWebResource;
+
/**
*
* @author Sebastian Sdorra
diff --git a/plugins/scm-svn-plugin/src/main/resources/META-INF/scm/plugin.xml b/plugins/scm-svn-plugin/src/main/resources/META-INF/scm/plugin.xml
index 307d22a9f9..c700c2bae5 100644
--- a/plugins/scm-svn-plugin/src/main/resources/META-INF/scm/plugin.xml
+++ b/plugins/scm-svn-plugin/src/main/resources/META-INF/scm/plugin.xml
@@ -10,8 +10,10 @@
+ sonia.scm.web.SvnWebPlugin
+
- sonia.scm.repository.SvnRepositoryHandler
+ sonia.scm.repository.SvnRepositoryHandler
diff --git a/scm-web-api/src/main/java/sonia/scm/web/ClasspathWebResource.java b/scm-web-api/src/main/java/sonia/scm/web/plugin/ClasspathWebResource.java
similarity index 96%
rename from scm-web-api/src/main/java/sonia/scm/web/ClasspathWebResource.java
rename to scm-web-api/src/main/java/sonia/scm/web/plugin/ClasspathWebResource.java
index d97d37c17a..c38b15ea48 100644
--- a/scm-web-api/src/main/java/sonia/scm/web/ClasspathWebResource.java
+++ b/scm-web-api/src/main/java/sonia/scm/web/plugin/ClasspathWebResource.java
@@ -5,7 +5,7 @@
-package sonia.scm.web;
+package sonia.scm.web.plugin;
//~--- JDK imports ------------------------------------------------------------
diff --git a/scm-core/src/main/java/sonia/scm/plugin/SCMPlugin.java b/scm-web-api/src/main/java/sonia/scm/web/plugin/SCMPlugin.java
similarity index 65%
rename from scm-core/src/main/java/sonia/scm/plugin/SCMPlugin.java
rename to scm-web-api/src/main/java/sonia/scm/web/plugin/SCMPlugin.java
index ef3d7ca287..d2b6807c97 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/SCMPlugin.java
+++ b/scm-web-api/src/main/java/sonia/scm/web/plugin/SCMPlugin.java
@@ -5,7 +5,7 @@
-package sonia.scm.plugin;
+package sonia.scm.web.plugin;
//~--- non-JDK imports --------------------------------------------------------
@@ -82,10 +82,64 @@ public class SCMPlugin
return handlers;
}
+ /**
+ * Method description
+ *
+ *
+ * @return
+ */
+ public SecurityConfig getSecurityConfig()
+ {
+ return securityConfig;
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ */
+ public Class extends ScmWebPlugin> getWebPlugin()
+ {
+ return webPlugin;
+ }
+
+ //~--- set methods ----------------------------------------------------------
+
+ /**
+ * Method description
+ *
+ *
+ * @param securityConfig
+ */
+ public void setSecurityConfig(SecurityConfig securityConfig)
+ {
+ this.securityConfig = securityConfig;
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @param webPlugin
+ */
+ public void setWebPlugin(Class extends ScmWebPlugin> webPlugin)
+ {
+ this.webPlugin = webPlugin;
+ }
+
//~--- fields ---------------------------------------------------------------
/** Field description */
@XmlElementWrapper(name = "repository-handlers")
- @XmlElement(name = "handler")
+ @XmlElement(name = "repository-handler")
private Set> handlers;
+
+ /** Field description */
+ @XmlElement(name = "security")
+ private SecurityConfig securityConfig;
+
+ /** Field description */
+ @XmlElement(name = "web-plugin")
+ private Class extends ScmWebPlugin> webPlugin;
}
diff --git a/scm-core/src/main/java/sonia/scm/plugin/SCMPluginManager.java b/scm-web-api/src/main/java/sonia/scm/web/plugin/SCMPluginManager.java
similarity index 74%
rename from scm-core/src/main/java/sonia/scm/plugin/SCMPluginManager.java
rename to scm-web-api/src/main/java/sonia/scm/web/plugin/SCMPluginManager.java
index 15dfa1ad27..4a1b272f50 100644
--- a/scm-core/src/main/java/sonia/scm/plugin/SCMPluginManager.java
+++ b/scm-web-api/src/main/java/sonia/scm/web/plugin/SCMPluginManager.java
@@ -5,25 +5,21 @@
-package sonia.scm.plugin;
+package sonia.scm.web.plugin;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import sonia.scm.repository.RepositoryHandler;
-import sonia.scm.util.Util;
-
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.net.URL;
-import java.util.Collection;
import java.util.Enumeration;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Set;
import javax.xml.bind.JAXB;
@@ -42,17 +38,6 @@ public class SCMPluginManager
private static final Logger logger =
LoggerFactory.getLogger(SCMPluginManager.class);
- //~--- constructors ---------------------------------------------------------
-
- /**
- * Constructs ...
- *
- */
- public SCMPluginManager()
- {
- repositoryHandlers = new HashSet>();
- }
-
//~--- methods --------------------------------------------------------------
/**
@@ -104,9 +89,9 @@ public class SCMPluginManager
*
* @return
*/
- public Set> getRepositoryHandlers()
+ public Set getPlugins()
{
- return repositoryHandlers;
+ return plugins;
}
//~--- methods --------------------------------------------------------------
@@ -122,13 +107,13 @@ public class SCMPluginManager
try
{
SCMPlugin plugin = JAXB.unmarshal(url, SCMPlugin.class);
- Collection> handlers =
- plugin.getHandlers();
- if (Util.isNotEmpty(handlers))
+ if (logger.isInfoEnabled())
{
- repositoryHandlers.addAll(handlers);
+ logger.info("load plugin {}", url.toExternalForm());
}
+
+ plugins.add(plugin);
}
catch (Exception ex)
{
@@ -139,5 +124,5 @@ public class SCMPluginManager
//~--- fields ---------------------------------------------------------------
/** Field description */
- private Set> repositoryHandlers;
+ private Set plugins = new LinkedHashSet();
}
diff --git a/scm-web-api/src/main/java/sonia/scm/web/ScmWebPlugin.java b/scm-web-api/src/main/java/sonia/scm/web/plugin/ScmWebPlugin.java
similarity index 93%
rename from scm-web-api/src/main/java/sonia/scm/web/ScmWebPlugin.java
rename to scm-web-api/src/main/java/sonia/scm/web/plugin/ScmWebPlugin.java
index 663e84ce67..019d48faca 100644
--- a/scm-web-api/src/main/java/sonia/scm/web/ScmWebPlugin.java
+++ b/scm-web-api/src/main/java/sonia/scm/web/plugin/ScmWebPlugin.java
@@ -5,7 +5,7 @@
-package sonia.scm.web;
+package sonia.scm.web.plugin;
/**
*
diff --git a/scm-web-api/src/main/java/sonia/scm/web/ScmWebPluginContext.java b/scm-web-api/src/main/java/sonia/scm/web/plugin/ScmWebPluginContext.java
similarity index 98%
rename from scm-web-api/src/main/java/sonia/scm/web/ScmWebPluginContext.java
rename to scm-web-api/src/main/java/sonia/scm/web/plugin/ScmWebPluginContext.java
index a88e381984..b447794f01 100644
--- a/scm-web-api/src/main/java/sonia/scm/web/ScmWebPluginContext.java
+++ b/scm-web-api/src/main/java/sonia/scm/web/plugin/ScmWebPluginContext.java
@@ -5,7 +5,7 @@
-package sonia.scm.web;
+package sonia.scm.web.plugin;
//~--- non-JDK imports --------------------------------------------------------
diff --git a/scm-web-api/src/main/java/sonia/scm/web/plugin/SecurityConfig.java b/scm-web-api/src/main/java/sonia/scm/web/plugin/SecurityConfig.java
new file mode 100644
index 0000000000..77fa536920
--- /dev/null
+++ b/scm-web-api/src/main/java/sonia/scm/web/plugin/SecurityConfig.java
@@ -0,0 +1,85 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+
+
+package sonia.scm.web.plugin;
+
+//~--- non-JDK imports --------------------------------------------------------
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import sonia.scm.security.EncryptionHandler;
+import sonia.scm.web.security.Authenticator;
+
+//~--- JDK imports ------------------------------------------------------------
+
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ *
+ * @author Sebastian Sdorra
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+public class SecurityConfig
+{
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ */
+ public Class extends Authenticator> getAuthenticator()
+ {
+ return authenticator;
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @return
+ */
+ public Class extends EncryptionHandler> getEncryptionHandler()
+ {
+ return encryptionHandler;
+ }
+
+ //~--- set methods ----------------------------------------------------------
+
+ /**
+ * Method description
+ *
+ *
+ * @param authenticator
+ */
+ public void setAuthenticator(Class extends Authenticator> authenticator)
+ {
+ this.authenticator = authenticator;
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @param encryptionHandler
+ */
+ public void setEncryptionHandler(
+ Class extends EncryptionHandler> encryptionHandler)
+ {
+ this.encryptionHandler = encryptionHandler;
+ }
+
+ //~--- fields ---------------------------------------------------------------
+
+ /** Field description */
+ @XmlElement(name = "authenticator")
+ private Class extends Authenticator> authenticator;
+
+ /** Field description */
+ @XmlElement(name = "encryption-handler")
+ private Class extends EncryptionHandler> encryptionHandler;
+}
diff --git a/scm-web-api/src/main/java/sonia/scm/web/WebResource.java b/scm-web-api/src/main/java/sonia/scm/web/plugin/WebResource.java
similarity index 93%
rename from scm-web-api/src/main/java/sonia/scm/web/WebResource.java
rename to scm-web-api/src/main/java/sonia/scm/web/plugin/WebResource.java
index 6abfbc1774..30c7e63c8e 100644
--- a/scm-web-api/src/main/java/sonia/scm/web/WebResource.java
+++ b/scm-web-api/src/main/java/sonia/scm/web/plugin/WebResource.java
@@ -5,7 +5,7 @@
-package sonia.scm.web;
+package sonia.scm.web.plugin;
//~--- JDK imports ------------------------------------------------------------
diff --git a/scm-web-api/src/test/java/sonia/test/PluginTest.java b/scm-web-api/src/test/java/sonia/test/PluginTest.java
new file mode 100644
index 0000000000..f7af56c600
--- /dev/null
+++ b/scm-web-api/src/test/java/sonia/test/PluginTest.java
@@ -0,0 +1,228 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package sonia.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.bind.JAXB;
+import org.junit.Test;
+import sonia.scm.ConfigChangedListener;
+import sonia.scm.SCMContextProvider;
+import sonia.scm.User;
+import sonia.scm.repository.Repository;
+import sonia.scm.repository.RepositoryException;
+import sonia.scm.repository.RepositoryHandler;
+import sonia.scm.repository.RepositoryType;
+import sonia.scm.security.EncryptionHandler;
+import sonia.scm.web.plugin.SCMPlugin;
+import sonia.scm.web.plugin.SecurityConfig;
+import sonia.scm.web.security.Authenticator;
+
+/**
+ *
+ * @author Sebastian Sdorra
+ */
+public class PluginTest {
+
+ @Test
+ public void test()
+ {
+ SCMPlugin plugin = new SCMPlugin();
+ plugin.addHandler( DemoRepositoryHandler.class );
+ plugin.addHandler(OtherRepositoryHandler.class);
+ SecurityConfig config = new SecurityConfig();
+ config.setAuthenticator( DemoAuthenticator.class );
+ config.setEncryptionHandler( EncryptionHandler.class );
+ plugin.setSecurityConfig( config );
+ JAXB.marshal(plugin, new File("/tmp/test.xml"));
+ }
+
+ static class DemoAuthenticator implements Authenticator {
+
+ @Override
+ public User authenticate(HttpServletRequest request, HttpServletResponse response, String username, String password)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void init(SCMContextProvider context)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ }
+
+ static class DemoEncryptionHander implements EncryptionHandler {
+
+ @Override
+ public String encrypt(String value)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ }
+
+ static class OtherRepositoryHandler implements RepositoryHandler {
+
+ @Override
+ public RepositoryType getType()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isConfigured()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void create(Repository object) throws RepositoryException, IOException
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void delete(Repository object) throws RepositoryException, IOException
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void modify(Repository object) throws RepositoryException, IOException
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void refresh(Repository object) throws RepositoryException, IOException
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Repository get(String id)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Collection getAll()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void init(SCMContextProvider context)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void addListener(ConfigChangedListener listener)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void removeListener(ConfigChangedListener listener)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ }
+
+ static class DemoRepositoryHandler implements RepositoryHandler {
+
+ @Override
+ public RepositoryType getType()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isConfigured()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void create(Repository object) throws RepositoryException, IOException
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void delete(Repository object) throws RepositoryException, IOException
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void modify(Repository object) throws RepositoryException, IOException
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void refresh(Repository object) throws RepositoryException, IOException
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Repository get(String id)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Collection getAll()
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void init(SCMContextProvider context)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void addListener(ConfigChangedListener listener)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void removeListener(ConfigChangedListener listener)
+ {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ }
+
+}
diff --git a/scm-webapp/src/main/java/sonia/scm/ContextListener.java b/scm-webapp/src/main/java/sonia/scm/ContextListener.java
index 1ce295edde..c69a0a2f70 100644
--- a/scm-webapp/src/main/java/sonia/scm/ContextListener.java
+++ b/scm-webapp/src/main/java/sonia/scm/ContextListener.java
@@ -14,20 +14,29 @@ import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.servlet.GuiceServletContextListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import sonia.scm.repository.RepositoryManager;
import sonia.scm.util.ServiceUtil;
import sonia.scm.util.Util;
-import sonia.scm.web.ScmWebPlugin;
-import sonia.scm.web.ScmWebPluginContext;
+import sonia.scm.web.plugin.SCMPlugin;
+import sonia.scm.web.plugin.SCMPluginManager;
+import sonia.scm.web.plugin.ScmWebPlugin;
+import sonia.scm.web.plugin.ScmWebPluginContext;
+import sonia.scm.web.security.Authenticator;
//~--- JDK imports ------------------------------------------------------------
+import java.io.IOException;
+
import java.util.ArrayList;
import java.util.Collection;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Set;
import javax.servlet.ServletContextEvent;
-import sonia.scm.web.security.Authenticator;
/**
*
@@ -36,6 +45,12 @@ import sonia.scm.web.security.Authenticator;
public class ContextListener extends GuiceServletContextListener
{
+ /** the logger for ContextListener */
+ private static final Logger logger =
+ LoggerFactory.getLogger(ContextListener.class);
+
+ //~--- methods --------------------------------------------------------------
+
/**
* Method description
*
@@ -45,9 +60,7 @@ public class ContextListener extends GuiceServletContextListener
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent)
{
- List plugins = ServiceUtil.getServices(ScmWebPlugin.class);
-
- for (ScmWebPlugin plugin : plugins)
+ for (ScmWebPlugin plugin : webPluginSet)
{
plugin.contextDestroyed(webPluginContext);
}
@@ -64,14 +77,38 @@ public class ContextListener extends GuiceServletContextListener
@Override
public void contextInitialized(ServletContextEvent servletContextEvent)
{
- webPluginContext =
- new ScmWebPluginContext(servletContextEvent.getServletContext());
+ pluginManager = new SCMPluginManager();
- List plugins = ServiceUtil.getServices(ScmWebPlugin.class);
-
- for (ScmWebPlugin plugin : plugins)
+ try
{
- plugin.contextInitialized(webPluginContext);
+ pluginManager.load();
+ webPluginContext =
+ new ScmWebPluginContext(servletContextEvent.getServletContext());
+
+ for (SCMPlugin plugin : pluginManager.getPlugins())
+ {
+ try
+ {
+ webPluginSet.add(plugin.getWebPlugin().newInstance());
+ }
+ catch (InstantiationException ex)
+ {
+ logger.error(ex.getMessage(), ex);
+ }
+ catch (IllegalAccessException ex)
+ {
+ logger.error(ex.getMessage(), ex);
+ }
+ }
+
+ for (ScmWebPlugin plugin : webPluginSet)
+ {
+ plugin.contextInitialized(webPluginContext);
+ }
+ }
+ catch (IOException ex)
+ {
+ throw new RuntimeException(ex);
}
super.contextInitialized(servletContextEvent);
@@ -112,6 +149,12 @@ public class ContextListener extends GuiceServletContextListener
//~--- fields ---------------------------------------------------------------
+ /** Field description */
+ private SCMPluginManager pluginManager;
+
/** Field description */
private ScmWebPluginContext webPluginContext;
+
+ /** Field description */
+ private Set webPluginSet = new LinkedHashSet();
}
diff --git a/scm-webapp/src/main/java/sonia/scm/ScmServletModule.java b/scm-webapp/src/main/java/sonia/scm/ScmServletModule.java
index a4dab4249e..9c3e7c2176 100644
--- a/scm-webapp/src/main/java/sonia/scm/ScmServletModule.java
+++ b/scm-webapp/src/main/java/sonia/scm/ScmServletModule.java
@@ -20,7 +20,6 @@ import sonia.scm.cache.CacheManager;
import sonia.scm.cache.CacheRepositoryManagerDecorator;
import sonia.scm.cache.EhCacheManager;
import sonia.scm.filter.SecurityFilter;
-import sonia.scm.plugin.SCMPluginManager;
import sonia.scm.plugin.ScriptResourceServlet;
import sonia.scm.repository.BasicRepositoryManager;
import sonia.scm.repository.RepositoryHandler;
@@ -28,7 +27,10 @@ import sonia.scm.repository.RepositoryManager;
import sonia.scm.security.EncryptionHandler;
import sonia.scm.security.MessageDigestEncryptionHandler;
import sonia.scm.util.DebugServlet;
-import sonia.scm.web.ScmWebPluginContext;
+import sonia.scm.util.Util;
+import sonia.scm.web.plugin.SCMPlugin;
+import sonia.scm.web.plugin.SCMPluginManager;
+import sonia.scm.web.plugin.ScmWebPluginContext;
import sonia.scm.web.security.Authenticator;
import sonia.scm.web.security.BasicSecurityContext;
import sonia.scm.web.security.SecurityContext;
@@ -43,8 +45,11 @@ import com.sun.jersey.spi.container.servlet.ServletContainer;
import java.io.IOException;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedHashSet;
import java.util.Map;
+import java.util.Set;
/**
*
@@ -117,8 +122,6 @@ public class ScmServletModule extends ServletModule
bind(Authenticator.class).to(XmlAuthenticator.class);
bind(SecurityContext.class).to(BasicSecurityContext.class);
- Multibinder repositoryHandlerBinder =
- Multibinder.newSetBinder(binder(), RepositoryHandler.class);
SCMPluginManager pluginManager = new SCMPluginManager();
try
@@ -130,13 +133,7 @@ public class ScmServletModule extends ServletModule
logger.error(ex.getMessage(), ex);
}
- for (Class extends RepositoryHandler> handler :
- pluginManager.getRepositoryHandlers())
- {
- bind(handler);
- repositoryHandlerBinder.addBinding().to(handler);
- }
-
+ loadPlugins(pluginManager);
bind(CacheManager.class).to(EhCacheManager.class);
bind(RepositoryManager.class).annotatedWith(Undecorated.class).to(
BasicRepositoryManager.class);
@@ -175,6 +172,61 @@ public class ScmServletModule extends ServletModule
serve(PATTERN_RESTAPI).with(GuiceContainer.class, params);
}
+ /**
+ * Method description
+ *
+ *
+ * @param repositoryHandlerBinder
+ * @param handlerSet
+ */
+ private void bindRepositoryHandlers(
+ Multibinder repositoryHandlerBinder,
+ Set> handlerSet)
+ {
+ for (Class extends RepositoryHandler> handlerClass : handlerSet)
+ {
+ if (logger.isInfoEnabled())
+ {
+ logger.info("load RepositoryHandler {}", handlerClass.getName());
+ }
+
+ bind(handlerClass);
+ repositoryHandlerBinder.addBinding().to(handlerClass);
+ }
+ }
+
+ /**
+ * Method description
+ *
+ *
+ * @param pluginManager
+ */
+ private void loadPlugins(SCMPluginManager pluginManager)
+ {
+ Set pluginSet = pluginManager.getPlugins();
+
+ if (Util.isNotEmpty(pluginSet))
+ {
+ Multibinder repositoryHandlerBinder =
+ Multibinder.newSetBinder(binder(), RepositoryHandler.class);
+ Set> handlerSet =
+ new LinkedHashSet>();
+
+ for (SCMPlugin plugin : pluginSet)
+ {
+ Collection> handlers =
+ plugin.getHandlers();
+
+ if (Util.isNotEmpty(handlers))
+ {
+ handlerSet.addAll(handlers);
+ }
+ }
+
+ bindRepositoryHandlers(repositoryHandlerBinder, handlerSet);
+ }
+ }
+
//~--- fields ---------------------------------------------------------------
/** Field description */
diff --git a/scm-webapp/src/main/java/sonia/scm/plugin/ScriptResourceServlet.java b/scm-webapp/src/main/java/sonia/scm/plugin/ScriptResourceServlet.java
index 08b1888eec..dc34c61d2c 100644
--- a/scm-webapp/src/main/java/sonia/scm/plugin/ScriptResourceServlet.java
+++ b/scm-webapp/src/main/java/sonia/scm/plugin/ScriptResourceServlet.java
@@ -14,8 +14,8 @@ import com.google.inject.Singleton;
import sonia.scm.util.IOUtil;
import sonia.scm.util.Util;
-import sonia.scm.web.ScmWebPluginContext;
-import sonia.scm.web.WebResource;
+import sonia.scm.web.plugin.ScmWebPluginContext;
+import sonia.scm.web.plugin.WebResource;
//~--- JDK imports ------------------------------------------------------------
diff --git a/scm-webapp/src/main/java/sonia/scm/web/security/XmlAuthenticator.java b/scm-webapp/src/main/java/sonia/scm/web/security/XmlAuthenticator.java
index ea19d7f5e3..0f4b2a033d 100644
--- a/scm-webapp/src/main/java/sonia/scm/web/security/XmlAuthenticator.java
+++ b/scm-webapp/src/main/java/sonia/scm/web/security/XmlAuthenticator.java
@@ -71,9 +71,6 @@ public class XmlAuthenticator implements Authenticator
String encryptedPassword = encryptionHandler.encrypt(password);
- System.out.println(encryptedPassword);
- System.out.println(user.getPassword());
-
if (!encryptedPassword.equalsIgnoreCase(user.getPassword()))
{
user = null;