Search in sources :

Example 51 with Ehcache

use of net.sf.ehcache.Ehcache in project simplejpa by appoxy.

the class EhCacheFactory method createCache.

public synchronized EhcacheWrapper createCache(String name) {
    if (manager == null) {
        throw new CacheException("CacheFactory was not initialized. Call init() before creating a cache.");
    }
    try {
        Cache cache = manager.getCache(name);
        if (cache == null) {
            log.warning("Could not find a specific ehcache configuration for cache named [" + name + "]; using defaults.");
            manager.addCache(name);
            cache = manager.getCache(name);
        }
        Ehcache backingCache = cache;
        if (!backingCache.getCacheEventNotificationService().hasCacheEventListeners()) {
            if (listeners.size() > 0) {
                for (CacheEventListener listener : listeners) {
                    if (!backingCache.getCacheEventNotificationService().getCacheEventListeners().contains(listener)) {
                        backingCache.getCacheEventNotificationService().registerListener(listener);
                    } else {
                    }
                }
            }
        }
        return new EhcacheWrapper(cache);
    } catch (net.sf.ehcache.CacheException e) {
        throw new CacheException("Could not create cache: " + name, e);
    }
}
Also used : CacheEventListener(net.sf.ehcache.event.CacheEventListener) CacheException(net.sf.ehcache.CacheException) Ehcache(net.sf.ehcache.Ehcache) Cache(net.sf.ehcache.Cache) CacheException(net.sf.ehcache.CacheException)

Aggregations

Ehcache (net.sf.ehcache.Ehcache)51 Test (org.junit.Test)15 CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)14 Element (net.sf.ehcache.Element)11 ResourcesElementsProvider (org.jasig.resourceserver.utils.aggr.ResourcesElementsProvider)9 Cache (net.sf.ehcache.Cache)7 CacheManager (net.sf.ehcache.CacheManager)7 CacheException (net.sf.ehcache.CacheException)6 Configuration (net.sf.ehcache.config.Configuration)5 DiskStoreConfiguration (net.sf.ehcache.config.DiskStoreConfiguration)5 CachedResource (org.apereo.portal.utils.cache.resource.CachedResource)5 CachingResourceLoaderImpl (org.apereo.portal.utils.cache.resource.CachingResourceLoaderImpl)5 LoadedResource (org.apereo.portal.utils.cache.resource.LoadedResource)5 CacheKey (org.apereo.portal.utils.cache.CacheKey)4 FileSystemResource (org.springframework.core.io.FileSystemResource)4 Resource (org.springframework.core.io.Resource)4 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)3 FileReader (java.io.FileReader)3 IOException (java.io.IOException)3