Top Description Fields Constructors Methods
org.eclipse.jgit.http.server

public Class GitServlet

extends MetaServlet
Class Inheritance
Imports
java.util.Enumeration, jakarta.servlet.Filter, .FilterConfig, .ServletConfig, .ServletContext, .ServletException, jakarta.servlet.http.HttpServletRequest, org.eclipse.jgit.http.server.glue.MetaServlet, org.eclipse.jgit.http.server.resolver.AsIsFileService, org.eclipse.jgit.transport.resolver.ReceivePackFactory, .RepositoryResolver, .UploadPackFactory

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 org.eclipse.jgit.http.server.glue.MetaServlet. Callers may register their own URL suffix translations through serve(String), or their regex translations through serveRegex(String). Each translation should contain a complete filter pipeline which ends with the HttpServlet that should handle the requested action.

Field Summary

Modifier and TypeField and Description
private final GitFilter
private static final long

Constructor Summary

AccessConstructor and Description
public
GitServlet()

New servlet that will load its base directory from web.xml.

Method Summary

Modifier and TypeMethod and Description
public void
addReceivePackFilter(Filter
filter to apply before any of the ReceivePack operations. The ReceivePack instance is available in the request attribute org.eclipse.jgit.http.server.ServletUtils#ATTRIBUTE_HANDLER.
filter
)

Add receive-pack filter

public void
addUploadPackFilter(Filter
filter to apply before any of the UploadPack operations. The UploadPack instance is available in the request attribute org.eclipse.jgit.http.server.ServletUtils#ATTRIBUTE_HANDLER.
filter
)

Add upload-pack filter

public void
init(ServletConfig
the ServletConfig object that contains configuration information for this servlet
config
)

Overrides org.eclipse.jgit.http.server.glue.MetaServlet.init.

Implements jakarta.servlet.Servlet.init.

Called by the servlet container to indicate to a servlet that the servlet is being placed into service.

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

Set AsIsFileService

public void
setReceivePackErrorHandler(ReceivePackErrorHandler
A custom error handler for git-receive-pack.
h
)

Set a custom error handler for git-receive-pack.

public void
setReceivePackFactory(ReceivePackFactory<HttpServletRequest>
the factory to construct and configure a org.eclipse.jgit.transport.ReceivePack session when a push is requested by a client.
f
)

Set receive-pack factory

public void
setRepositoryResolver(RepositoryResolver<HttpServletRequest>
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.
resolver
)

New servlet configured with a specific resolver.

public void
setUploadPackErrorHandler(UploadPackErrorHandler
A custom error handler for git-upload-pack.
h
)

Set a custom error handler for git-upload-pack.

public void
setUploadPackFactory(UploadPackFactory<HttpServletRequest>
the factory to construct and configure an org.eclipse.jgit.transport.UploadPack session when a fetch or clone is requested by a client.
f
)

Set upload-pack factory

Inherited from org.eclipse.jgit.http.server.glue.MetaServlet:
destroygetDelegateFilterregisterserveserveRegexservice

Field Detail

gitFilterback to summary
private final GitFilter gitFilter
serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.eclipse.jgit.http.server.glue.MetaServlet.serialVersionUID.

Constructor Detail

GitServletback to summary
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

addReceivePackFilterback to summary
public void addReceivePackFilter(Filter filter)

Add receive-pack filter

Parameters
filter:Filter

filter to apply before any of the ReceivePack operations. The ReceivePack instance is available in the request attribute org.eclipse.jgit.http.server.ServletUtils#ATTRIBUTE_HANDLER.

Since
7.0
addUploadPackFilterback to summary
public void addUploadPackFilter(Filter filter)

Add upload-pack filter

Parameters
filter:Filter

filter to apply before any of the UploadPack operations. The UploadPack instance is available in the request attribute org.eclipse.jgit.http.server.ServletUtils#ATTRIBUTE_HANDLER.

Since
7.0
initback to summary
public void init(ServletConfig config) throws ServletException

Overrides org.eclipse.jgit.http.server.glue.MetaServlet.init.

Implements jakarta.servlet.Servlet.init.

Doc from jakarta.servlet.GenericServlet.init.

Called by the servlet container to indicate to a servlet that the servlet is being placed into service. See Servlet#init.

This implementation stores the ServletConfig object it receives from the servlet container for later use. When overriding this form of the method, call super.init(config).

Parameters
config:ServletConfig

the ServletConfig object that contains configuration information for this servlet

Annotations
@Override
Exceptions
ServletException:
if an exception occurs that interrupts the servlet's normal operation
setAsIsFileServiceback to summary
public void setAsIsFileService(AsIsFileService f)

Set AsIsFileService

Parameters
f:AsIsFileService

the filter to validate direct access to repository files through a dumb client. If null then dumb client support is completely disabled.

setReceivePackErrorHandlerback to summary
public void setReceivePackErrorHandler(ReceivePackErrorHandler h)

Set a custom error handler for git-receive-pack.

Parameters
h:ReceivePackErrorHandler

A custom error handler for git-receive-pack.

Since
5.9.1
setReceivePackFactoryback to summary
public void setReceivePackFactory(ReceivePackFactory<HttpServletRequest> f)

Set receive-pack factory

Parameters
f:ReceivePackFactory<HttpServletRequest>

the factory to construct and configure a org.eclipse.jgit.transport.ReceivePack session when a push is requested by a client.

setRepositoryResolverback to summary
public void setRepositoryResolver(RepositoryResolver<HttpServletRequest> resolver)

New servlet configured with a specific resolver.

Parameters
resolver:RepositoryResolver<HttpServletRequest>

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.

setUploadPackErrorHandlerback to summary
public void setUploadPackErrorHandler(UploadPackErrorHandler h)

Set a custom error handler for git-upload-pack.

Parameters
h:UploadPackErrorHandler

A custom error handler for git-upload-pack.

Since
5.9.1
setUploadPackFactoryback to summary
public void setUploadPackFactory(UploadPackFactory<HttpServletRequest> f)

Set upload-pack factory

Parameters
f:UploadPackFactory<HttpServletRequest>

the factory to construct and configure an org.eclipse.jgit.transport.UploadPack session when a fetch or clone is requested by a client.