use of net.sf.ehcache.Ehcache in project killbill by killbill.
the class EhCacheCacheManagerProvider method get.
@Override
public CacheManager get() {
final CacheManager cacheManager;
try {
final InputStream inputStream = UriAccessor.accessUri(cacheConfig.getCacheConfigLocation());
cacheManager = CacheManager.create(inputStream);
} catch (final IOException e) {
throw new RuntimeException(e);
} catch (final URISyntaxException e) {
throw new RuntimeException(e);
}
for (final BaseCacheLoader cacheLoader : cacheLoaders) {
cacheLoader.init();
final Ehcache cache = cacheManager.getEhcache(cacheLoader.getCacheType().getCacheName());
if (cache == null) {
logger.warn("Cache for cacheName='{}' not configured - check your ehcache.xml", cacheLoader.getCacheType().getCacheName());
continue;
}
// Make sure we start from a clean state - this is mainly useful for tests
for (final CacheLoader existingCacheLoader : cache.getRegisteredCacheLoaders()) {
cache.unregisterCacheLoader(existingCacheLoader);
}
cache.registerCacheLoader(cacheLoader);
// Instrument the cache
final Ehcache decoratedCache = InstrumentedEhcache.instrument(metricRegistry, cache);
try {
cacheManager.replaceCacheWithDecoratedCache(cache, decoratedCache);
} catch (final CacheException e) {
logger.warn("Unable to instrument cache {}: {}", cache.getName(), e.getMessage());
}
}
return cacheManager;
}
use of net.sf.ehcache.Ehcache in project spring-security by spring-projects.
the class BasicLookupStrategyTests method getCache.
private Ehcache getCache() {
Ehcache cache = cacheManager.getCache("basiclookuptestcache");
cache.removeAll();
return cache;
}
use of net.sf.ehcache.Ehcache in project spring-security by spring-projects.
the class EhCacheBasedTicketCacheTests method testStartupDetectsMissingCache.
@Test
public void testStartupDetectsMissingCache() throws Exception {
EhCacheBasedTicketCache cache = new EhCacheBasedTicketCache();
try {
cache.afterPropertiesSet();
fail("Should have thrown IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
Ehcache myCache = cacheManager.getCache("castickets");
cache.setCache(myCache);
assertThat(cache.getCache()).isEqualTo(myCache);
}
use of net.sf.ehcache.Ehcache in project spring-security by spring-projects.
the class EhCacheBasedUserCacheTests method getCache.
private Ehcache getCache() {
Ehcache cache = cacheManager.getCache("ehcacheusercachetests");
cache.removeAll();
return cache;
}
use of net.sf.ehcache.Ehcache in project OpenClinica by OpenClinica.
the class EhCacheWrapper method get.
public V get(final K key) {
String db_type = CoreResources.getField("dbType");
if (db_type.equalsIgnoreCase("postgres")) {
Element element = null;
Ehcache ehCache = getCache();
if (ehCache != null) {
element = getCache().get(key);
logMe("element null" + element);
}
if (element != null) {
logMe("element not null" + element);
return (V) element.getObjectValue();
}
}
return null;
}
Aggregations