net.sf.ehcache.event.CacheEventListener Java Examples
The following examples show how to use
net.sf.ehcache.event.CacheEventListener.
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 sakai with Educational Community License v2.0 | 6 votes |
/** * Create a raw Cache object based on the configuration of this FactoryBean. */ protected Cache createCache() { // Only call EHCache 1.6 constructor if actually necessary (for compatibility with EHCache 1.3+) Cache cache = (!this.clearOnFlush) ? new Cache(this.cacheName, this.maxElementsInMemory, this.memoryStoreEvictionPolicy, this.overflowToDisk, null, this.eternal, this.timeToLive, this.timeToIdle, this.diskPersistent, this.diskExpiryThreadIntervalSeconds, null, this.bootstrapCacheLoader, this.maxElementsOnDisk, this.diskSpoolBufferSize, this.clearOnFlush) : new Cache(this.cacheName, this.maxElementsInMemory, this.memoryStoreEvictionPolicy, this.overflowToDisk, null, this.eternal, this.timeToLive, this.timeToIdle, this.diskPersistent, this.diskExpiryThreadIntervalSeconds, null, this.bootstrapCacheLoader, this.maxElementsOnDisk, this.diskSpoolBufferSize); if (this.cacheEventListeners != null) { for (CacheEventListener listener : this.cacheEventListeners) { cache.getCacheEventNotificationService().registerListener(listener); } } if (this.disabled) { cache.setDisabled(true); } net.sf.ehcache.config.CacheConfiguration config = cache.getCacheConfiguration(); config.setMaxEntriesLocalHeap(maxElementsInMemory); return cache; }
Example #2
Source File: EhCacheFactoryBean.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Create a raw Cache object based on the configuration of this FactoryBean. */ protected Cache createCache() { // Only call EHCache 1.6 constructor if actually necessary (for compatibility with EHCache 1.3+) Cache cache = (!this.clearOnFlush) ? new Cache(this.cacheName, this.maxElementsInMemory, this.memoryStoreEvictionPolicy, this.overflowToDisk, null, this.eternal, this.timeToLive, this.timeToIdle, this.diskPersistent, this.diskExpiryThreadIntervalSeconds, null, this.bootstrapCacheLoader, this.maxElementsOnDisk, this.diskSpoolBufferSize, this.clearOnFlush) : new Cache(this.cacheName, this.maxElementsInMemory, this.memoryStoreEvictionPolicy, this.overflowToDisk, null, this.eternal, this.timeToLive, this.timeToIdle, this.diskPersistent, this.diskExpiryThreadIntervalSeconds, null, this.bootstrapCacheLoader, this.maxElementsOnDisk, this.diskSpoolBufferSize); if (this.cacheEventListeners != null) { for (CacheEventListener listener : this.cacheEventListeners) { cache.getCacheEventNotificationService().registerListener(listener); } } if (this.disabled) { cache.setDisabled(true); } net.sf.ehcache.config.CacheConfiguration config = cache.getCacheConfiguration(); config.setMaxEntriesLocalHeap(maxElementsInMemory); return cache; }
Example #3
Source File: EhcacheCache.java From sakai with Educational Community License v2.0 | 5 votes |
@Override public void registerCacheEventListener(org.sakaiproject.memory.api.CacheEventListener cacheEventListener) { super.registerCacheEventListener(cacheEventListener); if (cacheEventListener == null) { cache.getCacheEventNotificationService().unregisterListener(this); } else { cache.getCacheEventNotificationService().registerListener(this); } }
Example #4
Source File: EhcacheCache.java From sakai with Educational Community License v2.0 | 5 votes |
@Override public void registerCacheEventListener(org.sakaiproject.memory.api.CacheEventListener cacheEventListener) { super.registerCacheEventListener(cacheEventListener); if (cacheEventListener == null) { cache.getCacheEventNotificationService().unregisterListener(this); } else { cache.getCacheEventNotificationService().registerListener(this); } }
Example #5
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 #6
Source File: GoCache.java From gocd with Apache License 2.0 | 4 votes |
public void addListener(CacheEventListener listener) { ehCache.getCacheEventNotificationService().registerListener(listener); }
Example #7
Source File: GoCache.java From gocd with Apache License 2.0 | 4 votes |
public void removeListener(CacheEventListener cacheEventListener) { ehCache.getCacheEventNotificationService().unregisterListener(cacheEventListener); }
Example #8
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; } }
Example #9
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 #10
Source File: CustomerCacheEventListenerFactory.java From cache with GNU General Public License v3.0 | 4 votes |
@Override public CacheEventListener createCacheEventListener(Properties properties) { return new CustomerCacheEventListener(); }
Example #11
Source File: JbootEhcacheImpl.java From jboot with Apache License 2.0 | 4 votes |
public void setCacheEventListener(CacheEventListener cacheEventListener) { this.cacheEventListener = cacheEventListener; }
Example #12
Source File: JbootEhcacheImpl.java From jboot with Apache License 2.0 | 4 votes |
public CacheEventListener getCacheEventListener() { return cacheEventListener; }
Example #13
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 #14
Source File: EhCacheFactoryBean.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Specify EhCache {@link net.sf.ehcache.event.CacheEventListener cache event listeners} * to registered with this cache. */ public void setCacheEventListeners(Set<CacheEventListener> cacheEventListeners) { this.cacheEventListeners = cacheEventListeners; }
Example #15
Source File: EhCacheFactoryBean.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Specify EhCache {@link net.sf.ehcache.event.CacheEventListener cache event listeners} * to registered with this cache. */ public void setCacheEventListeners(Set<CacheEventListener> cacheEventListeners) { this.cacheEventListeners = cacheEventListeners; }
Example #16
Source File: EhCacheFactoryBean.java From sakai with Educational Community License v2.0 | 2 votes |
/** * Specify EHCache {@link net.sf.ehcache.event.CacheEventListener cache event listeners} * to registered with this cache. */ public void setCacheEventListeners(Set<CacheEventListener> cacheEventListeners) { this.cacheEventListeners = cacheEventListeners; }
Example #17
Source File: EhCacheFactoryBean.java From sakai with Educational Community License v2.0 | 2 votes |
/** * Specify EHCache {@link net.sf.ehcache.event.CacheEventListener cache event listeners} * to registered with this cache. */ public void setCacheEventListeners(Set<CacheEventListener> cacheEventListeners) { this.cacheEventListeners = cacheEventListeners; }
Example #18
Source File: EhCacheFactoryBean.java From java-technology-stack with MIT License | 2 votes |
/** * Specify EhCache {@link net.sf.ehcache.event.CacheEventListener cache event listeners} * to registered with this cache. */ public void setCacheEventListeners(Set<CacheEventListener> cacheEventListeners) { this.cacheEventListeners = cacheEventListeners; }
Example #19
Source File: EhCacheFactoryBean.java From spring-analysis-note with MIT License | 2 votes |
/** * Specify EhCache {@link net.sf.ehcache.event.CacheEventListener cache event listeners} * to registered with this cache. */ public void setCacheEventListeners(Set<CacheEventListener> cacheEventListeners) { this.cacheEventListeners = cacheEventListeners; }