HttpHandler to an HttpServlet using Servlet Async support
and Servlet non-blocking I/O.
org.springframework.web.server.adapter.AbstractReactiveWebInitializer
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class | ServletHttpHandlerAdapter.
AsyncListener to complete the Additional |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private DataBufferFactory | |
| private static final int | |
| private final HttpHandler | |
| private static final Log | |
| private String | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected ServletServerHttpRequest | |
| protected ServletServerHttpResponse | createResponse(HttpServletResponse response, AsyncContext context, ServletServerHttpRequest request)
|
| public void | destroy()
Implements jakarta. Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. |
| public int | |
| public DataBufferFactory | |
| public ServletConfig | getServletConfig()
Implements jakarta. Returns a |
| public String | getServletInfo()
Implements jakarta. Returns information about the servlet, such as author, version, and copyright. |
| public String | Returns: the path, or an empty string if the Servlet is deployed without a prefix (i.e. "/" or "/*"), ornull if this method is invoked
before the init(ServletConfig) Servlet container callback.Return the Servlet path under which the Servlet is deployed by checking
the Servlet registration from |
| private String | |
| public void | init(ServletConfig
a config)ServletConfig object containing the servlet's configuration and initialization
parametersImplements jakarta. Called by the servlet container to indicate to a servlet that the servlet is being placed into service. |
| private static void | |
| public void | service(ServletRequest
the request, ServletResponse ServletRequest object that contains the client's requestthe response)ServletResponse object that contains the servlet's responseImplements jakarta. Called by the servlet container to allow the servlet to respond to a request. |
| public void | |
| public void |
| bufferSize | back to summary |
|---|---|
| private int bufferSize | |
| dataBufferFactory | back to summary |
|---|---|
| private DataBufferFactory dataBufferFactory | |
| DEFAULT_BUFFER_SIZE | back to summary |
|---|---|
| private static final int DEFAULT_BUFFER_SIZE | |
| httpHandler | back to summary |
|---|---|
| private final HttpHandler httpHandler | |
| logger | back to summary |
|---|---|
| private static final Log logger | |
| servletPath | back to summary |
|---|---|
| private String servletPath
| |
| WRITE_ERROR_ATTRIBUTE_NAME | back to summary |
|---|---|
| private static final String WRITE_ERROR_ATTRIBUTE_NAME | |
| ServletHttpHandlerAdapter | back to summary |
|---|---|
| public ServletHttpHandlerAdapter(HttpHandler httpHandler) | |
| createRequest | back to summary |
|---|---|
| protected ServletServerHttpRequest createRequest(HttpServletRequest request, AsyncContext context) throws IOException, URISyntaxException | |
| createResponse | back to summary |
|---|---|
| protected ServletServerHttpResponse createResponse(HttpServletResponse response, AsyncContext context, ServletServerHttpRequest request) throws IOException | |
| destroy | back to summary |
|---|---|
| public void destroy() Implements jakarta. Doc from jakarta. Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. This
method is only called once all threads within the servlet's This method gives the servlet an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the servlet's current state in memory.
| |
| getBufferSize | back to summary |
|---|---|
| public int getBufferSize() Return the configured input buffer size. | |
| getDataBufferFactory | back to summary |
|---|---|
| public DataBufferFactory getDataBufferFactory() | |
| getServletConfig | back to summary |
|---|---|
| public ServletConfig getServletConfig() Implements jakarta. Doc from jakarta. Returns a
Implementations of this interface are responsible for storing the
| |
| getServletInfo | back to summary |
|---|---|
| public String getServletInfo() Implements jakarta. Doc from jakarta. Returns information about the servlet, such as author, version, and copyright. The string that this method returns should be plain text and not markup of any kind (such as HTML, XML, etc.). | |
| getServletPath | back to summary |
|---|---|
| public String getServletPath() Return the Servlet path under which the Servlet is deployed by checking
the Servlet registration from
| |
| getServletPath | back to summary |
|---|---|
| private String getServletPath(ServletConfig config) | |
| init | back to summary |
|---|---|
| public void init(ServletConfig config) Implements jakarta. Doc from jakarta. Called by the servlet container to indicate to a servlet that the servlet is being placed into service.
The servlet container calls the
The servlet container cannot place the servlet into service if the
| |
| runIfAsyncNotComplete | back to summary |
|---|---|
| private static void runIfAsyncNotComplete(AsyncContext asyncContext, AtomicBoolean isCompleted, Runnable task) | |
| service | back to summary |
|---|---|
| public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException Implements jakarta. Doc from jakarta. Called by the servlet container to allow the servlet to respond to a request.
This method is only called after the servlet's The status code of the response always should be set for a servlet that throws or sends an error. Servlets typically run inside multithreaded servlet containers that can handle multiple requests concurrently. Developers must be aware to synchronize access to any shared resources such as files, network connections, and as well as the servlet's class and instance variables. More information on multithreaded programming in Java is available in the Java tutorial on multi-threaded programming.
| |
| setBufferSize | back to summary |
|---|---|
| public void setBufferSize(int bufferSize) Set the size of the input buffer used for reading in bytes. By default this is set to 8192. | |
| setDataBufferFactory | back to summary |
|---|---|
| public void setDataBufferFactory(DataBufferFactory dataBufferFactory) | |
| Modifier and Type | Field and Description |
|---|---|
| private final AsyncContext | |
| private final AtomicBoolean | |
| private final String | |
| private volatile Subscription |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | onError(Throwable
the throwable signaled ex)Implements org. Failed terminal state. |
| public void | onNext(Void
the element signaled aVoid)Implements org. Data notification sent by the |
| public void | onSubscribe(Subscription
the subscription)Subscription that allows requesting data via Subscription#request(long)Implements org. Invoked after calling |
| public void |
| asyncContext | back to summary |
|---|---|
| private final AsyncContext asyncContext | |
| completionFlag | back to summary |
|---|---|
| private final AtomicBoolean completionFlag | |
| logPrefix | back to summary |
|---|---|
| private final String logPrefix | |
| subscription | back to summary |
|---|---|
| private volatile Subscription subscription
| |
| HandlerResultSubscriber | back to summary |
|---|---|
| public HandlerResultSubscriber(AsyncContext asyncContext, AtomicBoolean completionFlag, String logPrefix) | |
| onComplete | back to summary |
|---|---|
| public void onComplete() Implements org. Doc from org. Successful terminal state.
No further events will be sent even if
| |
| onError | back to summary |
|---|---|
| public void onError(Throwable ex) Implements org. Doc from org. Failed terminal state.
No further events will be sent even if | |
| onNext | back to summary |
|---|---|
| public void onNext(Void aVoid) Implements org. Doc from org. Data notification sent by the | |
| onSubscribe | back to summary |
|---|---|
| public void onSubscribe(Subscription subscription) Implements org. Doc from org. Invoked after calling
No data will start flowing until
It is the responsibility of this
The
| |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |
AsyncContext in case of error or
timeout notifications from the container
Additional AsyncListeners are registered in
ServletServerHttpRequest to signal onError/onComplete to the
request body Subscriber, and in ServletServerHttpResponse to
cancel the write Publisher and signal onError/onComplete downstream to
the writing result Subscriber.
| Modifier and Type | Field and Description |
|---|---|
| private final AtomicBoolean | |
| private final Runnable | |
| private final String | |
| private final AsyncListener | |
| private final AsyncListener |
| Access | Constructor and Description |
|---|---|
| public | HttpHandlerAsyncListener(AsyncListener requestAsyncListener, AsyncListener responseAsyncListener, Runnable handlerDisposeTask, AtomicBoolean completionFlag, String logPrefix)
|
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| private static void | |
| private static void | |
| private void | |
| public void | onComplete(AsyncEvent
Provides access to the objects associated with the event event)Implements jakarta. This event is fired after the call to |
| public void | onError(AsyncEvent
Provides access to the objects associated with the event event)Implements jakarta. This event is fired if an error occurs during an asynchronous operation but before the container takes any action as a result of the error. |
| public void | onStartAsync(AsyncEvent
Provides access to the objects associated with the event event)Implements jakarta. This event is fired if new call is made to |
| public void | onTimeout(AsyncEvent
Provides access to the objects associated with the event event)Implements jakarta. This event is fired if an asynchronous operation times out but before the container takes any action as a result of the timeout. |
| completionFlag | back to summary |
|---|---|
| private final AtomicBoolean completionFlag | |
| handlerDisposeTask | back to summary |
|---|---|
| private final Runnable handlerDisposeTask | |
| logPrefix | back to summary |
|---|---|
| private final String logPrefix | |
| requestAsyncListener | back to summary |
|---|---|
| private final AsyncListener requestAsyncListener | |
| responseAsyncListener | back to summary |
|---|---|
| private final AsyncListener responseAsyncListener | |
| HttpHandlerAsyncListener | back to summary |
|---|---|
| public HttpHandlerAsyncListener(AsyncListener requestAsyncListener, AsyncListener responseAsyncListener, Runnable handlerDisposeTask, AtomicBoolean completionFlag, String logPrefix) | |
| delegateComplete | back to summary |
|---|---|
| private static void delegateComplete(AsyncListener listener, AsyncEvent event) | |
| delegateError | back to summary |
|---|---|
| private static void delegateError(AsyncListener listener, AsyncEvent event) | |
| delegateTimeout | back to summary |
|---|---|
| private static void delegateTimeout(AsyncListener listener, AsyncEvent event) | |
| handleTimeoutOrError | back to summary |
|---|---|
| private void handleTimeoutOrError(AsyncEvent event) | |
| onComplete | back to summary |
|---|---|
| public void onComplete(AsyncEvent event) Implements jakarta. Doc from jakarta. This event is fired after the call to
| |
| onError | back to summary |
|---|---|
| public void onError(AsyncEvent event) Implements jakarta. Doc from jakarta. This event is fired if an error occurs during an asynchronous operation but before the container takes any action as a result of the error.
| |
| onStartAsync | back to summary |
|---|---|
| public void onStartAsync(AsyncEvent event) Implements jakarta. Doc from jakarta. This event is fired if new call is made to
| |
| onTimeout | back to summary |
|---|---|
| public void onTimeout(AsyncEvent event) Implements jakarta. Doc from jakarta. This event is fired if an asynchronous operation times out but before the container takes any action as a result of the timeout.
| |