Package com.google.gerrit.httpd.raw
Class ResourceServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- com.google.gerrit.httpd.raw.ResourceServlet
-
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
- Direct Known Subclasses:
SiteStaticDirectoryServlet
public abstract class ResourceServlet extends javax.servlet.http.HttpServlet
Base class for serving static resources.Supports caching, ETags, basic content type detection, and limited gzip compression.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ResourceServlet.Resource
static class
ResourceServlet.Weigher
-
Constructor Summary
Constructors Modifier Constructor Description protected
ResourceServlet(com.google.common.cache.Cache<Path,ResourceServlet.Resource> cache, boolean refresh)
protected
ResourceServlet(com.google.common.cache.Cache<Path,ResourceServlet.Resource> cache, boolean refresh, boolean cacheOnClient)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static String
contentType(String name)
protected void
doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse rsp)
protected FileTime
getLastModifiedTime(Path p)
protected abstract Path
getResourcePath(String pathInfo)
Get the resource path on the filesystem that should be served for this request.-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
-
-
-
-
Constructor Detail
-
ResourceServlet
protected ResourceServlet(com.google.common.cache.Cache<Path,ResourceServlet.Resource> cache, boolean refresh)
-
ResourceServlet
protected ResourceServlet(com.google.common.cache.Cache<Path,ResourceServlet.Resource> cache, boolean refresh, boolean cacheOnClient)
-
-
Method Detail
-
getResourcePath
protected abstract Path getResourcePath(String pathInfo) throws IOException
Get the resource path on the filesystem that should be served for this request.- Parameters:
pathInfo
- result ofHttpServletRequest.getPathInfo()
.- Returns:
- path where static content can be found.
- Throws:
IOException
- if an error occurred resolving the resource.
-
getLastModifiedTime
protected FileTime getLastModifiedTime(Path p) throws IOException
- Throws:
IOException
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse rsp) throws IOException
- Overrides:
doGet
in classjavax.servlet.http.HttpServlet
- Throws:
IOException
-
-