ActionListener<NodesResponse>
public static class RestActions.NodesResponseRestListener<NodesResponse extends BaseNodesResponse & ToXContent> extends RestBuilderListener<NodesResponse>
NodesResponseRestBuilderListener
automatically translates any BaseNodesResponse
(multi-node) response that is
ToXContent
-compatible into a RestResponse
with the necessary header info (e.g., "cluster_name").
This is meant to avoid a slew of anonymous classes doing (or worse):
client.admin().cluster().request(nodesRequest, new RestBuilderListener<NodesResponse>(channel) {
public RestResponse buildResponse(NodesResponse response, XContentBuilder builder) throws Exception {
return RestActions.nodesResponse(builder, ToXContent.EMPTY_PARAMS, response);
}
});
channel
Constructor | Description |
---|---|
NodesResponseRestListener(RestChannel channel) |
Modifier and Type | Method | Description |
---|---|---|
RestResponse |
buildResponse(NodesResponse response,
XContentBuilder builder) |
Builds a response to send back over the channel.
|
onFailure, onResponse, toBiConsumer, wrap, wrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onFailure, onResponse
buildResponse
processResponse
public NodesResponseRestListener(RestChannel channel)
public RestResponse buildResponse(NodesResponse response, XContentBuilder builder) throws java.lang.Exception
RestBuilderListener
XContentBuilder
using the XContentBuilder.close()
method.buildResponse
in class RestBuilderListener<NodesResponse extends BaseNodesResponse & ToXContent>
java.lang.Exception