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 - the TransportSession 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
    Modifier and Type
    Class
    Description
    class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    protected com.levigo.jadice.web.transport.server.session.internal.TransportManagerInternal
     

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    AbstractTransportServlet(com.levigo.jadice.web.transport.server.session.internal.TransportManagerInternal transportManager)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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 a HttpServletResponse, to "UTF-8".
    protected abstract T
    Creates a new transport session of the type T for the given ClientSession.
    void
     
    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 concrete TransportSession 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, doPost, doPut, doTrace, getLastModified, service

    Methods inherited from class jakarta.servlet.GenericServlet

    getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • transportManager

      protected com.levigo.jadice.web.transport.server.session.internal.TransportManagerInternal transportManager
    • timerService

      protected ScheduledExecutorService timerService
  • Constructor Details

    • AbstractTransportServlet

      public AbstractTransportServlet()
    • AbstractTransportServlet

      public AbstractTransportServlet(com.levigo.jadice.web.transport.server.session.internal.TransportManagerInternal transportManager)
  • Method Details

    • getMaxMessageSize

      @Deprecated protected int 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 interface jakarta.servlet.Servlet
      Overrides:
      init in class jakarta.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 a HttpServletResponse, to "UTF-8".
      Parameters:
      response - the http servlet response to modify
    • createTransportSession

      protected abstract T createTransportSession(ClientSession clientSession)
      Creates a new transport session of the type T for the given ClientSession.
      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 interface jakarta.servlet.Servlet
      Overrides:
      destroy in class jakarta.servlet.GenericServlet
    • getTransportSession

      protected T getTransportSession(String clientId, Class<T> sessionClass)
      Gets a transport session for a given client and concrete TransportSession 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 for
      sessionClass - 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 class jakarta.servlet.http.HttpServlet
      Throws:
      jakarta.servlet.ServletException
      IOException