Package org.elasticsearch.rest.action
Class RestActions.NodesResponseRestListener<NodesResponse extends BaseNodesResponse & org.elasticsearch.common.xcontent.ToXContent>
java.lang.Object
org.elasticsearch.rest.action.RestActionListener<Response>
org.elasticsearch.rest.action.RestResponseListener<Response>
org.elasticsearch.rest.action.RestBuilderListener<NodesResponse>
org.elasticsearch.rest.action.RestActions.NodesResponseRestListener<NodesResponse>
- All Implemented Interfaces:
ActionListener<NodesResponse>
- Enclosing class:
- RestActions
public static class RestActions.NodesResponseRestListener<NodesResponse extends BaseNodesResponse & org.elasticsearch.common.xcontent.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);
}
});
-
Field Summary
-
Constructor Summary
Constructors Constructor Description NodesResponseRestListener(RestChannel channel)
-
Method Summary
Modifier and Type Method Description RestResponse
buildResponse(NodesResponse response, org.elasticsearch.common.xcontent.XContentBuilder builder)
Builds a response to send back over the channel.
-
Constructor Details
-
Method Details
-
buildResponse
public RestResponse buildResponse(NodesResponse response, org.elasticsearch.common.xcontent.XContentBuilder builder) throws java.lang.ExceptionDescription copied from class:RestBuilderListener
Builds a response to send back over the channel. Implementors should ensure that they close the providedXContentBuilder
using theXContentBuilder.close()
method.- Specified by:
buildResponse
in classRestBuilderListener<NodesResponse extends BaseNodesResponse & org.elasticsearch.common.xcontent.ToXContent>
- Throws:
java.lang.Exception
-