Class 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.http.impl.client.CloseableHttpClient client, org.apache.http.client.config.RequestConfig defaultRequestConfig, boolean chunkedEncodingEnabled)  
    • Constructor Detail

      • DropwizardApacheConnector

        public DropwizardApacheConnector​(org.apache.http.impl.client.CloseableHttpClient client,
                                         @Nullable
                                         org.apache.http.client.config.RequestConfig defaultRequestConfig,
                                         boolean chunkedEncodingEnabled)
    • Method Detail

      • 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

        @Nullable
        protected org.apache.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