Class FileCachingHttpClientBuilder.StorageManagingHttpClient

java.lang.Object
net.shibboleth.shared.httpclient.AbstractHttpClient
net.shibboleth.shared.httpclient.FileCachingHttpClientBuilder.StorageManagingHttpClient
All Implemented Interfaces:
Closeable, AutoCloseable, Component, DestructableComponent, InitializableComponent, org.apache.hc.client5.http.classic.HttpClient, org.apache.hc.core5.io.ModalCloseable
Enclosing class:
FileCachingHttpClientBuilder

private static class FileCachingHttpClientBuilder.StorageManagingHttpClient extends AbstractHttpClient implements InitializableComponent, DestructableComponent
Class which wraps a caching instance of HttpClient 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.hc.client5.http.classic.HttpClient
    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.hc.client5.http.impl.cache.ManagedHttpCacheStorage
    The cache storage instance to manage.
    private Timer
    Scheduled task timer.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StorageManagingHttpClient(org.apache.hc.client5.http.classic.HttpClient wrappedClient, org.apache.hc.client5.http.impl.cache.ManagedHttpCacheStorage managedStorage, long taskInterval)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    void
    close(org.apache.hc.core5.io.CloseMode closeMode)
    void
    Destroys the component.
    protected org.apache.hc.core5.http.ClassicHttpResponse
    doExecute(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.ClassicHttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context)
    Execute the HTTP request.
    void
    Initializes the component.
    boolean
    Gets whether this component has been destroyed.
    boolean
    Gets whether this component is initialized.
    protected final void
    Common code (exbedded from AbstractInitializableComponent to check component state.

    Methods inherited from class net.shibboleth.shared.httpclient.AbstractHttpClient

    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

    Methods inherited from interface org.apache.hc.client5.http.classic.HttpClient

    executeOpen
  • Field Details

    • log

      @Nonnull private org.slf4j.Logger log
      Logger.
    • httpClient

      @NonnullAfterInit private org.apache.hc.client5.http.classic.HttpClient httpClient
      The wrapped HttpClient instance.
    • storage

      @NonnullAfterInit private org.apache.hc.client5.http.impl.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

      @NonnullAfterInit private Timer timer
      Scheduled task timer.
    • maintenanceTask

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

    • StorageManagingHttpClient

      public StorageManagingHttpClient(@Nonnull org.apache.hc.client5.http.classic.HttpClient wrappedClient, @Nonnull org.apache.hc.client5.http.impl.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

    • throwComponentStateExceptions

      protected final void throwComponentStateExceptions()
      Common code (exbedded from AbstractInitializableComponent to check component state.
    • doExecute

      protected org.apache.hc.core5.http.ClassicHttpResponse doExecute(@Nullable org.apache.hc.core5.http.HttpHost target, @Nonnull org.apache.hc.core5.http.ClassicHttpRequest request, @Nullable org.apache.hc.core5.http.protocol.HttpContext context) throws IOException
      Execute the HTTP request.
      Specified by:
      doExecute in class AbstractHttpClient
      Parameters:
      target - the target host for the request, may be null
      request - the request to execute
      context - the context to use for the execution, or null to use the default context
      Returns:
      the response to the request
      Throws:
      IOException - in case of a problem or the connection was aborted
    • close

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

      public void close(org.apache.hc.core5.io.CloseMode closeMode)
      Specified by:
      close in interface org.apache.hc.core5.io.ModalCloseable
    • 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