Search in sources :

Example 6 with CacheEventListener

use of net.sf.ehcache.event.CacheEventListener 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

CacheEventListener (net.sf.ehcache.event.CacheEventListener)6 Cache (net.sf.ehcache.Cache)3 Ehcache (net.sf.ehcache.Ehcache)3 CacheException (net.sf.ehcache.CacheException)2 CacheManager (net.sf.ehcache.CacheManager)2 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)1 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)1 Serializable (java.io.Serializable)1 Method (java.lang.reflect.Method)1 Element (net.sf.ehcache.Element)1 CacheLoader (net.sf.ehcache.loader.CacheLoader)1 Exchange (org.apache.camel.Exchange)1 Message (org.apache.camel.Message)1 Processor (org.apache.camel.Processor)1 BaseCacheTest (org.apache.camel.component.BaseCacheTest)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1