This interface establishes a consistent pattern for configuring HTTP operations with retry capabilities. Rather than passing HttpHandler and RetryStrategy as separate parameters, implementations provide both dependencies through a single provider interface.
Design Benefits
- Unified Constructor:
new ResilientHttpHandler(provider)instead ofnew ResilientHttpHandler(handler, strategy) - Consistent Pattern: All HTTP configuration classes follow the same pattern
- Reduced Breaking Changes: Internal provider evolution without API changes
- Better Testability: Single interface to mock
- Future-Proof: Interface can evolve for HTTP-specific configuration needs
Implementation Pattern
Configuration classes implement this interface by providing their HttpHandler and RetryStrategy:
public class HttpJwksLoaderConfig implements HttpHandlerProvider {
@Override
public HttpHandler getHttpHandler() { return httpHandler; }
@Override
public RetryStrategy getRetryStrategy() { return retryStrategy; }
}
Consumer Pattern
HTTP handler implementations consume this interface for unified dependency injection:
public class ResilientHttpHandler {
public ResilientHttpHandler(HttpHandlerProvider provider) {
this.httpHandler = provider.getHttpHandler();
this.retryStrategy = provider.getRetryStrategy();
}
}
- Since:
- 1.0
- Author:
- Oliver Wolff
-
Method Summary
Modifier and TypeMethodDescription@NonNull de.cuioss.tools.net.http.HttpHandlerProvides the HttpHandler for HTTP operations.@NonNull RetryStrategyProvides the RetryStrategy for HTTP operations.
-
Method Details
-
getHttpHandler
Provides the HttpHandler for HTTP operations.This HttpHandler is used by HTTP clients for making actual HTTP requests. The implementation must ensure that the returned HttpHandler is properly configured with appropriate timeouts, SSL settings, and other HTTP-specific parameters.
- Returns:
- the HttpHandler instance, never null
-
getRetryStrategy
Provides the RetryStrategy for HTTP operations.This RetryStrategy defines how failed HTTP operations should be retried, including exponential backoff parameters, maximum attempts, and retry conditions. The implementation must ensure that the RetryStrategy is configured appropriately for the specific HTTP operation context.
- Returns:
- the RetryStrategy instance, never null
-