Class TileServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
com.levigo.jadice.web.conn.server.TileServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

public class TileServlet extends jakarta.servlet.http.HttpServlet
This servlet handles HTTP tile requests.

The "@WebServlet"-Annotation was removed as this Servlet needs some Autowired components, therefore the servlet has to be manually registered by a ServletRegistrationBean

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    Simple implementation of the RenderControls to be fed with the deserialized settings manually on the server because the client implementation is not accessible on the server.
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected com.levigo.jadice.web.server.internal.TileRenderService
     

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    TileServlet(com.levigo.jadice.web.server.internal.TileRenderService tileRenderService)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
     
    static String
    getClientId(String queryString)
    Extracts the client-ID from a given tile-request URL.
    protected void
    getData(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
     
    protected void
    handleRequestAsynchronously(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, com.levigo.jadice.web.shared.model.internal.RenderSpecification spec, String renderSpecHashCode)
    Starts the asynchronous processing of the tile-rendering by initializing an async-context.
    protected void
    handleTileCancelCallback(AtomicBoolean requestStillValid, jakarta.servlet.AsyncContext async)
    Callback-method when a Tile-render-request was cancelled
    protected void
    handleTileErrorCallback(AtomicBoolean requestStillValid, jakarta.servlet.AsyncContext async, Throwable e)
    Callback-method when an error occurred in a Tile-render-request
    protected void
    handleTileSuccessCallback(AtomicBoolean requestStillValid, jakarta.servlet.AsyncContext async, BufferedImage tileData, boolean clientSupportsWebp, String renderSpecHashCode)
    Success-callback when a Tile was successfully rendered.
    protected void
     
    protected void
    setTileImageFuture(com.levigo.jadice.web.server.internal.concurrent.TileRenderFuture tileImageFuture, TileRenderAsyncListener tileRenderAsyncListener)
    Moved to own method so it can be overridden in Tests
    protected jakarta.servlet.AsyncContext
    startAsync(jakarta.servlet.http.HttpServletRequest request)
     
    protected PageSegmentHandle[]
    unmarshalHandles(String handlesString)
     
    protected com.levigo.jadice.web.shared.model.internal.RenderSpecification
    unmarshalRenderSpecification(jakarta.servlet.http.HttpServletRequest request)
     

    Methods inherited from class jakarta.servlet.http.HttpServlet

    doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, init, service, service

    Methods inherited from class jakarta.servlet.GenericServlet

    destroy, 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

    • tileRenderService

      @Autowired protected com.levigo.jadice.web.server.internal.TileRenderService tileRenderService
  • Constructor Details

    • TileServlet

      public TileServlet()
    • TileServlet

      public TileServlet(com.levigo.jadice.web.server.internal.TileRenderService tileRenderService)
  • Method Details

    • getClientId

      public static String getClientId(String queryString)
      Extracts the client-ID from a given tile-request URL.
      Parameters:
      queryString - the queryString of the tile-request URL
      Returns:
      the extracted client-id for the given tile-request
    • doGet

      protected void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException
      Overrides:
      doGet in class jakarta.servlet.http.HttpServlet
      Throws:
      jakarta.servlet.ServletException
    • getData

      protected void getData(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IndexOutOfBoundsException, ar.com.hjg.pngj.PngjOutputException, IOException
      Throws:
      IndexOutOfBoundsException
      ar.com.hjg.pngj.PngjOutputException
      IOException
    • handleRequestAsynchronously

      protected void handleRequestAsynchronously(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, com.levigo.jadice.web.shared.model.internal.RenderSpecification spec, String renderSpecHashCode)
      Starts the asynchronous processing of the tile-rendering by initializing an async-context. The intention is to optimize the handling of requests while a potential long-running tile-generation is running in the background.
    • startAsync

      protected jakarta.servlet.AsyncContext startAsync(jakarta.servlet.http.HttpServletRequest request)
    • setTileImageFuture

      protected void setTileImageFuture(com.levigo.jadice.web.server.internal.concurrent.TileRenderFuture tileImageFuture, TileRenderAsyncListener tileRenderAsyncListener)
      Moved to own method so it can be overridden in Tests
    • handleTileSuccessCallback

      protected void handleTileSuccessCallback(AtomicBoolean requestStillValid, jakarta.servlet.AsyncContext async, BufferedImage tileData, boolean clientSupportsWebp, String renderSpecHashCode)
      Success-callback when a Tile was successfully rendered. Writes the result to the response
      Parameters:
      requestStillValid - flag that is set to invalid by the async-context when the async-request timed-out
      async - the async-context for this operation
      tileData - the result of the tile-render-process (the actual image)
    • handleTileCancelCallback

      protected void handleTileCancelCallback(AtomicBoolean requestStillValid, jakarta.servlet.AsyncContext async)
      Callback-method when a Tile-render-request was cancelled
      Parameters:
      requestStillValid - flag that is set to invalid by the async-context when the async-request timed-out
      async - the async-context for this operation
    • handleTileErrorCallback

      protected void handleTileErrorCallback(AtomicBoolean requestStillValid, jakarta.servlet.AsyncContext async, Throwable e)
      Callback-method when an error occurred in a Tile-render-request
      Parameters:
      requestStillValid - flag that is set to invalid by the async-context when the async-request timed-out
      async - the async-context for this operation
      e - the error
    • unmarshalRenderSpecification

      protected com.levigo.jadice.web.shared.model.internal.RenderSpecification unmarshalRenderSpecification(jakarta.servlet.http.HttpServletRequest request) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • unmarshalHandles

      protected PageSegmentHandle[] unmarshalHandles(String handlesString) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • logClientClosedException

      protected void logClientClosedException(Exception e)