Introduce extension point for further protocol implementations

This commit is contained in:
René Pfeuffer
2018-09-13 10:35:10 +02:00
parent 7c76f7a699
commit 145502a7b8
19 changed files with 137 additions and 153 deletions

View File

@@ -38,10 +38,8 @@ import com.google.common.io.Closeables;
import sonia.scm.repository.Repository;
import sonia.scm.repository.SvnRepositoryHandler;
import sonia.scm.repository.api.Command;
import sonia.scm.repository.api.ScmProtocol;
import java.io.IOException;
import java.util.Collections;
import java.util.Set;
/**
@@ -61,18 +59,10 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
* @param handler
* @param repository
* @param httpScmProtocol
*/
SvnRepositoryServiceProvider(SvnRepositoryHandler handler,
Repository repository, HttpScmProtocol httpScmProtocol)
Repository repository)
{
this.repository = repository;
this.httpScmProtocol = httpScmProtocol;
this.context = new SvnContext(handler.getDirectory(repository));
}
@@ -188,11 +178,6 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
return new SvnUnbundleCommand(context, repository);
}
@Override
public Set<ScmProtocol> getSupportedProtocols() {
return Collections.singleton(httpScmProtocol);
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@@ -200,6 +185,4 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
/** Field description */
private final Repository repository;
private final HttpScmProtocol httpScmProtocol;
}

View File

@@ -36,17 +36,17 @@ import com.google.inject.Inject;
import sonia.scm.plugin.Extension;
import sonia.scm.repository.Repository;
import sonia.scm.repository.SvnRepositoryHandler;
import sonia.scm.web.SvnScmProtocolProviderWrapper;
@Extension
public class SvnRepositoryServiceResolver implements RepositoryServiceResolver {
public static final String TYPE = "svn";
private SvnRepositoryHandler handler;
@Inject
public SvnRepositoryServiceResolver(SvnRepositoryHandler handler, SvnScmProtocolProviderWrapper protocolWrapper) {
public SvnRepositoryServiceResolver(SvnRepositoryHandler handler) {
this.handler = handler;
this.protocolWrapper = protocolWrapper;
}
@Override
@@ -54,13 +54,9 @@ public class SvnRepositoryServiceResolver implements RepositoryServiceResolver {
SvnRepositoryServiceProvider provider = null;
if (TYPE.equalsIgnoreCase(repository.getType())) {
provider = new SvnRepositoryServiceProvider(handler, repository, protocolWrapper.get(repository));
provider = new SvnRepositoryServiceProvider(handler, repository);
}
return provider;
}
private SvnRepositoryHandler handler;
private final InitializingHttpScmProtocolWrapper protocolWrapper;
}

View File

@@ -2,6 +2,7 @@ package sonia.scm.web;
import sonia.scm.api.v2.resources.ScmPathInfoStore;
import sonia.scm.config.ScmConfiguration;
import sonia.scm.plugin.Extension;
import sonia.scm.repository.spi.InitializingHttpScmProtocolWrapper;
import sonia.scm.repository.spi.ScmProviderHttpServlet;
@@ -14,10 +15,16 @@ import javax.servlet.ServletException;
import java.util.Enumeration;
@Singleton
@Extension
public class SvnScmProtocolProviderWrapper extends InitializingHttpScmProtocolWrapper {
public static final String PARAMETER_SVN_PARENTPATH = "SVNParentPath";
@Override
public String getType() {
return "svn";
}
@Inject
public SvnScmProtocolProviderWrapper(Provider<SvnDAVServlet> servletProvider, Provider<SvnPermissionFilter> permissionFilter, Provider<ScmPathInfoStore> uriInfoStore, ScmConfiguration scmConfiguration) {
super(servletProvider, permissionFilter, uriInfoStore, scmConfiguration);