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 and Description |
---|
NodesResponseRestListener(RestChannel channel) |
Modifier and Type | Method and Description |
---|---|
RestResponse |
buildResponse(NodesResponse response,
XContentBuilder builder)
Builds a response to send back over the channel.
|
buildResponse
processResponse
onFailure, onResponse
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onFailure, onResponse, wrap
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