/** * Create a local region fronting the main region. * */ private Region<String, HttpSession> createOrRetrieveLocalRegion() { // Attempt to retrieve the fronting region String frontingRegionName = this.sessionRegion.getName() + "_local"; Region<String, HttpSession> frontingRegion = this.cache.getRegion(frontingRegionName); if (frontingRegion == null) { // Create the region factory RegionFactory<String, HttpSession> factory = this.cache.createRegionFactory(RegionShortcut.LOCAL_HEAP_LRU); // Add the cache loader and writer factory.setCacheLoader(new LocalSessionCacheLoader(this.sessionRegion)); factory.setCacheWriter(new LocalSessionCacheWriter(this.sessionRegion)); // Create the region frontingRegion = factory.create(frontingRegionName); LOG.info("Created new local session region: {}", frontingRegion); } else { LOG.info("Retrieved existing local session region: {}", frontingRegion); } return frontingRegion; } }
.setCacheLoader(DeclarableTypeInstantiator.newInstance(regionAttributes.getCacheLoader(), cache));
factory.setCacheLoader(new LocalSessionCacheLoader(this.sessionRegion)); factory.setCacheWriter(new LocalSessionCacheWriter(this.sessionRegion));
}); when(mockRegionFactory.setCacheLoader(any(CacheLoader.class))) .thenAnswer(newSetter(cacheLoader, mockRegionFactory));
factory.setCacheLoader(new LocalSessionCacheLoader(this.sessionRegion)); factory.setCacheWriter(new LocalSessionCacheWriter(this.sessionRegion));