Package org.opencastproject.fsresources
Class StaticResourceServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.opencastproject.fsresources.StaticResourceServlet
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
public class StaticResourceServlet
extends javax.servlet.http.HttpServlet
Serves static content from a configured path on the filesystem. In production systems, this should be replaced with
apache httpd or another web server optimized for serving static content.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) OSGI Activation callbackvoidaddStaticFileAuthorization(StaticFileAuthorization authorization) protected voidcopy(File f, javax.servlet.ServletOutputStream out, Iterator<StaticResourceServlet.Range> ranges, String contentType) protected IOExceptioncopyRange(InputStream istream, javax.servlet.ServletOutputStream ostream, long start, long end) Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception).protected voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) protected voiddoHead(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) protected ArrayList<StaticResourceServlet.Range> parseRange(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse response, String eTag, long lastModified, long fileLength) Parse the range header.voidremoveStaticFileAuthorization(StaticFileAuthorization authorization) Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPost, doPut, doTrace, getLastModified, service, serviceMethods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
-
Field Details
-
SERVLET_PATH
- See Also:
-
-
Constructor Details
-
StaticResourceServlet
public StaticResourceServlet()No-arg constructor
-
-
Method Details
-
addStaticFileAuthorization
-
removeStaticFileAuthorization
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) OSGI Activation callback- Parameters:
cc- the component context
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException - Overrides:
doGetin classjavax.servlet.http.HttpServlet- Throws:
IOException- See Also:
-
doHead
protected void doHead(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException - Overrides:
doHeadin classjavax.servlet.http.HttpServlet- Throws:
IOException
-
copy
protected void copy(File f, javax.servlet.ServletOutputStream out, Iterator<StaticResourceServlet.Range> ranges, String contentType) throws IOException - Throws:
IOException
-
parseRange
protected ArrayList<StaticResourceServlet.Range> parseRange(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse response, String eTag, long lastModified, long fileLength) throws IOException Parse the range header.- Parameters:
req- The servlet request we are processingresponse- The servlet response we are creating- Returns:
- Vector of ranges
- Throws:
IOException
-
copyRange
protected IOException copyRange(InputStream istream, javax.servlet.ServletOutputStream ostream, long start, long end) Copy the contents of the specified input stream to the specified output stream, and ensure that both streams are closed before returning (even in the face of an exception).- Parameters:
istream- The input stream to read fromostream- The output stream to write tostart- Start of the range which will be copiedend- End of the range which will be copied- Returns:
- Exception which occurred during processing
-