Package no.priv.bang.servlet.frontend
Class FrontendServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- no.priv.bang.servlet.frontend.FrontendServlet
-
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public class FrontendServlet extends javax.servlet.http.HttpServlet
This is a servlet that's intended to be a base class for a DS component exposing aServlet
service that plugs into the OSGi web whiteboard. The servlet will scan the classpath for resources matching the request pathinfo (minus any webcontext added to the servlet path) and serve the resources with a content-type determined by the file name extension. In addition the servlet supports a list of aliases for index.html that exists to support reload of paths created by the react router. In a subclass, this list can be set by calling thesetRoutes(String...)
method.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private no.priv.bang.osgi.service.adapters.logservice.LogServiceAdapter
logservice
private ArrayList<String>
routes
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description FrontendServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addSlashToServletPath(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
private void
copyStream(InputStream input, javax.servlet.ServletOutputStream output)
protected void
doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
private String
findResourceFromPathInfo(String pathInfo)
List<String>
getRoutes()
(package private) String
guessContentTypeFromResourceName(String resource)
void
setLogService(org.osgi.service.log.LogService logservice)
void
setRoutes(String... routes)
-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
logservice
private final no.priv.bang.osgi.service.adapters.logservice.LogServiceAdapter logservice
-
-
Method Detail
-
setRoutes
public void setRoutes(String... routes)
-
setLogService
public void setLogService(org.osgi.service.log.LogService logservice)
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
- Overrides:
doGet
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
IOException
-
addSlashToServletPath
private void addSlashToServletPath(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
- Throws:
IOException
-
copyStream
private void copyStream(InputStream input, javax.servlet.ServletOutputStream output) throws IOException
- Throws:
IOException
-
-