org.eclipse.jgit.http.server
Class GitServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.eclipse.jgit.http.server.glue.MetaServlet
              extended by org.eclipse.jgit.http.server.GitServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class GitServlet
extends MetaServlet

Handles Git repository access over HTTP.

Applications embedding this servlet should map a directory path within the application to this servlet, for example:

   <servlet>
     <servlet-name>GitServlet</servlet-name>
     <servlet-class>org.eclipse.jgit.http.server.GitServlet</servlet-class>
     <init-param>
       <param-name>base-path</param-name>
       <param-value>/var/srv/git</param-value>
     </init-param>
     <init-param>
       <param-name>export-all</param-name>
       <param-value>0</param-value>
     </init-param>
 </servlet>
   <servlet-mapping>
     <servlet-name>GitServlet</servlet-name>
     <url-pattern>/git/*</url-pattern>
   </servlet-mapping>
 

Applications may wish to add additional repository action URLs to this servlet by taking advantage of its extension from MetaServlet. Callers may register their own URL suffix translations through MetaServlet.serve(String), or their regex translations through MetaServlet.serveRegex(String). Each translation should contain a complete filter pipeline which ends with the HttpServlet that should handle the requested action.

See Also:
Serialized Form

Constructor Summary
GitServlet()
          New servlet that will load its base directory from web.xml.
 
Method Summary
 void addReceivePackFilter(javax.servlet.Filter filter)
           
 void addUploadPackFilter(javax.servlet.Filter filter)
           
 void init(javax.servlet.ServletConfig config)
           
protected  ServletBinder register(ServletBinder binder)
          Configure a newly created binder.
 void setAsIsFileService(AsIsFileService f)
           
 void setReceivePackFactory(ReceivePackFactory<javax.servlet.http.HttpServletRequest> f)
           
 void setRepositoryResolver(RepositoryResolver<javax.servlet.http.HttpServletRequest> resolver)
          New servlet configured with a specific resolver.
 void setUploadPackFactory(UploadPackFactory<javax.servlet.http.HttpServletRequest> f)
           
 
Methods inherited from class org.eclipse.jgit.http.server.glue.MetaServlet
destroy, serve, serveRegex, service
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GitServlet

public GitServlet()
New servlet that will load its base directory from web.xml.

The required parameter base-path must be configured to point to the local filesystem directory where all served Git repositories reside.

Method Detail

setRepositoryResolver

public void setRepositoryResolver(RepositoryResolver<javax.servlet.http.HttpServletRequest> resolver)
New servlet configured with a specific resolver.

Parameters:
resolver - the resolver to use when matching URL to Git repository. If null the base-path parameter will be looked for in the parameter table during init, which usually comes from the web.xml file of the web application.

setAsIsFileService

public void setAsIsFileService(AsIsFileService f)
Parameters:
f - the filter to validate direct access to repository files through a dumb client. If null then dumb client support is completely disabled.

setUploadPackFactory

public void setUploadPackFactory(UploadPackFactory<javax.servlet.http.HttpServletRequest> f)
Parameters:
f - the factory to construct and configure an UploadPack session when a fetch or clone is requested by a client.

addUploadPackFilter

public void addUploadPackFilter(javax.servlet.Filter filter)
Parameters:
filter - filter to apply before any of the UploadPack operations. The UploadPack instance is available in the request attribute ServletUtils.ATTRIBUTE_HANDLER.

setReceivePackFactory

public void setReceivePackFactory(ReceivePackFactory<javax.servlet.http.HttpServletRequest> f)
Parameters:
f - the factory to construct and configure a ReceivePack session when a push is requested by a client.

addReceivePackFilter

public void addReceivePackFilter(javax.servlet.Filter filter)
Parameters:
filter - filter to apply before any of the ReceivePack operations. The ReceivePack instance is available in the request attribute ServletUtils.ATTRIBUTE_HANDLER.

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

register

protected ServletBinder register(ServletBinder binder)
Description copied from class: MetaServlet
Configure a newly created binder.

Overrides:
register in class MetaServlet
Parameters:
binder - the newly created binder.
Returns:
binder for the caller, potentially after adding one or more filters into the pipeline.


Copyright © 2011. All Rights Reserved.