- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.eclipse.jetty.servlets.DataRateLimitedServlet
-
- All Implemented Interfaces:
java.io.Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
public class DataRateLimitedServlet extends javax.servlet.http.HttpServletA servlet that uses the Servlet 3.1 asynchronous IO API to server static content at a limited data rate.Two implementations are supported:
- The
StandardDataStreamimpl uses only standard APIs, but produces more garbage due to the byte[] nature of the API. - the
JettyDataStreamimpl uses a Jetty API to write a ByteBuffer and thus allow the efficient use of file mapped buffers without any temporary buffer copies (I did tell the JSR that this was a good idea to have in the standard!).
The data rate is controlled by setting init parameters:
- buffersize
- The amount of data in bytes written per write
- pause
- The period in ms to wait after a write before attempting another
- pool
- The size of the thread pool used to service the writes (defaults to available processors)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DataRateLimitedServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()protected voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)voidinit()-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
-
-
-
-
Method Detail
-
init
public void init() throws javax.servlet.ServletException- Overrides:
initin classjavax.servlet.GenericServlet- Throws:
javax.servlet.ServletException
-
destroy
public void destroy()
- Specified by:
destroyin interfacejavax.servlet.Servlet- Overrides:
destroyin classjavax.servlet.GenericServlet
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException- Overrides:
doGetin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionjava.io.IOException
-
-