Package org.elasticsearch.rest.action
Class RestActions.NodesResponseRestListener<NodesResponse extends BaseNodesResponse & 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 & ToXContent> extends RestBuilderListener<NodesResponse>
NodesResponseRestBuilderListener
automatically translates anyBaseNodesResponse
(multi-node) response that isToXContent
-compatible into aRestResponse
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
-
Fields inherited from class org.elasticsearch.rest.action.RestActionListener
channel
-
-
Constructor Summary
Constructors Constructor Description NodesResponseRestListener(RestChannel channel)
-
Method Summary
Modifier and Type Method Description RestResponse
buildResponse(NodesResponse response, XContentBuilder builder)
Builds a response to send back over the channel.-
Methods inherited from class org.elasticsearch.rest.action.RestBuilderListener
buildResponse
-
Methods inherited from class org.elasticsearch.rest.action.RestResponseListener
processResponse
-
Methods inherited from class org.elasticsearch.rest.action.RestActionListener
onFailure, onResponse
-
-
-
-
Constructor Detail
-
NodesResponseRestListener
public NodesResponseRestListener(RestChannel channel)
-
-
Method Detail
-
buildResponse
public RestResponse buildResponse(NodesResponse response, XContentBuilder builder) throws java.lang.Exception
Description 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 & ToXContent>
- Throws:
java.lang.Exception
-
-