ClusterManagementServiceProvider (Apache Geode 1.9.0)
Date: 2019-04-19

org.apache.geode.management.client

## Class ClusterManagementServiceProvider

- java.lang.Object
- - org.apache.geode.management.client.ClusterManagementServiceProvider

-     @Experimental
      public class ClusterManagementServiceProvider
      extends Object

  Top-level entry point for client interaction with the `ClusterManagementService`. A user can create an instance of the `ClusterManagementService` (CMS for short) in several ways, each providing various level of control or expediency.

  Calling `getServiceFactory(context)` will return an explicit instance of `ClusterManagementServiceFactory`. Methods on this factory can then be called to create or retrieve instances of a CMS. New `ClusterManagementServiceProvider`s can be written if specific customization or parameterization is required.

  A note about contexts. A context is simply a unique string which identifies a specific instance of CMS that will be returned. Contexts map to the different uses of a CMS. Currently, the following contexts are provided:
  - `JAVA_CLIENT_CONTEXT` ("java-client") - would be used to retrieve a CMS instance on a pure Java client - i.e. an app that is not running in the context of a Geode client or server. This context is available when using the geode-management module.
  - `GEODE_CONTEXT` ("geode") - would be used to retrieve a CMS instance from a JVM where either a `Cache` or `ClientCache` exists. This context is available when using the geode-core module.
  If the URL of the Cluster Management Service is known, the `getService(url)` method can be called. This implicitly uses the `JAVA_CLIENT_CONTEXT`. For further control the CMS can be configured with a `ClientHttpRequestFactory` by calling `getService(requestFactory)`.

  Finally, the simplest way to create a CMS instance is simply to call `getService()`. This method will attempt to infer the context and use an appropriate service provider to create a CMS instance.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `GEODE_CONTEXT`
    `static String` | `JAVA_CLIENT_CONTEXT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClusterManagementServiceProvider()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static ClusterManagementService` | `getService()` use this to get the ClusterManagementService from the locator, or from a server that connects to a locator with no security manager.
    `static ClusterManagementService` | `getService(org.springframework.http.client.ClientHttpRequestFactory requestFactory)` Retrieve a `ClusterManagementService` instance configured with a `ClientHttpRequestFactory` with a general requestFactory.
    `static ClusterManagementService` | `getService(String host, int port)` Retrieve a `ClusterManagementService` instance configured with an explicit service endpoint.
    `static ClusterManagementService` | `getService(String host, int port, SSLContext sslContext, HostnameVerifier hostnameVerifier, String username, String password)` Retrieve a `ClusterManagementService` instance configured with an explicit service endpoint.
    `static ClusterManagementService` | `getService(String username, String password)` use this retrieve a ClusterManagementService from a server that connects to a secured locator

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### JAVA_CLIENT_CONTEXT

          public static final String JAVA_CLIENT_CONTEXT

      See Also:
        Constant Field Values

    - #### GEODE_CONTEXT

          public static final String GEODE_CONTEXT

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ClusterManagementServiceProvider

          public ClusterManagementServiceProvider()

  - ### Method Detail

    - #### getService

          public static ClusterManagementService getService()

      use this to get the ClusterManagementService from the locator, or from a server that connects to a locator with no security manager.

    - #### getService

          public static ClusterManagementService getService(String username,
                                                            String password)

      use this retrieve a ClusterManagementService from a server that connects to a secured locator

    - #### getService

          public static ClusterManagementService getService(String host,
                                                            int port)

      Retrieve a `ClusterManagementService` instance configured with an explicit service endpoint. this is good for end point with no ssl nor security turned on.

      For example:

           ClusterManagementServiceProvider.getService("locatorHost", "7070")

      Throws:
        `IllegalArgumentException` - if the provided url is malformed

    - #### getService

          public static ClusterManagementService getService(String host,
                                                            int port,
                                                            SSLContext sslContext,
                                                            HostnameVerifier hostnameVerifier,
                                                            String username,
                                                            String password)

      Retrieve a `ClusterManagementService` instance configured with an explicit service endpoint. This service will allow you to connect to ssl enabled and security enabled end point with the specified sslContext and hostnameVerifier
      Parameters:
        `host` - the locator's host name
        `port` - http port of the locator
        `sslContext` - a pre configured sslContext to connect with
        `hostnameVerifier` - a pre configured hostnameVerifier to connect with
        `username` - if cluster has security manager, use this username to connect
        `password` - if cluster has security manager, use this password to connect

    - #### getService

          public static ClusterManagementService getService(org.springframework.http.client.ClientHttpRequestFactory requestFactory)

      Retrieve a `ClusterManagementService` instance configured with a `ClientHttpRequestFactory` with a general requestFactory. you can configure the requestFactory to tailor to your need to connect to the end point.
      Parameters:
        `requestFactory` - the Request Factory configured with the URL of the Cluster Management Service running on a locator. The port used is as configured by the http-service-port property on the Geode locator.
      Returns:
        a `ClusterManagementService` instance configured to connect to the service endpoint.