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,HttpClient
- Enclosing class:
- FileCachingHttpClientBuilder
private static class FileCachingHttpClientBuilder.StorageManagingHttpClient extends CloseableHttpClient implements InitializableComponent, DestructableComponent
Class which wraps a caching instance ofCloseableHttpClientand its associatedManagedHttpCacheStorage, and manages the scheduled maintenance and lifecycle of the latter.
-
-
Field Summary
Fields Modifier and Type Field Description private booleandestroyedDestroyed flag.private CloseableHttpClienthttpClientThe wrapped HttpClient instance.private booleaninitializedInitialized flag.private LoggerlogLogger.private TimerTaskmaintenanceTaskThe scheduled storage maintenance task.private longmaintenanceTaskIntervalInterval of the scheduled maintenance task.private ManagedHttpCacheStoragestorageThe cache storage instance to manage.private TimertimerScheduled task timer.
-
Constructor Summary
Constructors Constructor Description StorageManagingHttpClient(CloseableHttpClient wrappedClient, ManagedHttpCacheStorage managedStorage, long taskInterval)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()voiddestroy()Destroys the component.protected CloseableHttpResponsedoExecute(HttpHost target, HttpRequest request, HttpContext context)ClientConnectionManagergetConnectionManager()Deprecated.HttpParamsgetParams()Deprecated.voidinitialize()Initializes the component.booleanisDestroyed()Gets whether this component has been destroyed.booleanisInitialized()Gets whether this component is initialized.
-
-
-
Field Detail
-
log
private Logger log
Logger.
-
httpClient
private CloseableHttpClient httpClient
The wrapped HttpClient instance.
-
storage
private 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 Detail
-
StorageManagingHttpClient
public StorageManagingHttpClient(@Nonnull CloseableHttpClient wrappedClient, @Nonnull ManagedHttpCacheStorage managedStorage, long taskInterval)Constructor.- Parameters:
wrappedClient- the wrapped HttpClient instancemanagedStorage- the managed cache storage instancetaskInterval- the interval at which storage maintenance should run
-
-
Method Detail
-
doExecute
protected CloseableHttpResponse doExecute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException
- Specified by:
doExecutein classCloseableHttpClient- Throws:
IOExceptionClientProtocolException
-
getParams
@Deprecated public HttpParams getParams()
Deprecated.- Specified by:
getParamsin interfaceHttpClient
-
getConnectionManager
@Deprecated public ClientConnectionManager getConnectionManager()
Deprecated.- Specified by:
getConnectionManagerin interfaceHttpClient
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
isInitialized
public boolean isInitialized()
Gets whether this component is initialized.- Specified by:
isInitializedin interfaceInitializableComponent- 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:
isDestroyedin interfaceDestructableComponent- Returns:
- true iff the component has been destroyed
-
initialize
public void initialize() throws ComponentInitializationExceptionInitializes the component.- Specified by:
initializein interfaceInitializableComponent- Throws:
ComponentInitializationException- thrown if there is a problem initializing the component
-
destroy
public void destroy()
Destroys the component.- Specified by:
destroyin interfaceDestructableComponent
-
-