package io.georocket.client;

import java.io.Closeable;

import io.vertx.core.Vertx;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientOptions;

/**
 * Provides interface to perform operations against a GeoRocket server
 * @since 1.0.0
 * @author Michel Kraemer
 */
public class GeoRocketClient implements Closeable {
  /**
   * Default server host: "localhost"
   */
  public static final String DEFAULT_HOST = "localhost";
  
  /**
   * Default server port: 63020
   */
  public static final int DEFAULT_PORT = 63020;
  
  /**
   * HTTP client used to connect to GeoRocket
   */
  private final HttpClient client;
  
  /**
   * Create a client connecting to GeoRocket running on
   * {@value #DEFAULT_HOST}:{@value #DEFAULT_PORT}
   * @param vertx a Vert.x instance used to create a HTTP client
   */
  public GeoRocketClient(Vertx vertx) {
    this(DEFAULT_HOST, vertx);
  }
  
  /**
   * Create a client connecting to GeoRocket running on the
   * specified host and the default port {@value #DEFAULT_PORT}
   * @param host the GeoRocket host
   * @param vertx a Vert.x instance used to create a HTTP client
   */
  public GeoRocketClient(String host, Vertx vertx) {
    this(host, DEFAULT_PORT, vertx);
  }
  
  /**
   * Create a client connecting to GeoRocket running on the
   * specified host and port
   * @param host the GeoRocket host
   * @param port the GeoRocket port
   * @param vertx a Vert.x instance used to create a HTTP client
   */
  public GeoRocketClient(String host, int port, Vertx vertx) {
    this(vertx.createHttpClient(new HttpClientOptions()
        .setDefaultHost(host)
        .setDefaultPort(port)));
  }
  
  /**
   * Create a client connecting to GeoRocket through the given
   * HTTP client
   * @param client the HTTP client
   */
  public GeoRocketClient(HttpClient client) {
    this.client = client;
  }
  
  /**
   * Close this client and release all resources
   */
  @Override
  public void close() {
    client.close();
  }
  
  /**
   * Create a new client accessing the GeoRocket data store
   * @return the store client
   */
  public StoreClient getStore() {
    return new StoreClient(client);
  }
}

@@ -606,13 +606,15 @@
   pr
-ivate
+otected
  fin
@@ -1653,24 +1653,341 @@
 port)));%0A  %7D
+%0A%0A  /**%0A   * Create a client connecting to GeoRocket running with%0A   * specified options%0A   * @param options options for HTTP client%0A   * @param vertx a Vert.x instance used to create a HTTP client%0A   */%0A  public GeoRocketClient(HttpClientOptions options, Vertx vertx) %7B%0A    this(vertx.createHttpClient(options));%0A  %7D
 %0A  %0A  /**%0A  

Implement new constructor to allow flexible http client options