]> source.dussan.org Git - gitblit.git/commitdiff
Map gitservlet from web.xml and configure it from gitblit properties.
authorJames Moger <james.moger@gitblit.com>
Sat, 18 Jun 2011 13:22:05 +0000 (09:22 -0400)
committerJames Moger <james.moger@gitblit.com>
Sat, 18 Jun 2011 13:22:05 +0000 (09:22 -0400)
src/WEB-INF/web.xml
src/com/gitblit/GitBlitServer.java
src/com/gitblit/GitServlet.java [new file with mode: 0644]

index d5d3288fd7eb1ae944fb40704fe203100c21e5b2..26615902f167505b1c0d8f528afe8b2a25b6c502 100644 (file)
                 <url-pattern> MUST match: \r
                        * GitFilter\r
                        * com.gitblit.Constants.GIT_PATH\r
-                       * Wicket Filter ignorePaths parameter --><!-- STRIP\r
+                       * Wicket Filter ignorePaths parameter -->\r
        <servlet>\r
                <servlet-name>GitServlet</servlet-name>\r
-               <servlet-class>org.jgit.http.transport.GitServlet</servlet-class>\r
-               <init-param>\r
-                       <param-name>base-path</param-name>\r
-                       <param-value>c:/git</param-value>\r
-               </init-param>\r
-               <init-param>\r
-                       <param-name>export-all</param-name>\r
-                       <param-value>1</param-value>\r
-               </init-param>\r
+               <servlet-class>com.gitblit.GitServlet</servlet-class>\r
        </servlet>\r
        <servlet-mapping>\r
                <servlet-name>GitServlet</servlet-name>         \r
                <url-pattern>/git/*</url-pattern>\r
-       </servlet-mapping>STRIP -->\r
+       </servlet-mapping>\r
        \r
        \r
        <!-- Syndication Servlet\r
index 3687e4db24ad495583cd0740bf0c16793eacbc3d..678c9d43ea6e28c18e7a6a9834ce702db4255a94 100644 (file)
@@ -38,11 +38,8 @@ import org.eclipse.jetty.server.session.HashSessionManager;
 import org.eclipse.jetty.server.ssl.SslConnector;\r
 import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;\r
 import org.eclipse.jetty.server.ssl.SslSocketConnector;\r
-import org.eclipse.jetty.servlet.FilterMapping;\r
-import org.eclipse.jetty.servlet.ServletHolder;\r
 import org.eclipse.jetty.util.thread.QueuedThreadPool;\r
 import org.eclipse.jetty.webapp.WebAppContext;\r
-import org.eclipse.jgit.http.server.GitServlet;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
@@ -197,13 +194,6 @@ public class GitBlitServer {
                sessionManager.setSecureCookies(params.port <= 0 && params.securePort > 0);\r
                rootContext.getSessionHandler().setSessionManager(sessionManager);\r
 \r
-               // JGit Filter and Servlet\r
-               String jgitPathSpec = Constants.GIT_PATH + "*";\r
-               rootContext.addFilter(GitFilter.class, jgitPathSpec, FilterMapping.DEFAULT);\r
-               ServletHolder jGitServlet = rootContext.addServlet(GitServlet.class, jgitPathSpec);\r
-               jGitServlet.setInitParameter("base-path", params.repositoriesFolder);\r
-               jGitServlet.setInitParameter("export-all", "1");\r
-\r
                // Ensure there is a defined Login Service\r
                String realmUsers = params.realmFile;\r
                if (StringUtils.isEmpty(realmUsers)) {\r
diff --git a/src/com/gitblit/GitServlet.java b/src/com/gitblit/GitServlet.java
new file mode 100644 (file)
index 0000000..daf5d96
--- /dev/null
@@ -0,0 +1,16 @@
+package com.gitblit;\r
+\r
+public class GitServlet extends org.eclipse.jgit.http.server.GitServlet {\r
+\r
+       private static final long serialVersionUID = 1L;\r
+\r
+       @Override\r
+       public String getInitParameter(String name) {\r
+               if (name.equals("base-path")) {\r
+                       return GitBlit.getString(Keys.git.repositoriesFolder, "git");\r
+               } else if (name.equals("export-all")) {\r
+                       return "1";\r
+               }\r
+               return super.getInitParameter(name);\r
+       }\r
+}\r