All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.turbospaces.jetty.GitJettyChannel Maven / Gradle / Ivy

There is a newer version: 2.0.33
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy