Class ApacheConnector

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.apache.http.impl.client.CloseableHttpClient client  
      private org.apache.http.client.CookieStore cookieStore  
      private static java.util.logging.Logger LOGGER  
      private boolean preemptiveBasicAuth  
      private static java.lang.String release  
      private org.apache.http.client.config.RequestConfig requestConfig  
      private static org.apache.http.util.VersionInfo vi  
    • Constructor Summary

      Constructors 
      Constructor Description
      ApacheConnector​(javax.ws.rs.client.Client client, javax.ws.rs.core.Configuration config)
      Create the new Apache HTTP Client connector.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ClientResponse apply​(ClientRequest clientRequest)
      Synchronously process client request into a response.
      java.util.concurrent.Future<?> apply​(ClientRequest request, AsyncConnectorCallback callback)
      Asynchronously process client request into a response.
      void close()
      Close connector and release all it's internally associated resources.
      private org.apache.http.conn.HttpClientConnectionManager createConnectionManager​(javax.ws.rs.client.Client client, javax.ws.rs.core.Configuration config, javax.net.ssl.SSLContext sslContext, boolean useSystemProperties)  
      private org.apache.http.conn.HttpClientConnectionManager getConnectionManager​(javax.ws.rs.client.Client client, javax.ws.rs.core.Configuration config, javax.net.ssl.SSLContext sslContext)  
      org.apache.http.client.CookieStore getCookieStore()
      Get the CookieStore.
      private org.apache.http.HttpHost getHost​(org.apache.http.client.methods.HttpUriRequest request)  
      org.apache.http.client.HttpClient getHttpClient()
      Get the HttpClient.
      private org.apache.http.HttpEntity getHttpEntity​(ClientRequest clientRequest, boolean bufferingEnabled)  
      private static java.io.InputStream getInputStream​(org.apache.http.client.methods.CloseableHttpResponse response)  
      java.lang.String getName()
      Get name of current connector.
      private static java.net.URI getProxyUri​(java.lang.Object proxy)  
      private org.apache.http.client.methods.HttpUriRequest getUriHttpRequest​(ClientRequest clientRequest)  
      private static java.lang.String[] split​(java.lang.String s)  
      private static java.util.Map<java.lang.String,​java.lang.String> writeOutBoundHeaders​(javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.Object> headers, org.apache.http.client.methods.HttpUriRequest request)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • vi

        private static final org.apache.http.util.VersionInfo vi
      • release

        private static final java.lang.String release
      • client

        private final org.apache.http.impl.client.CloseableHttpClient client
      • cookieStore

        private final org.apache.http.client.CookieStore cookieStore
      • preemptiveBasicAuth

        private final boolean preemptiveBasicAuth
      • requestConfig

        private final org.apache.http.client.config.RequestConfig requestConfig
    • Constructor Detail

      • ApacheConnector

        ApacheConnector​(javax.ws.rs.client.Client client,
                        javax.ws.rs.core.Configuration config)
        Create the new Apache HTTP Client connector.
        Parameters:
        client - JAX-RS client instance for which the connector is being created.
        config - client configuration.
    • Method Detail

      • getConnectionManager

        private org.apache.http.conn.HttpClientConnectionManager getConnectionManager​(javax.ws.rs.client.Client client,
                                                                                      javax.ws.rs.core.Configuration config,
                                                                                      javax.net.ssl.SSLContext sslContext)
      • createConnectionManager

        private org.apache.http.conn.HttpClientConnectionManager createConnectionManager​(javax.ws.rs.client.Client client,
                                                                                         javax.ws.rs.core.Configuration config,
                                                                                         javax.net.ssl.SSLContext sslContext,
                                                                                         boolean useSystemProperties)
      • split

        private static java.lang.String[] split​(java.lang.String s)
      • getHttpClient

        public org.apache.http.client.HttpClient getHttpClient()
        Get the HttpClient.
        Returns:
        the HttpClient.
      • getProxyUri

        private static java.net.URI getProxyUri​(java.lang.Object proxy)
      • apply

        public ClientResponse apply​(ClientRequest clientRequest)
                             throws javax.ws.rs.ProcessingException
        Description copied from interface: Connector
        Synchronously process client request into a response. The method is used by Jersey client runtime to synchronously send a request and receive a response.
        Specified by:
        apply in interface Connector
        Specified by:
        apply in interface Inflector<ClientRequest,​ClientResponse>
        Parameters:
        clientRequest - Jersey client request to be sent.
        Returns:
        Jersey client response received for the client request.
        Throws:
        javax.ws.rs.ProcessingException - in case of any invocation failure.
      • apply

        public java.util.concurrent.Future<?> apply​(ClientRequest request,
                                                    AsyncConnectorCallback callback)
        Description copied from interface: Connector
        Asynchronously process client request into a response. The method is used by Jersey client runtime to asynchronously send a request and receive a response.
        Specified by:
        apply in interface Connector
        Parameters:
        request - Jersey client request to be sent.
        callback - Jersey asynchronous connector callback to asynchronously receive the request processing result (either a response or a failure).
        Returns:
        asynchronously executed task handle.
      • getName

        public java.lang.String getName()
        Description copied from interface: Connector
        Get name of current connector. Should contain identification of underlying specification and optionally version number. Will be used in User-Agent header.
        Specified by:
        getName in interface Connector
        Returns:
        name of current connector. Returning null or empty string means not including this information in a generated "User-Agent" header.
      • close

        public void close()
        Description copied from interface: Connector
        Close connector and release all it's internally associated resources.
        Specified by:
        close in interface Connector
      • getHost

        private org.apache.http.HttpHost getHost​(org.apache.http.client.methods.HttpUriRequest request)
      • getUriHttpRequest

        private org.apache.http.client.methods.HttpUriRequest getUriHttpRequest​(ClientRequest clientRequest)
      • getHttpEntity

        private org.apache.http.HttpEntity getHttpEntity​(ClientRequest clientRequest,
                                                         boolean bufferingEnabled)
      • writeOutBoundHeaders

        private static java.util.Map<java.lang.String,​java.lang.String> writeOutBoundHeaders​(javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.Object> headers,
                                                                                                   org.apache.http.client.methods.HttpUriRequest request)
      • getInputStream

        private static java.io.InputStream getInputStream​(org.apache.http.client.methods.CloseableHttpResponse response)
                                                   throws java.io.IOException
        Throws:
        java.io.IOException