Java Code Examples for net.sf.ehcache.Ehcache#setBootstrapCacheLoader()
The following examples show how to use
net.sf.ehcache.Ehcache#setBootstrapCacheLoader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EhCacheFactoryBean.java From spring-analysis-note with MIT License | 4 votes |
@Override public void afterPropertiesSet() throws CacheException { // If no cache name given, use bean name as cache name. String cacheName = getName(); if (cacheName == null) { cacheName = this.beanName; if (cacheName != null) { setName(cacheName); } } // If no CacheManager given, fetch the default. if (this.cacheManager == null) { if (logger.isDebugEnabled()) { logger.debug("Using default EhCache CacheManager for cache region '" + cacheName + "'"); } this.cacheManager = CacheManager.getInstance(); } synchronized (this.cacheManager) { // Fetch cache region: If none with the given name exists, create one on the fly. Ehcache rawCache; boolean cacheExists = this.cacheManager.cacheExists(cacheName); if (cacheExists) { if (logger.isDebugEnabled()) { logger.debug("Using existing EhCache cache region '" + cacheName + "'"); } rawCache = this.cacheManager.getEhcache(cacheName); } else { if (logger.isDebugEnabled()) { logger.debug("Creating new EhCache cache region '" + cacheName + "'"); } rawCache = createCache(); rawCache.setBootstrapCacheLoader(this.bootstrapCacheLoader); } if (this.cacheEventListeners != null) { for (CacheEventListener listener : this.cacheEventListeners) { rawCache.getCacheEventNotificationService().registerListener(listener); } } // Needs to happen after listener registration but before setStatisticsEnabled if (!cacheExists) { this.cacheManager.addCache(rawCache); } if (this.disabled) { rawCache.setDisabled(true); } Ehcache decoratedCache = decorateCache(rawCache); if (decoratedCache != rawCache) { this.cacheManager.replaceCacheWithDecoratedCache(rawCache, decoratedCache); } this.cache = decoratedCache; } }
Example 2
Source File: EhCacheFactoryBean.java From java-technology-stack with MIT License | 4 votes |
@Override public void afterPropertiesSet() throws CacheException { // If no cache name given, use bean name as cache name. String cacheName = getName(); if (cacheName == null) { cacheName = this.beanName; if (cacheName != null) { setName(cacheName); } } // If no CacheManager given, fetch the default. if (this.cacheManager == null) { if (logger.isDebugEnabled()) { logger.debug("Using default EhCache CacheManager for cache region '" + cacheName + "'"); } this.cacheManager = CacheManager.getInstance(); } synchronized (this.cacheManager) { // Fetch cache region: If none with the given name exists, create one on the fly. Ehcache rawCache; boolean cacheExists = this.cacheManager.cacheExists(cacheName); if (cacheExists) { if (logger.isDebugEnabled()) { logger.debug("Using existing EhCache cache region '" + cacheName + "'"); } rawCache = this.cacheManager.getEhcache(cacheName); } else { if (logger.isDebugEnabled()) { logger.debug("Creating new EhCache cache region '" + cacheName + "'"); } rawCache = createCache(); rawCache.setBootstrapCacheLoader(this.bootstrapCacheLoader); } if (this.cacheEventListeners != null) { for (CacheEventListener listener : this.cacheEventListeners) { rawCache.getCacheEventNotificationService().registerListener(listener); } } // Needs to happen after listener registration but before setStatisticsEnabled if (!cacheExists) { this.cacheManager.addCache(rawCache); } if (this.disabled) { rawCache.setDisabled(true); } Ehcache decoratedCache = decorateCache(rawCache); if (decoratedCache != rawCache) { this.cacheManager.replaceCacheWithDecoratedCache(rawCache, decoratedCache); } this.cache = decoratedCache; } }
Example 3
Source File: EhCacheFactoryBean.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void afterPropertiesSet() throws CacheException { // If no cache name given, use bean name as cache name. String cacheName = getName(); if (cacheName == null) { cacheName = this.beanName; setName(cacheName); } // If no CacheManager given, fetch the default. if (this.cacheManager == null) { if (logger.isDebugEnabled()) { logger.debug("Using default EhCache CacheManager for cache region '" + cacheName + "'"); } this.cacheManager = CacheManager.getInstance(); } synchronized (this.cacheManager) { // Fetch cache region: If none with the given name exists, create one on the fly. Ehcache rawCache; boolean cacheExists = this.cacheManager.cacheExists(cacheName); if (cacheExists) { if (logger.isDebugEnabled()) { logger.debug("Using existing EhCache cache region '" + cacheName + "'"); } rawCache = this.cacheManager.getEhcache(cacheName); } else { if (logger.isDebugEnabled()) { logger.debug("Creating new EhCache cache region '" + cacheName + "'"); } rawCache = createCache(); rawCache.setBootstrapCacheLoader(this.bootstrapCacheLoader); } if (this.cacheEventListeners != null) { for (CacheEventListener listener : this.cacheEventListeners) { rawCache.getCacheEventNotificationService().registerListener(listener); } } // Needs to happen after listener registration but before setStatisticsEnabled if (!cacheExists) { this.cacheManager.addCache(rawCache); } // Only necessary on EhCache <2.7: As of 2.7, statistics are on by default. if (this.statisticsEnabled && setStatisticsEnabledMethod != null) { ReflectionUtils.invokeMethod(setStatisticsEnabledMethod, rawCache, true); } if (this.sampledStatisticsEnabled && setSampledStatisticsEnabledMethod != null) { ReflectionUtils.invokeMethod(setSampledStatisticsEnabledMethod, rawCache, true); } if (this.disabled) { rawCache.setDisabled(true); } Ehcache decoratedCache = decorateCache(rawCache); if (decoratedCache != rawCache) { this.cacheManager.replaceCacheWithDecoratedCache(rawCache, decoratedCache); } this.cache = decoratedCache; } }
Example 4
Source File: EhCacheFactoryBean.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public void afterPropertiesSet() throws CacheException { // If no cache name given, use bean name as cache name. String cacheName = getName(); if (cacheName == null) { cacheName = this.beanName; setName(cacheName); } // If no CacheManager given, fetch the default. if (this.cacheManager == null) { if (logger.isDebugEnabled()) { logger.debug("Using default EhCache CacheManager for cache region '" + cacheName + "'"); } this.cacheManager = CacheManager.getInstance(); } synchronized (this.cacheManager) { // Fetch cache region: If none with the given name exists, create one on the fly. Ehcache rawCache; boolean cacheExists = this.cacheManager.cacheExists(cacheName); if (cacheExists) { if (logger.isDebugEnabled()) { logger.debug("Using existing EhCache cache region '" + cacheName + "'"); } rawCache = this.cacheManager.getEhcache(cacheName); } else { if (logger.isDebugEnabled()) { logger.debug("Creating new EhCache cache region '" + cacheName + "'"); } rawCache = createCache(); rawCache.setBootstrapCacheLoader(this.bootstrapCacheLoader); } if (this.cacheEventListeners != null) { for (CacheEventListener listener : this.cacheEventListeners) { rawCache.getCacheEventNotificationService().registerListener(listener); } } // Needs to happen after listener registration but before setStatisticsEnabled if (!cacheExists) { this.cacheManager.addCache(rawCache); } // Only necessary on EhCache <2.7: As of 2.7, statistics are on by default. if (this.statisticsEnabled && setStatisticsEnabledMethod != null) { ReflectionUtils.invokeMethod(setStatisticsEnabledMethod, rawCache, true); } if (this.sampledStatisticsEnabled && setSampledStatisticsEnabledMethod != null) { ReflectionUtils.invokeMethod(setSampledStatisticsEnabledMethod, rawCache, true); } if (this.disabled) { rawCache.setDisabled(true); } Ehcache decoratedCache = decorateCache(rawCache); if (decoratedCache != rawCache) { this.cacheManager.replaceCacheWithDecoratedCache(rawCache, decoratedCache); } this.cache = decoratedCache; } }