public class GitFilter extends MetaFilter
Applications embedding this filter should map a directory path within the
application to this filter. For a servlet version, see
GitServlet
.
Applications may wish to add additional repository action URLs to this
servlet by taking advantage of its extension from
MetaFilter
. Callers may register
their own URL suffix translations through MetaFilter.serve(String)
, or their
regex translations through MetaFilter.serveRegex(String)
. Each translation
should contain a complete filter pipeline which ends with the HttpServlet
that should handle the requested action.
Modifier and Type | Field and Description |
---|---|
private AsIsFileService |
asIs |
private boolean |
initialized |
private ReceivePackFactory<javax.servlet.http.HttpServletRequest> |
receivePackFactory |
private java.util.List<javax.servlet.Filter> |
receivePackFilters |
private RepositoryResolver<javax.servlet.http.HttpServletRequest> |
resolver |
private UploadPackFactory<javax.servlet.http.HttpServletRequest> |
uploadPackFactory |
private java.util.List<javax.servlet.Filter> |
uploadPackFilters |
Constructor and Description |
---|
GitFilter()
New servlet that will load its base directory from
web.xml . |
Modifier and Type | Method and Description |
---|---|
void |
addReceivePackFilter(javax.servlet.Filter filter)
Add receive-pack filter
|
void |
addUploadPackFilter(javax.servlet.Filter filter)
Add upload-pack filter
|
private void |
assertNotInitialized() |
private static boolean |
getBoolean(javax.servlet.FilterConfig cfg,
java.lang.String param) |
private static java.io.File |
getFile(javax.servlet.FilterConfig cfg,
java.lang.String param) |
void |
init(javax.servlet.FilterConfig filterConfig) |
protected ServletBinder |
register(ServletBinder binder)
Configure a newly created binder.
|
void |
setAsIsFileService(AsIsFileService f)
Set AsIsFileService
|
void |
setReceivePackFactory(ReceivePackFactory<javax.servlet.http.HttpServletRequest> f)
Set the receive-pack factory
|
void |
setRepositoryResolver(RepositoryResolver<javax.servlet.http.HttpServletRequest> resolver)
New servlet configured with a specific resolver.
|
void |
setUploadPackFactory(UploadPackFactory<javax.servlet.http.HttpServletRequest> f)
Set upload-pack factory
|
destroy, doFilter, serve, serveRegex, serveRegex
private volatile boolean initialized
private RepositoryResolver<javax.servlet.http.HttpServletRequest> resolver
private AsIsFileService asIs
private UploadPackFactory<javax.servlet.http.HttpServletRequest> uploadPackFactory
private ReceivePackFactory<javax.servlet.http.HttpServletRequest> receivePackFactory
private final java.util.List<javax.servlet.Filter> uploadPackFilters
private final java.util.List<javax.servlet.Filter> receivePackFilters
public GitFilter()
web.xml
.
The required parameter base-path
must be configured to point to
the local filesystem directory where all served Git repositories reside.
public void setRepositoryResolver(RepositoryResolver<javax.servlet.http.HttpServletRequest> resolver)
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.public void setAsIsFileService(AsIsFileService f)
f
- the filter to validate direct access to repository files
through a dumb client. If null
then dumb client
support is completely disabled.public void setUploadPackFactory(UploadPackFactory<javax.servlet.http.HttpServletRequest> f)
f
- the factory to construct and configure an
UploadPack
session when a
fetch or clone is requested by a client.public void addUploadPackFilter(javax.servlet.Filter filter)
filter
- filter to apply before any of the UploadPack operations. The
UploadPack instance is available in the request attribute
ServletUtils.ATTRIBUTE_HANDLER
.public void setReceivePackFactory(ReceivePackFactory<javax.servlet.http.HttpServletRequest> f)
f
- the factory to construct and configure a
ReceivePack
session when a
push is requested by a client.public void addReceivePackFilter(javax.servlet.Filter filter)
filter
- filter to apply before any of the ReceivePack operations. The
ReceivePack instance is available in the request attribute
ServletUtils.ATTRIBUTE_HANDLER
.private void assertNotInitialized()
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException
init
in interface javax.servlet.Filter
init
in class MetaFilter
javax.servlet.ServletException
private static java.io.File getFile(javax.servlet.FilterConfig cfg, java.lang.String param) throws javax.servlet.ServletException
javax.servlet.ServletException
private static boolean getBoolean(javax.servlet.FilterConfig cfg, java.lang.String param) throws javax.servlet.ServletException
javax.servlet.ServletException
protected ServletBinder register(ServletBinder binder)
register
in class MetaFilter
binder
- the newly created binder.