Class JettyResourceServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.ops4j.pax.web.service.jetty.internal.web.DefaultServlet
-
- org.ops4j.pax.web.service.jetty.internal.web.JettyResourceServlet
-
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig,org.eclipse.jetty.server.ResourceService.WelcomeFactory,org.eclipse.jetty.util.resource.ResourceFactory
public class JettyResourceServlet extends DefaultServlet
Extension of Jetty's default servlet to satisfy the resource contract from Http Service and Whiteboard Service specifications.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.LoggerLOG-
Fields inherited from class org.ops4j.pax.web.service.jetty.internal.web.DefaultServlet
_cache, _resourceService, _welcomes, CONTEXT_INIT
-
-
Constructor Summary
Constructors Constructor Description JettyResourceServlet(org.eclipse.jetty.util.resource.PathResource baseUrlResource, String chroot)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.eclipse.jetty.util.resource.ResourcegetResource(String pathInContext)get Resource to serve.voidinit()protected org.eclipse.jetty.server.handler.ContextHandlerinitContextHandler(javax.servlet.ServletContext servletContext)Compute the field _contextHandler.
In the case where the DefaultServlet is deployed on the HttpService it is likely that this method needs to be overwritten to unwrap the ServletContext facade until we reach the original jetty's ContextHandler.voidsetWelcomeFiles(String[] welcomeFiles)By makingDefaultServlet._welcomesprotected, we can set those files without reinitializing the servletvoidsetWelcomeFilesRedirect(boolean welcomeFilesRedirect)-
Methods inherited from class org.ops4j.pax.web.service.jetty.internal.web.DefaultServlet
destroy, doGet, doHead, doOptions, doPost, doTrace, getInitParameter, getWelcomeFile
-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doPut, getLastModified, service, service
-
-
-
-
Constructor Detail
-
JettyResourceServlet
public JettyResourceServlet(org.eclipse.jetty.util.resource.PathResource baseUrlResource, String chroot)
-
-
Method Detail
-
init
public void init() throws javax.servlet.UnavailableException- Overrides:
initin classDefaultServlet- Throws:
javax.servlet.UnavailableException
-
setWelcomeFiles
public void setWelcomeFiles(String[] welcomeFiles)
By makingDefaultServlet._welcomesprotected, we can set those files without reinitializing the servlet- Parameters:
welcomeFiles-
-
setWelcomeFilesRedirect
public void setWelcomeFilesRedirect(boolean welcomeFilesRedirect)
-
initContextHandler
protected org.eclipse.jetty.server.handler.ContextHandler initContextHandler(javax.servlet.ServletContext servletContext)
Description copied from class:DefaultServletCompute the field _contextHandler.
In the case where the DefaultServlet is deployed on the HttpService it is likely that this method needs to be overwritten to unwrap the ServletContext facade until we reach the original jetty's ContextHandler.- Overrides:
initContextHandlerin classDefaultServlet- Parameters:
servletContext- The servletContext of this servlet.- Returns:
- the jetty's ContextHandler for this servletContext.
-
getResource
public org.eclipse.jetty.util.resource.Resource getResource(String pathInContext)
Description copied from class:DefaultServletget Resource to serve. Map a path to a resource. The default implementation calls HttpContext.getResource but derived servlets may provide their own mapping.- Specified by:
getResourcein interfaceorg.eclipse.jetty.util.resource.ResourceFactory- Overrides:
getResourcein classDefaultServlet- Parameters:
pathInContext- The path to find a resource for.- Returns:
- The resource to serve.
-
-