Class ClosableCallback

  • All Implemented Interfaces:
    org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse>

    public class ClosableCallback
    extends java.lang.Object
    implements org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse>
    Java 7's try-with-resource closes the client before the future is completed. This callback captures the client and closes it once the request is completed. See also http://stackoverflow.com/a/35962718/368220.
    • Constructor Summary

      Constructors 
      ConstructorDescription
      ClosableCallback​(org.apache.http.impl.nio.client.CloseableHttpAsyncClient closeableHttpAsyncClient) 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidcancelled() 
      voidcompleted​(org.apache.http.HttpResponse httpResponse) 
      voidfailed​(java.lang.Exception e) 
      • Methods inherited from class java.lang.Object

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

      • ClosableCallback

        public ClosableCallback​(org.apache.http.impl.nio.client.CloseableHttpAsyncClient closeableHttpAsyncClient)
    • Method Detail

      • completed

        public void completed​(org.apache.http.HttpResponse httpResponse)
        Specified by:
        completed in interface org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse>
      • failed

        public void failed​(java.lang.Exception e)
        Specified by:
        failed in interface org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse>
      • cancelled

        public void cancelled()
        Specified by:
        cancelled in interface org.apache.http.concurrent.FutureCallback<org.apache.http.HttpResponse>