HandlerContainer that allows a hot swap of a wrapped handler.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | destroy()
Overrides org. Implements org. |
| public Handler | Returns: Returns the handlers.Implements org. |
| public Invocable. | |
| public boolean | handle(Request
the HTTP request to handle request, Response the HTTP response to handle response, Callback the callback to complete when the handling is complete callback)Implements org. Invoked to handle the passed HTTP request and response. |
| public void | setHandler(Handler
Set the handler)Handler which should be wrapped.Implements org. |
| _handler | back to summary |
|---|---|
| private volatile Handler _handler | |
| HotSwapHandler | back to summary |
|---|---|
| public HotSwapHandler() | |
| destroy | back to summary |
|---|---|
| public void destroy() Overrides org. Implements org. Doc from org. Destroys the managed Destroyable beans in the reverse order they were added.
| |
| getHandler | back to summary |
|---|---|
| public Handler getHandler() Implements org.
| |
| getInvocationType | back to summary |
|---|---|
| public Invocable. Overrides org. Overrides default org.
| |
| handle | back to summary |
|---|---|
| public boolean handle(Request request, Response response, Callback callback) throws Exception Implements org. Doc from org. Invoked to handle the passed HTTP request and response. The request is accepted by returning true, then handling must be concluded by completing the passed callback. The handling may be asynchronous, i.e. this method may return true and complete the given callback later, possibly from a different thread. If this method returns false, then the callback must not be invoked and any mutation on the response reversed. Exceptions thrown by this method may be subsequently handled by an error The simplest implementation is:
public boolean handle(Request request, Response response, Callback callback)
{
callback.succeeded();
return true;
}
A HelloWorld implementation is:
public boolean handle(Request request, Response response, Callback callback)
{
response.write(true, ByteBuffer.wrap("Hello World\n".getBytes(StandardCharsets.UTF_8)), callback);
return true;
}
| |
| setHandler | back to summary |
|---|---|
| public void setHandler(Handler handler) Implements org. | |