Class ApacheHTTPSender

  • All Implemented Interfaces:
    HTTPSender

    final class ApacheHTTPSender
    extends java.lang.Object
    implements HTTPSender
    Implementation of the HTTPSender interface which uses the Apache HttpClient API to send messages to the connection manager.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private BOSHClientConfig cfg
      Session configuration.
      private org.apache.http.client.HttpClient httpClient
      HttpClient instance to use to communicate.
      private java.util.concurrent.locks.Lock lock
      Lock used for internal synchronization.
    • Constructor Summary

      Constructors 
      Constructor Description
      ApacheHTTPSender()
      Prevent construction apart from our package.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()
      Dispose of all resources used to provide the required services.
      void init​(BOSHClientConfig session)
      Initialize the HTTP sender instance for use with the session provided.
      private org.apache.http.client.HttpClient initHttpClient​(BOSHClientConfig config)  
      HTTPResponse send​(CMSessionParams params, AbstractBody body)
      Create a Callable instance which can be used to send the request specified to the connection manager.
      • Methods inherited from class java.lang.Object

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

      • lock

        private final java.util.concurrent.locks.Lock lock
        Lock used for internal synchronization.
      • httpClient

        private org.apache.http.client.HttpClient httpClient
        HttpClient instance to use to communicate.
    • Constructor Detail

      • ApacheHTTPSender

        ApacheHTTPSender()
        Prevent construction apart from our package.
    • Method Detail

      • init

        public void init​(BOSHClientConfig session)
        Initialize the HTTP sender instance for use with the session provided. This method will be called once before use of the service instance.
        Specified by:
        init in interface HTTPSender
        Parameters:
        session - session configuration
      • destroy

        public void destroy()
        Dispose of all resources used to provide the required services. This method will be called once when the service instance is no longer required.
        Specified by:
        destroy in interface HTTPSender
      • send

        public HTTPResponse send​(CMSessionParams params,
                                 AbstractBody body)
        Create a Callable instance which can be used to send the request specified to the connection manager. This method should return immediately, prior to doing any real work. The invocation of the returned Callable should send the request (if it has not already been sent by the time of the call), block while waiting for the response, and then return the response body.
        Specified by:
        send in interface HTTPSender
        Parameters:
        params - CM session creation resopnse params
        body - request body to send
        Returns:
        callable used to access the response
      • initHttpClient

        private org.apache.http.client.HttpClient initHttpClient​(BOSHClientConfig config)