mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-22 16:29:51 +01:00
Introduce extension point for further protocol implementations
This commit is contained in:
@@ -37,10 +37,8 @@ import com.google.common.collect.ImmutableSet;
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.api.Command;
|
||||
import sonia.scm.repository.api.ScmProtocol;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -69,12 +67,9 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
public GitRepositoryServiceProvider(GitRepositoryHandler handler,
|
||||
Repository repository, HttpScmProtocol httpScmProtocol)
|
||||
{
|
||||
public GitRepositoryServiceProvider(GitRepositoryHandler handler, Repository repository) {
|
||||
this.handler = handler;
|
||||
this.repository = repository;
|
||||
this.httpScmProtocol = httpScmProtocol;
|
||||
this.context = new GitContext(handler.getDirectory(repository));
|
||||
}
|
||||
|
||||
@@ -238,11 +233,6 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
return new GitTagsCommand(context, repository);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ScmProtocol> getSupportedProtocols() {
|
||||
return Collections.singleton(httpScmProtocol);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@@ -253,6 +243,4 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
|
||||
/** Field description */
|
||||
private Repository repository;
|
||||
|
||||
private final HttpScmProtocol httpScmProtocol;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.google.inject.Inject;
|
||||
import sonia.scm.plugin.Extension;
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.web.GitScmProtocolProviderWrapper;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -49,10 +48,11 @@ public class GitRepositoryServiceResolver implements RepositoryServiceResolver {
|
||||
|
||||
public static final String TYPE = "git";
|
||||
|
||||
private final GitRepositoryHandler handler;
|
||||
|
||||
@Inject
|
||||
public GitRepositoryServiceResolver(GitRepositoryHandler handler, GitScmProtocolProviderWrapper providerWrapper) {
|
||||
public GitRepositoryServiceResolver(GitRepositoryHandler handler) {
|
||||
this.handler = handler;
|
||||
this.providerWrapper = providerWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,12 +60,9 @@ public class GitRepositoryServiceResolver implements RepositoryServiceResolver {
|
||||
GitRepositoryServiceProvider provider = null;
|
||||
|
||||
if (TYPE.equalsIgnoreCase(repository.getType())) {
|
||||
provider = new GitRepositoryServiceProvider(handler, repository, providerWrapper.get(repository));
|
||||
provider = new GitRepositoryServiceProvider(handler, repository);
|
||||
}
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
private final GitRepositoryHandler handler;
|
||||
private final GitScmProtocolProviderWrapper providerWrapper;
|
||||
}
|
||||
|
||||
@@ -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 javax.inject.Inject;
|
||||
@@ -9,9 +10,15 @@ import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
@Extension
|
||||
public class GitScmProtocolProviderWrapper extends InitializingHttpScmProtocolWrapper {
|
||||
@Inject
|
||||
public GitScmProtocolProviderWrapper(Provider<ScmGitServlet> servletProvider, Provider<GitPermissionFilter> permissionFilter, Provider<ScmPathInfoStore> uriInfoStore, ScmConfiguration scmConfiguration) {
|
||||
super(servletProvider, permissionFilter, uriInfoStore, scmConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "git";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user