private void preloadDynamicCaches ( ) { List < CacheService > dynamicCacheServices = CacheRegistry . getInstance ( ) . getDynamicCacheServices ( ) ; for ( CacheService dynamicCacheService : dynamicCacheServices ) { if ( dynamicCacheService instanceof PreloadableCache ) { try { PreloadableCache preloadableCache = ( PreloadableCache ) dynamicCacheService ; RegisteredService regServ = preloadableCache . getClass ( ) . getAnnotation ( RegisteredService . class ) ; Map < String , String > params = new HashMap <> ( ) ; Parameter [ ] parameters = regServ . parameters ( ) ; if ( parameters != null ) { for ( Parameter parameter : parameters ) { if ( parameter . name ( ) . length ( ) > 0 ) params . put ( parameter . name ( ) , parameter . value ( ) ) ; } } preloadableCache . initialize ( params ) ; preloadableCache . loadCache ( ) ; } catch ( Exception ex ) { logger . severeException ( "Failed to preload " + dynamicCacheService . getClass ( ) , ex ) ; } } synchronized ( allCaches ) { allCaches . put ( dynamicCacheService . getClass ( ) . getName ( ) , dynamicCacheService ) ; } } }
Load caches registered as dynamic java services .