Package net.shibboleth.shared.httpclient
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
FieldsModifier and TypeFieldDescriptionprivate booleanDestroyed flag.private org.apache.hc.client5.http.classic.HttpClientThe wrapped HttpClient instance.private booleanInitialized flag.private org.slf4j.LoggerLogger.private TimerTaskThe scheduled storage maintenance task.private longInterval of the scheduled maintenance task.private org.apache.hc.client5.http.impl.cache.ManagedHttpCacheStorageThe cache storage instance to manage.private TimerScheduled task timer. -
Constructor Summary
ConstructorsConstructorDescriptionStorageManagingHttpClient(org.apache.hc.client5.http.classic.HttpClient wrappedClient, org.apache.hc.client5.http.impl.cache.ManagedHttpCacheStorage managedStorage, long taskInterval) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidclose(org.apache.hc.core5.io.CloseMode closeMode) voiddestroy()protected org.apache.hc.core5.http.ClassicHttpResponsedoExecute(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.voidbooleanbooleanprotected final voidCommon code (exbedded fromAbstractInitializableComponentto check component state.Methods inherited from class net.shibboleth.shared.httpclient.AbstractHttpClient
execute, execute, execute, execute, execute, execute, execute, executeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hc.client5.http.classic.HttpClient
executeOpen
-
Field Details
-
log
@Nonnull private org.slf4j.Logger logLogger. -
httpClient
The wrapped HttpClient instance. -
storage
The cache storage instance to manage. -
maintenanceTaskInterval
private long maintenanceTaskIntervalInterval of the scheduled maintenance task. -
initialized
private boolean initializedInitialized flag. -
destroyed
private boolean destroyedDestroyed flag. -
timer
Scheduled task timer. -
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 instancemanagedStorage- the managed cache storage instancetaskInterval- the interval at which storage maintenance should run
-
-
Method Details
-
throwComponentStateExceptions
protected final void throwComponentStateExceptions()Common code (exbedded fromAbstractInitializableComponentto 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:
doExecutein classAbstractHttpClient- Parameters:
target- the target host for the request, may benullrequest- the request to executecontext- the context to use for the execution, ornullto use the default context- Returns:
- the response to the request
- Throws:
IOException- in case of a problem or the connection was aborted
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
close
public void close(org.apache.hc.core5.io.CloseMode closeMode) - Specified by:
closein interfaceorg.apache.hc.core5.io.ModalCloseable
-
isInitialized
public boolean isInitialized()- Specified by:
isInitializedin interfaceInitializableComponent
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceDestructableComponent
-
initialize
- Specified by:
initializein interfaceInitializableComponent- Throws:
ComponentInitializationException
-
destroy
public void destroy()- Specified by:
destroyin interfaceDestructableComponent
-