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); } });

  • Constructor Details

    • NodesResponseRestListener

      public NodesResponseRestListener​(RestChannel channel)
  • Method Details

    • buildResponse

      public RestResponse buildResponse​(NodesResponse response, org.elasticsearch.common.xcontent.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 provided XContentBuilder using the XContentBuilder.close() method.
      Specified by:
      buildResponse in class RestBuilderListener<NodesResponse extends BaseNodesResponse & org.elasticsearch.common.xcontent.ToXContent>
      Throws:
      java.lang.Exception