/** * Decorate the given Cache, if necessary. * @param cache the raw Cache object, based on the configuration of this FactoryBean * @return the (potentially decorated) cache object to be registered with the CacheManager */ protected Ehcache decorateCache(Ehcache cache) { if (this.cacheEntryFactory != null) { if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory); } else { return new SelfPopulatingCache(cache, this.cacheEntryFactory); } } if (this.blocking) { return new BlockingCache(cache); } return cache; }
/** * Decorate the given Cache, if necessary. * @param cache the raw Cache object, based on the configuration of this FactoryBean * @return the (potentially decorated) cache object to be registered with the CacheManager */ protected Ehcache decorateCache(Ehcache cache) { if (this.cacheEntryFactory != null) { if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory); } else { return new SelfPopulatingCache(cache, this.cacheEntryFactory); } } if (this.blocking) { return new BlockingCache(cache); } return cache; }
public void setCache(Ehcache cache) { BlockingCache ref; if (!(cache instanceof BlockingCache)) { ref = new BlockingCache(cache); cache.getCacheManager().replaceCacheWithDecoratedCache(cache, new BlockingCache(cache)); } else { ref = (BlockingCache)cache; } this.cache = ref; }
/** * Sets the non-null {@link Ehcache} used to back this {@link TokenStore}. * * @param cache * a non-null {@link Ehcache} */ public void setCache(Ehcache cache) { BlockingCache ref; if (!(cache instanceof BlockingCache)) { ref = new BlockingCache(cache); cache.getCacheManager().replaceCacheWithDecoratedCache(cache, new BlockingCache(cache)); } else { ref = (BlockingCache) cache; } this.cache = ref; }
/** * Create a new reference to the ehcache cache implementation. * * @param cacheName contains the name of the cache to retrieve * @return reference to cache for specified object. */ public Cache getCache( String cacheName ) { Ehcache cache = mEhCacheImpl.getEhcache( cacheName ); if(cache != null) { return new EhCacheImpl( cacheName, new BlockingCache(cache) ); } else { return CacheFactory.createInstance( cacheName, mEhCacheImpl ); } }
/** * Decorate the given Cache, if necessary. * @param cache the raw Cache object, based on the configuration of this FactoryBean * @return the (potentially decorated) cache object to be registered with the CacheManager */ protected Ehcache decorateCache(Ehcache cache) { if (this.cacheEntryFactory != null) { if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory); } else { return new SelfPopulatingCache(cache, this.cacheEntryFactory); } } if (this.blocking) { return new BlockingCache(cache); } return cache; }
/** * Decorate the given Cache, if necessary. * @param cache the raw Cache object, based on the configuration of this FactoryBean * @return the (potentially decorated) cache object to be registered with the CacheManager */ protected Ehcache decorateCache(Ehcache cache) { if (this.cacheEntryFactory != null) { if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory); } else { return new SelfPopulatingCache(cache, this.cacheEntryFactory); } } if (this.blocking) { return new BlockingCache(cache); } return cache; }
/** * Decorate the given Cache, if necessary. * * @param cache the raw Cache object, based on the configuration of this * FactoryBean * @return the (potentially decorated) cache object to be registered with the * CacheManager */ protected Ehcache decorateCache(Ehcache cache) { if (this.cacheEntryFactory != null) { if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory); } else { return new SelfPopulatingCache(cache, this.cacheEntryFactory); } } if (this.blocking) { return new BlockingCache(cache); } return cache; }
/** * Decorate the given Cache, if necessary. * * @param cache the raw Cache object, based on the configuration of this * FactoryBean * @return the (potentially decorated) cache object to be registered with the * CacheManager */ protected Ehcache decorateCache(Ehcache cache) { if (this.cacheEntryFactory != null) { if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { return new UpdatingSelfPopulatingCache(cache, (UpdatingCacheEntryFactory) this.cacheEntryFactory); } else { return new SelfPopulatingCache(cache, this.cacheEntryFactory); } } if (this.blocking) { return new BlockingCache(cache); } return cache; }
protected void createCache(String name) { synchronized (this.getClass()) { cacheManager.addCache(name); final Ehcache cache = cacheManager.getEhcache(name); // default EHCache is non blocking. Since our impl always requires blocking cache wrap it here. final BlockingCache newBlockingCache = new BlockingCache(cache); newBlockingCache.setTimeoutMillis(getBlockingTimeout()); cacheManager.replaceCacheWithDecoratedCache(cache, newBlockingCache); } }
public EhBlockingCache(final String id) { super(id); if (!CACHE_MANAGER.cacheExists(id)) { CACHE_MANAGER.addCache(this.id); Ehcache ehcache = CACHE_MANAGER.getEhcache(this.id); BlockingCache blockingCache = new BlockingCache(ehcache); CACHE_MANAGER.replaceCacheWithDecoratedCache(ehcache, blockingCache); } }
/** * Replace the cache with a BlockingCache decorated one if this has not been done yet. * The cacheLoaderTimeoutMillis of the original cache will be used as the timeoutMillis of the BlockingCache. * @param ehcache the original cache * @return a BlockingCache wrapping the original one */ protected BlockingCache replaceWithBlockingCacheIfNot(Ehcache ehcache){ if (ehcache instanceof BlockingCache){ return (BlockingCache) ehcache; } BlockingCache blockingCache = new BlockingCache(ehcache); blockingCache.setTimeoutMillis((int)ehcache.getCacheConfiguration().getCacheLoaderTimeoutMillis()); cacheManager.replaceCacheWithDecoratedCache(ehcache, blockingCache); return blockingCache; }
/** * Create and return a reference to {@link Cache} object. * * @return instance of {@link Cache}. */ public static Cache createInstance(String name, net.sf.ehcache.CacheManager cacheManager) { net.sf.ehcache.Ehcache cache = cacheManager.getEhcache(name); if(cache == null) { String error = "createInstance cache: " + name + " is null"; throw new CfgRuntimeException(GlobalErrIds.FT_CACHE_NOT_CONFIGURED, error); } BlockingCache blockingCache = new BlockingCache(cache); blockingCache.setTimeoutMillis(60000); cacheManager.replaceCacheWithDecoratedCache(cache, blockingCache); return new EhCacheImpl(name, blockingCache); } }
if (!(cache instanceof BlockingCache)) { BlockingCache newBlockingCache = new BlockingCache(cache); getCacheManager().replaceCacheWithDecoratedCache(cache, newBlockingCache);
BlockingCache newBlockingCache = new BlockingCache( cache ); getCacheManager( ).replaceCacheWithDecoratedCache( cache, newBlockingCache );
BlockingCache newBlockingCache = new BlockingCache(cache); getCacheManager().replaceCacheWithDecoratedCache(cache, newBlockingCache);