Interface HttpClientFactory


public interface HttpClientFactory
Factory for building pre-configured HttpClient Fluent Executor and Request objects based on a configured host, port and (optionally) username/password. Each OSGi configuration with factory PID com.adobe.acs.commons.http.impl.HttpClientFactoryImpl exposes one service of this kind. The individual factories will generally be accessed by service lookup using the factory.name property. Despite the name each instance of this interface only holds a single Executor instance (bound to a single HttpClient).
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    customize(Consumer<org.apache.http.impl.client.HttpClientBuilder> builderCustomizer)
    Customizes the underlying HttpClientBuilder which is used to create the singleton http client and executor
    org.apache.http.client.fluent.Request
    delete(String partialUrl)
    Create a DELETE request using the base hostname and port defined in the factory configuration.
    org.apache.http.client.fluent.Request
    get(String partialUrl)
    Create a GET request using the base hostname and port defined in the factory configuration.
    org.apache.http.client.fluent.Executor
    Get the singleton Executor object.
    org.apache.http.client.fluent.Request
    options(String partialUrl)
    Create a OPTIONS request using the base hostname and port defined in the factory configuration.
    org.apache.http.client.fluent.Request
    post(String partialUrl)
    Create a POST request using the base hostname and port defined in the factory configuration.
    org.apache.http.client.fluent.Request
    put(String partialUrl)
    Create a PUT request using the base hostname and port defined in the factory configuration.
  • Method Details

    • customize

      void customize(Consumer<org.apache.http.impl.client.HttpClientBuilder> builderCustomizer)
      Customizes the underlying HttpClientBuilder which is used to create the singleton http client and executor
      Parameters:
      builderCustomizer - a Consumer taking the HttpClientBuilder initialized with the configured basic options.
      Throws:
      IllegalStateException - in case getExecutor() has been called already
      Since:
      2.1.0 (Bundle version 6.4.0)
    • getExecutor

      org.apache.http.client.fluent.Executor getExecutor()
      Get the singleton Executor object.
      Returns:
      the executor
    • get

      org.apache.http.client.fluent.Request get(String partialUrl)
      Create a GET request using the base hostname and port defined in the factory configuration.
      Parameters:
      partialUrl - the portion of the URL after the port (and slash)
      Returns:
      a fluent Request object
    • put

      org.apache.http.client.fluent.Request put(String partialUrl)
      Create a PUT request using the base hostname and port defined in the factory configuration.
      Parameters:
      partialUrl - the portion of the URL after the port (and slash)
      Returns:
      a fluent Request object
    • post

      org.apache.http.client.fluent.Request post(String partialUrl)
      Create a POST request using the base hostname and port defined in the factory configuration.
      Parameters:
      partialUrl - the portion of the URL after the port (and slash)
      Returns:
      a fluent Request object
    • delete

      org.apache.http.client.fluent.Request delete(String partialUrl)
      Create a DELETE request using the base hostname and port defined in the factory configuration.
      Parameters:
      partialUrl - the portion of the URL after the port (and slash)
      Returns:
      a fluent Request object
    • options

      org.apache.http.client.fluent.Request options(String partialUrl)
      Create a OPTIONS request using the base hostname and port defined in the factory configuration.
      Parameters:
      partialUrl - the portion of the URL after the port (and slash)
      Returns:
      a fluent Request object