HttpHandler
public class GracefulShutdownHandler extends Object implements HttpHandler
The handler itself does not shut anything down.
Import: The thread safety semantics of the handler are very important. Don't touch anything unless you know what you are doing.
Modifier and Type | Class | Description |
---|---|---|
static interface |
GracefulShutdownHandler.ShutdownListener |
A listener which can be registered with the handler to be notified when all pending requests have finished.
|
Constructor | Description |
---|---|
GracefulShutdownHandler(HttpHandler next) |
Modifier and Type | Method | Description |
---|---|---|
void |
addShutdownListener(GracefulShutdownHandler.ShutdownListener shutdownListener) |
Adds a shutdown listener that will be invoked when all requests have finished.
|
void |
awaitShutdown() |
Waits for the handler to shutdown.
|
boolean |
awaitShutdown(long millis) |
Waits a set length of time for the handler to shut down
|
void |
handleRequest(HttpServerExchange exchange) |
Handle the request.
|
void |
shutdown() |
|
void |
start() |
public GracefulShutdownHandler(HttpHandler next)
public void handleRequest(HttpServerExchange exchange) throws Exception
HttpHandler
handleRequest
in interface HttpHandler
exchange
- the HTTP request/response exchangeException
public void shutdown()
public void start()
public void awaitShutdown() throws InterruptedException
InterruptedException
public boolean awaitShutdown(long millis) throws InterruptedException
millis
- The length of timetrue
If the handler successfully shut downInterruptedException
public void addShutdownListener(GracefulShutdownHandler.ShutdownListener shutdownListener)
shutdownListener
- The shutdown listenerCopyright © 2018. All rights reserved.