Package io.fabric8.mockwebserver.http
Class Dispatcher
- java.lang.Object
-
- io.fabric8.mockwebserver.http.Dispatcher
-
- Direct Known Subclasses:
CrudDispatcher,MockDispatcher,QueueDispatcher
public abstract class Dispatcher extends Object
Handler for mock server requests.
-
-
Constructor Summary
Constructors Constructor Description Dispatcher()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract MockResponsedispatch(RecordedRequest request)Returns a response to satisfyrequest.voidreleaseResources()Release any per-connection resources that must outlive in-flight dispatches.voidshutdown()Release any resources held by this dispatcher.
-
-
-
Method Detail
-
dispatch
public abstract MockResponse dispatch(RecordedRequest request)
Returns a response to satisfyrequest. This method may block (for instance, to wait on a CountdownLatch).
-
shutdown
public void shutdown()
Release any resources held by this dispatcher. Any requests that are currently being dispatched should return immediately. Responses returned after shutdown will not be transmitted: their socket connections have already been closed.
-
releaseResources
public void releaseResources()
Release any per-connection resources that must outlive in-flight dispatches.Called after the HTTP server has stopped accepting new connections, so it is safe to tear down state that an in-flight handler might otherwise touch (for example a WebSocket session's
ScheduledExecutorServiceused to deliveronOpenmessages).Note: Vert.x
HttpServer.close()does not strictly wait for every in-flight WebSocket upgrade to deliver itsonOpencallback before completing, so callers that schedule onto resources released here must still be defensive against a shutdown that races with a late upgrade (seeWebSocketSession.send).The default implementation is a no-op.
-
-