Class FileCachingHttpClientBuilder.StorageManagingHttpClient

java.lang.Object
org.apache.http.impl.client.CloseableHttpClient
net.shibboleth.utilities.java.support.httpclient.FileCachingHttpClientBuilder.StorageManagingHttpClient
All Implemented Interfaces:
Closeable, AutoCloseable, Component, DestructableComponent, InitializableComponent, org.apache.http.client.HttpClient
Enclosing class:
FileCachingHttpClientBuilder

private static class FileCachingHttpClientBuilder.StorageManagingHttpClient extends org.apache.http.impl.client.CloseableHttpClient implements InitializableComponent, DestructableComponent
Class which wraps a caching instance of CloseableHttpClient and its associated ManagedHttpCacheStorage, and manages the scheduled maintenance and lifecycle of the latter.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    Destroyed flag.
    private org.apache.http.impl.client.CloseableHttpClient
    The wrapped HttpClient instance.
    private boolean
    Initialized flag.
    private org.slf4j.Logger
    Logger.
    private TimerTask
    The scheduled storage maintenance task.
    private long
    Interval of the scheduled maintenance task.
    private org.apache.http.impl.client.cache.ManagedHttpCacheStorage
    The cache storage instance to manage.
    private Timer
    Scheduled task timer.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StorageManagingHttpClient(org.apache.http.impl.client.CloseableHttpClient wrappedClient, org.apache.http.impl.client.cache.ManagedHttpCacheStorage managedStorage, long taskInterval)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    void
    Destroys the component.
    protected org.apache.http.client.methods.CloseableHttpResponse
    doExecute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.protocol.HttpContext context)
    org.apache.http.conn.ClientConnectionManager
    Deprecated.
    org.apache.http.params.HttpParams
    Deprecated.
    void
    Initializes the component.
    boolean
    Gets whether this component has been destroyed.
    boolean
    Gets whether this component is initialized.

    Methods inherited from class org.apache.http.impl.client.CloseableHttpClient

    execute, execute, execute, execute, execute, execute, execute, execute

    Methods inherited from class java.lang.Object

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

    • log

      private org.slf4j.Logger log
      Logger.
    • httpClient

      private org.apache.http.impl.client.CloseableHttpClient httpClient
      The wrapped HttpClient instance.
    • storage

      private org.apache.http.impl.client.cache.ManagedHttpCacheStorage storage
      The cache storage instance to manage.
    • maintenanceTaskInterval

      private long maintenanceTaskInterval
      Interval of the scheduled maintenance task.
    • initialized

      private boolean initialized
      Initialized flag.
    • destroyed

      private boolean destroyed
      Destroyed flag.
    • timer

      private Timer timer
      Scheduled task timer.
    • maintenanceTask

      private TimerTask maintenanceTask
      The scheduled storage maintenance task.
  • Constructor Details

    • StorageManagingHttpClient

      public StorageManagingHttpClient(@Nonnull org.apache.http.impl.client.CloseableHttpClient wrappedClient, @Nonnull org.apache.http.impl.client.cache.ManagedHttpCacheStorage managedStorage, long taskInterval)
      Constructor.
      Parameters:
      wrappedClient - the wrapped HttpClient instance
      managedStorage - the managed cache storage instance
      taskInterval - the interval at which storage maintenance should run
  • Method Details

    • doExecute

      protected org.apache.http.client.methods.CloseableHttpResponse doExecute(org.apache.http.HttpHost target, org.apache.http.HttpRequest request, org.apache.http.protocol.HttpContext context) throws IOException, org.apache.http.client.ClientProtocolException
      Specified by:
      doExecute in class org.apache.http.impl.client.CloseableHttpClient
      Throws:
      IOException
      org.apache.http.client.ClientProtocolException
    • getParams

      @Deprecated public org.apache.http.params.HttpParams getParams()
      Deprecated.
      Specified by:
      getParams in interface org.apache.http.client.HttpClient
    • getConnectionManager

      @Deprecated public org.apache.http.conn.ClientConnectionManager getConnectionManager()
      Deprecated.
      Specified by:
      getConnectionManager in interface org.apache.http.client.HttpClient
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • isInitialized

      public boolean isInitialized()
      Gets whether this component is initialized.
      Specified by:
      isInitialized in interface InitializableComponent
      Returns:
      true iff this component is initialized
    • isDestroyed

      public boolean isDestroyed()
      Gets whether this component has been destroyed. Normally, once a component has been destroyed it cannot be used.
      Specified by:
      isDestroyed in interface DestructableComponent
      Returns:
      true iff the component has been destroyed
    • initialize

      public void initialize() throws ComponentInitializationException
      Initializes the component.
      Specified by:
      initialize in interface InitializableComponent
      Throws:
      ComponentInitializationException - thrown if there is a problem initializing the component
    • destroy

      public void destroy()
      Destroys the component.
      Specified by:
      destroy in interface DestructableComponent