Class SvgDownloader
-
- All Implemented Interfaces:
public final class SvgDownloaderDownloads icon SVG files from CDN with local caching, validation, and retry logic.
Supports multiple icon libraries through the IconConfig interface.
Features:
Content validation (type, size, structure)
7-day cache with metadata tracking
HTTPS enforcement for security
Automatic retry with exponential backoff
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classSvgDownloader.CacheStats
-
Field Summary
Fields Modifier and Type Field Description public final static IntegerMAX_CONNECTIONS_COUNTpublic final static IntegerMAX_CONNECTIONS_PER_ROUTE
-
Method Summary
Modifier and Type Method Description final StringdownloadSvg(String iconName, IconConfig config)Download an SVG file for the given icon and configuration with automatic retry logic. final Unitcleanup()final BooleanisCached(String cacheKey)Check if an SVG is cached and valid final SvgDownloader.CacheStatsgetCacheStats()Get cache statistics -
-
Method Detail
-
downloadSvg
final String downloadSvg(String iconName, IconConfig config)
Download an SVG file for the given icon and configuration with automatic retry logic.
This method:
Checks the local cache first
Downloads from CDN if not cached (with retries on failure)
Validates content type, size, and structure
Caches valid content for future use
Retry Strategy:
Exponential backoff: delay doubles after each retry
Configurable max retries (default: 3)
Configurable initial delay (default: 1000ms)
- Parameters:
iconName- Name of the iconconfig- Icon library configuration- Returns:
SVG content as string, or null if download fails after all retries
-
getCacheStats
final SvgDownloader.CacheStats getCacheStats()
Get cache statistics
-
-
-
-