public abstract class EventSourceServlet extends HttpServlet
A servlet that implements the event source protocol, also known as "server sent events".
This servlet must be subclassed to implement abstract method newEventSource(HttpServletRequest)
to return an instance of EventSource that allows application to listen for event source events
and to emit event source events.
This servlet supports the following configuration parameters:
heartBeatPeriod, that specifies the heartbeat period, in seconds, used to check
whether the connection has been closed by the client; defaults to 10 seconds.NOTE: there is currently no support for last-event-id.
| Modifier and Type | Class and Description |
|---|---|
protected class |
EventSourceServlet.EventSourceEmitter |
| Constructor and Description |
|---|
EventSourceServlet() |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
protected void |
doGet(HttpServletRequest request,
HttpServletResponse response) |
void |
init() |
protected abstract EventSource |
newEventSource(HttpServletRequest request) |
protected void |
open(EventSource eventSource,
EventSource.Emitter emitter) |
protected void |
respond(HttpServletRequest request,
HttpServletResponse response) |
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, servicegetInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, logpublic void init()
throws ServletException
init in class GenericServletServletExceptionpublic void destroy()
destroy in interface Servletdestroy in class GenericServletprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
doGet in class HttpServletServletExceptionIOExceptionprotected abstract EventSource newEventSource(HttpServletRequest request)
protected void respond(HttpServletRequest request, HttpServletResponse response) throws IOException
IOExceptionprotected void open(EventSource eventSource, EventSource.Emitter emitter) throws IOException
IOExceptionCopyright © 1995-2015 Webtide. All Rights Reserved.