org.springframework.http.server.reactive

## Class ServletHttpHandlerAdapter

- java.lang.Object
- - org.springframework.http.server.reactive.ServletHttpHandlerAdapter

- All Implemented Interfaces:
    Servlet
  Direct Known Subclasses:
    JettyHttpHandlerAdapter, TomcatHttpHandlerAdapter

      public class ServletHttpHandlerAdapter
      extends Object
      implements Servlet

  Adapt `HttpHandler` to an `HttpServlet` using Servlet Async support and Servlet 3.1 non-blocking I/O.
  Since:
    5.0
  Author:
    Arjen Poutsma, Rossen Stoyanchev
  See Also:
    `AbstractReactiveWebInitializer`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServletHttpHandlerAdapter(HttpHandler httpHandler)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected org.springframework.http.server.reactive.ServletServerHttpRequest` | `createRequest(HttpServletRequest request, AsyncContext context)`
    `protected org.springframework.http.server.reactive.ServletServerHttpResponse` | `createResponse(HttpServletResponse response, AsyncContext context, org.springframework.http.server.reactive.ServletServerHttpRequest request)`
    `void` | `destroy()`
    `int` | `getBufferSize()` Return the configured input buffer size.
    `DataBufferFactory` | `getDataBufferFactory()`
    `ServletConfig` | `getServletConfig()`
    `String` | `getServletInfo()`
    `String` | `getServletPath()` Return the Servlet path under which the Servlet is deployed by checking the Servlet registration from `init(ServletConfig)`.
    `void` | `init(ServletConfig config)`
    `void` | `service(ServletRequest request, ServletResponse response)`
    `void` | `setBufferSize(int bufferSize)` Set the size of the input buffer used for reading in bytes.
    `void` | `setDataBufferFactory(DataBufferFactory dataBufferFactory)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ServletHttpHandlerAdapter

          public ServletHttpHandlerAdapter(HttpHandler httpHandler)

  - ### Method Detail

    - #### setBufferSize

          public void setBufferSize(int bufferSize)

      Set the size of the input buffer used for reading in bytes.

      By default this is set to 8192.

    - #### getBufferSize

          public int getBufferSize()

      Return the configured input buffer size.

    - #### getServletPath

          @Nullable
          public String getServletPath()

      Return the Servlet path under which the Servlet is deployed by checking the Servlet registration from `init(ServletConfig)`.
      Returns:
        the path, or an empty string if the Servlet is deployed without a prefix (i.e. "/" or "/*"), or `null` if this method is invoked before the `init(ServletConfig)` Servlet container callback.

    - #### setDataBufferFactory

          public void setDataBufferFactory(DataBufferFactory dataBufferFactory)

    - #### getDataBufferFactory

          public DataBufferFactory getDataBufferFactory()

    - #### init

          public void init(ServletConfig config)

      Specified by:
        `init` in interface `Servlet`

    - #### service

          public void service(ServletRequest request,
                              ServletResponse response)
                       throws ServletException,
                              IOException

      Specified by:
        `service` in interface `Servlet`
      Throws:
        `ServletException`
        `IOException`

    - #### createRequest

          protected org.springframework.http.server.reactive.ServletServerHttpRequest createRequest(HttpServletRequest request,
                                                                                                    AsyncContext context)
                                                                                             throws IOException,
                                                                                                    URISyntaxException

      Throws:
        `IOException`
        `URISyntaxException`

    - #### createResponse

          protected org.springframework.http.server.reactive.ServletServerHttpResponse createResponse(HttpServletResponse response,
                                                                                                      AsyncContext context,
                                                                                                      org.springframework.http.server.reactive.ServletServerHttpRequest request)
                                                                                               throws IOException

      Throws:
        `IOException`

    - #### getServletInfo

          public String getServletInfo()

      Specified by:
        `getServletInfo` in interface `Servlet`

    - #### getServletConfig

          @Nullable
          public ServletConfig getServletConfig()

      Specified by:
        `getServletConfig` in interface `Servlet`

    - #### destroy

          public void destroy()

      Specified by:
        `destroy` in interface `Servlet`