Class DropwizardApacheConnector

java.lang.Object
io.dropwizard.client.DropwizardApacheConnector
All Implemented Interfaces:
org.glassfish.jersey.client.spi.Connector, org.glassfish.jersey.process.Inflector<org.glassfish.jersey.client.ClientRequest,org.glassfish.jersey.client.ClientResponse>

public class DropwizardApacheConnector extends Object implements org.glassfish.jersey.client.spi.Connector
Dropwizard Apache Connector.

It's a custom version of Jersey's Connector that uses Apache's HttpClient as an HTTP transport implementation.

It uses a pre-configured HTTP client by HttpClientBuilder rather then creates a client from the Jersey configuration.

This approach affords to use the extended configuration of the Apache HttpClient in Dropwizard with a fluent interface of JerseyClient.

  • Constructor Summary

    Constructors
    Constructor
    Description
    DropwizardApacheConnector(org.apache.hc.client5.http.impl.classic.CloseableHttpClient client, @Nullable org.apache.hc.client5.http.config.RequestConfig defaultRequestConfig, boolean chunkedEncodingEnabled)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.glassfish.jersey.client.ClientResponse
    apply(org.glassfish.jersey.client.ClientRequest jerseyRequest)
    apply(org.glassfish.jersey.client.ClientRequest request, org.glassfish.jersey.client.spi.AsyncConnectorCallback callback)
    void
    protected @Nullable org.apache.hc.core5.http.HttpEntity
    getHttpEntity(org.glassfish.jersey.client.ClientRequest jerseyRequest)
    Get an Apache's HttpEntity from Jersey's ClientRequest

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DropwizardApacheConnector

      public DropwizardApacheConnector(org.apache.hc.client5.http.impl.classic.CloseableHttpClient client, @Nullable org.apache.hc.client5.http.config.RequestConfig defaultRequestConfig, boolean chunkedEncodingEnabled)
  • Method Details

    • apply

      public org.glassfish.jersey.client.ClientResponse apply(org.glassfish.jersey.client.ClientRequest jerseyRequest)
      Specified by:
      apply in interface org.glassfish.jersey.client.spi.Connector
      Specified by:
      apply in interface org.glassfish.jersey.process.Inflector<org.glassfish.jersey.client.ClientRequest,org.glassfish.jersey.client.ClientResponse>
    • getHttpEntity

      protected @Nullable org.apache.hc.core5.http.HttpEntity getHttpEntity(org.glassfish.jersey.client.ClientRequest jerseyRequest)
      Get an Apache's HttpEntity from Jersey's ClientRequest

      Create a custom HTTP entity, because Jersey doesn't provide a request stream or a byte buffer.

      Parameters:
      jerseyRequest - representation of an HTTP request in Jersey
      Returns:
      a correct HttpEntity implementation
    • apply

      public Future<?> apply(org.glassfish.jersey.client.ClientRequest request, org.glassfish.jersey.client.spi.AsyncConnectorCallback callback)
      Specified by:
      apply in interface org.glassfish.jersey.client.spi.Connector
    • getName

      public String getName()
      Specified by:
      getName in interface org.glassfish.jersey.client.spi.Connector
    • close

      public void close()
      Specified by:
      close in interface org.glassfish.jersey.client.spi.Connector