Class AbstractTransportServlet<T extends com.levigo.jadice.web.transport.server.session.internal.TransportSession>
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
com.levigo.jadice.web.transport.server.networking.AbstractTransportServlet<T>
- Type Parameters:
T
- theTransportSession
implementation
- All Implemented Interfaces:
jakarta.servlet.Servlet
,jakarta.servlet.ServletConfig
,Serializable
- Direct Known Subclasses:
EventStreamServlet
,LongpollTransportServlet
public abstract class AbstractTransportServlet<T extends com.levigo.jadice.web.transport.server.session.internal.TransportSession>
extends jakarta.servlet.http.HttpServlet
The AbstractTransportServlet defines the basic behavior of transport servlet.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ScheduledExecutorService
protected com.levigo.jadice.web.transport.server.session.internal.TransportManagerInternal
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractTransportServlet
(com.levigo.jadice.web.transport.server.session.internal.TransportManagerInternal transportManager) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
configureNoCache
(jakarta.servlet.http.HttpServletResponse response) Sets the header field "Cache-Control" to "no-cache".protected void
configureResponse
(jakarta.servlet.http.HttpServletResponse response) Sets the content type to "text/plain" and the corresponding character encoding of aHttpServletResponse
, to "UTF-8".protected abstract T
createTransportSession
(ClientSession clientSession) Creates a new transport session of the typeT
for the givenClientSession
.void
destroy()
protected com.levigo.jadice.web.transport.server.internal.config.ConnectionConfiguration
protected int
Deprecated.only to be used in tests!protected T
getTransportSession
(String clientId, Class<T> sessionClass) Gets a transport session for a given client and concreteTransportSession
implementation.void
init
(jakarta.servlet.ServletConfig config) protected void
service
(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, service
Methods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
transportManager
protected com.levigo.jadice.web.transport.server.session.internal.TransportManagerInternal transportManager -
timerService
-
-
Constructor Details
-
AbstractTransportServlet
public AbstractTransportServlet() -
AbstractTransportServlet
public AbstractTransportServlet(com.levigo.jadice.web.transport.server.session.internal.TransportManagerInternal transportManager)
-
-
Method Details
-
getMaxMessageSize
Deprecated.only to be used in tests!The maximum possible size of a message in bytes. -
init
public void init(jakarta.servlet.ServletConfig config) throws jakarta.servlet.ServletException - Specified by:
init
in interfacejakarta.servlet.Servlet
- Overrides:
init
in classjakarta.servlet.http.HttpServlet
- Throws:
jakarta.servlet.ServletException
-
getConfig
protected com.levigo.jadice.web.transport.server.internal.config.ConnectionConfiguration getConfig() -
configureNoCache
protected void configureNoCache(jakarta.servlet.http.HttpServletResponse response) Sets the header field "Cache-Control" to "no-cache".- Parameters:
response
- The http servlet response to modify.
-
configureResponse
protected void configureResponse(jakarta.servlet.http.HttpServletResponse response) Sets the content type to "text/plain" and the corresponding character encoding of aHttpServletResponse
, to "UTF-8".- Parameters:
response
- the http servlet response to modify
-
createTransportSession
Creates a new transport session of the typeT
for the givenClientSession
.- Parameters:
clientSession
- The client session to create a transport session for.- Returns:
- The newly created transport session.
-
destroy
public void destroy()- Specified by:
destroy
in interfacejakarta.servlet.Servlet
- Overrides:
destroy
in classjakarta.servlet.GenericServlet
-
getTransportSession
Gets a transport session for a given client and concreteTransportSession
implementation.- If the transport session implementation is the same as the current transport session for the client, the current one is returned.
- If the transport session is another session as the current transport session, the session gets changed to the new one and is returned.
- If no transport session was set yet, a new session is set for the client and is returned.
- Parameters:
clientId
- the identifier of the client to get the transport session forsessionClass
- the TransportSession implementation to get session for- Returns:
- the transport session for the given client and transport session implementation
-
service
protected void service(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException - Overrides:
service
in classjakarta.servlet.http.HttpServlet
- Throws:
jakarta.servlet.ServletException
IOException
-