Generalize servlet decorator structure

This commit is contained in:
René Pfeuffer
2018-09-14 09:15:46 +02:00
parent a075962a66
commit 6ab5f58fe9
5 changed files with 70 additions and 16 deletions

View File

@@ -0,0 +1,28 @@
package sonia.scm.repository.spi;
import sonia.scm.repository.Repository;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class ScmProviderHttpServletDecorator implements ScmProviderHttpServlet {
private final ScmProviderHttpServlet object;
public ScmProviderHttpServletDecorator(ScmProviderHttpServlet object) {
this.object = object;
}
@Override
public void service(HttpServletRequest request, HttpServletResponse response, Repository repository) throws ServletException, IOException {
object.service(request, response, repository);
}
@Override
public void init(ServletConfig config) throws ServletException {
object.init(config);
}
}

View File

@@ -0,0 +1,15 @@
package sonia.scm.repository.spi;
import sonia.scm.DecoratorFactory;
import sonia.scm.plugin.ExtensionPoint;
@ExtensionPoint
public interface ScmProviderHttpServletDecoratorFactory extends DecoratorFactory<ScmProviderHttpServlet> {
/**
* Has to return <code>true</code> if this factory provides a decorator for the given scm type (eg. "git", "hg" or
* "svn").
* @param type The current scm type this factory can provide a decorator for.
* @return <code>true</code> when the provided decorator should be used for the given scm type.
*/
boolean handlesScmType(String type);
}

View File

@@ -1,7 +0,0 @@
package sonia.scm.repository.spi;
import sonia.scm.DecoratorFactory;
import sonia.scm.plugin.ExtensionPoint;
@ExtensionPoint
public interface ScmProviderHttpServletFactory extends DecoratorFactory<ScmProviderHttpServlet> {}