mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
Introduce extension point for further protocol implementations
This commit is contained in:
@@ -39,11 +39,9 @@ import sonia.scm.repository.HgHookManager;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.api.Command;
|
||||
import sonia.scm.repository.api.ScmProtocol;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -78,11 +76,10 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
HgRepositoryServiceProvider(HgRepositoryHandler handler,
|
||||
HgHookManager hookManager, Repository repository, HttpScmProtocol httpScmProtocol)
|
||||
HgHookManager hookManager, Repository repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
this.handler = handler;
|
||||
this.httpScmProtocol = httpScmProtocol;
|
||||
this.repositoryDirectory = handler.getDirectory(repository);
|
||||
this.context = new HgCommandContext(hookManager, handler, repository,
|
||||
repositoryDirectory);
|
||||
@@ -260,11 +257,6 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
return new HgTagsCommand(context, repository);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ScmProtocol> getSupportedProtocols() {
|
||||
return Collections.singleton(httpScmProtocol);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@@ -278,6 +270,4 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
|
||||
/** Field description */
|
||||
private File repositoryDirectory;
|
||||
|
||||
private final HttpScmProtocol httpScmProtocol;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import sonia.scm.plugin.Extension;
|
||||
import sonia.scm.repository.HgHookManager;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.web.HgScmProtocolProviderWrapper;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -48,59 +47,27 @@ import sonia.scm.web.HgScmProtocolProviderWrapper;
|
||||
public class HgRepositoryServiceResolver implements RepositoryServiceResolver
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final String TYPE = "hg";
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
private HgRepositoryHandler handler;
|
||||
private HgHookManager hookManager;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param hookManager
|
||||
* @param handler
|
||||
*/
|
||||
@Inject
|
||||
public HgRepositoryServiceResolver(HgRepositoryHandler handler,
|
||||
HgHookManager hookManager, HgScmProtocolProviderWrapper providerWrapper)
|
||||
HgHookManager hookManager)
|
||||
{
|
||||
this.handler = handler;
|
||||
this.hookManager = hookManager;
|
||||
this.providerWrapper = providerWrapper;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public HgRepositoryServiceProvider resolve(Repository repository)
|
||||
{
|
||||
public HgRepositoryServiceProvider resolve(Repository repository) {
|
||||
HgRepositoryServiceProvider provider = null;
|
||||
|
||||
if (TYPE.equalsIgnoreCase(repository.getType()))
|
||||
{
|
||||
provider = new HgRepositoryServiceProvider(handler, hookManager,
|
||||
repository, providerWrapper.get(repository));
|
||||
if (TYPE.equalsIgnoreCase(repository.getType())) {
|
||||
provider = new HgRepositoryServiceProvider(handler, hookManager, repository);
|
||||
}
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private HgRepositoryHandler handler;
|
||||
|
||||
/** Field description */
|
||||
private HgHookManager hookManager;
|
||||
|
||||
private final HgScmProtocolProviderWrapper 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 HgScmProtocolProviderWrapper extends InitializingHttpScmProtocolWrapper {
|
||||
@Inject
|
||||
public HgScmProtocolProviderWrapper(Provider<HgCGIServlet> servletProvider, Provider<HgPermissionFilter> permissionFilter, Provider<ScmPathInfoStore> uriInfoStore, ScmConfiguration scmConfiguration) {
|
||||
super(servletProvider, permissionFilter, uriInfoStore, scmConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "hg";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user