com.turbospaces.jetty.GitJettyChannel Maven / Gradle / Ivy
package com.turbospaces.jetty;
import java.util.Objects;
import org.eclipse.jgit.http.server.GitServlet;
import org.eclipse.jgit.lib.Repository;
public class GitJettyChannel extends AbstractWebAppJettyChannel {
private final GitServlet gitServlet = new GitServlet();
private final Repository repository;
private final String path;
public GitJettyChannel(int port, String path, Repository repository) throws Throwable {
super(port);
this.path = Objects.requireNonNull(path);
this.repository = Objects.requireNonNull(repository);
gitServlet.setRepositoryResolver((req, name) -> {
repository.incrementOpen();
return repository;
});
}
@Override
public void start() {
addHandler(createGitServlet(path, gitServlet));
super.start();
}
public Repository getRepository() {
return repository;
}
}