private Map<CacheCategory, CacheService> createCaches(CacheInfo cacheInfo) { Map<CacheCategory, CacheService> ciCaches = new HashMap<CacheCategory, CacheService>(); for (Map.Entry<CacheCategory, CacheConfiguration> entry : cacheInfo.getConfiguration().entrySet()) { if (entry.getValue() instanceof InfinispanConfiguration) { CacheService cacheService; CacheCategory category = entry.getKey(); InfinispanConfiguration config = (InfinispanConfiguration) entry.getValue(); if (config.isCacheEnabled()) { String configurationName = config.getConfigurationName(); if (null == configurationName) { Configuration dcc = manager.getDefaultCacheConfiguration(); Configuration infinispan = config.getInfinispanConfiguration(new ConfigurationBuilder().read(dcc)); configurationName = "$" + category.getName() + "$" + cacheInfo.getId(); manager.defineConfiguration(configurationName, infinispan); } recorder.record("infinispan", "configuration name " + configurationName); cacheService = new InfinispanCacheService(manager.<String, Object>getCache(configurationName)); } else { cacheService = noCacheFactory.create(null, category); } ciCaches.put(category, cacheService); } } return ciCaches; }
@Override public CacheService create(Layer layer, CacheCategory category) { CacheSelector cacheSelector = new CacheSelector(category, layer); CacheService cacheService; cacheService = caches.get(cacheSelector); if (null == cacheService) { cacheSelector = new CacheSelector(category, null); cacheService = caches.get(cacheSelector); } if (null == cacheService) { cacheService = noCacheFactory.create(layer, category); } return cacheService; }