Search in sources :

Example 46 with CacheManager

use of net.sf.ehcache.CacheManager in project gocd by gocd.

the class UserCacheFactory method createCacheManager.

private CacheManager createCacheManager() {
    Configuration configuration = new Configuration();
    configuration.setDefaultCacheConfiguration(new CacheConfiguration("cache", 10000));
    return new CacheManager(configuration);
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Configuration(net.sf.ehcache.config.Configuration) CacheManager(net.sf.ehcache.CacheManager) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration)

Example 47 with CacheManager

use of net.sf.ehcache.CacheManager in project cxf by apache.

the class EHCacheUtils method getCacheManager.

public static CacheManager getCacheManager(Bus bus, URL configFileURL) {
    CacheManager cacheManager = null;
    String globalCacheManagerName = getGlobalCacheManagerName(bus);
    if (globalCacheManagerName != null) {
        cacheManager = CacheManager.getCacheManager(globalCacheManagerName);
    }
    if (cacheManager == null) {
        String confName = "";
        if (bus != null) {
            confName = bus.getId();
        }
        cacheManager = EHCacheManagerHolder.getCacheManager(confName, configFileURL);
    }
    return cacheManager;
}
Also used : CacheManager(net.sf.ehcache.CacheManager)

Example 48 with CacheManager

use of net.sf.ehcache.CacheManager in project oc-explorer by devgateway.

the class MarkupCacheService method clearReportsApiCache.

/**
 * Remove from cache all reports api content
 */
public void clearReportsApiCache() {
    CacheManager cm = CacheManager.getInstance();
    // get the reports cache "reportsApiCache", declared in ehcache.xml
    Cache cache = cm.getCache("reportsApiCache");
    if (cache != null) {
        cache.removeAll();
    }
    // get the reports cache "excelExportCache", declared in ehcache.xml
    Cache excelExportCache = cm.getCache("excelExportCache");
    if (excelExportCache != null) {
        excelExportCache.removeAll();
    }
}
Also used : CacheManager(net.sf.ehcache.CacheManager) MarkupCache(org.apache.wicket.markup.MarkupCache) Cache(net.sf.ehcache.Cache)

Example 49 with CacheManager

use of net.sf.ehcache.CacheManager in project cxf by apache.

the class EHCacheUtilsTest method testUseGlobalManager.

@Test
public void testUseGlobalManager() {
    Bus bus = BusFactory.getThreadDefaultBus();
    Configuration conf = ConfigurationFactory.parseConfiguration(EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
    conf.setName("myGlobalConfig");
    CacheManager.newInstance(conf);
    CacheManager manager = EHCacheUtils.getCacheManager(bus, EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
    assertFalse(manager.getName().equals("myGlobalConfig"));
    EHCacheManagerHolder.releaseCacheManger(manager);
    assertEquals(Status.STATUS_SHUTDOWN, manager.getStatus());
    bus.setProperty(EHCacheUtils.GLOBAL_EHCACHE_MANAGER_NAME, "myGlobalConfig");
    manager = EHCacheUtils.getCacheManager(bus, EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
    assertEquals("myGlobalConfig", manager.getName());
    EHCacheManagerHolder.releaseCacheManger(manager);
    assertEquals(Status.STATUS_ALIVE, manager.getStatus());
    manager.shutdown();
    assertEquals(Status.STATUS_SHUTDOWN, manager.getStatus());
    bus.setProperty(EHCacheUtils.GLOBAL_EHCACHE_MANAGER_NAME, "myGlobalConfigXXX");
    manager = EHCacheUtils.getCacheManager(bus, EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
    assertFalse(manager.getName().equals("myGlobalConfig"));
    EHCacheManagerHolder.releaseCacheManger(manager);
    assertEquals(Status.STATUS_SHUTDOWN, manager.getStatus());
}
Also used : Bus(org.apache.cxf.Bus) Configuration(net.sf.ehcache.config.Configuration) CacheManager(net.sf.ehcache.CacheManager) EHCacheManagerHolder(org.apache.wss4j.common.cache.EHCacheManagerHolder) Test(org.junit.Test)

Aggregations

CacheManager (net.sf.ehcache.CacheManager)49 Cache (net.sf.ehcache.Cache)23 Test (org.junit.Test)14 Configuration (net.sf.ehcache.config.Configuration)12 MarkupCache (org.apache.wicket.markup.MarkupCache)10 CacheException (net.sf.ehcache.CacheException)8 CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)7 UpdatingSelfPopulatingCache (net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache)6 Ehcache (net.sf.ehcache.Ehcache)5 BlockingCache (net.sf.ehcache.constructs.blocking.BlockingCache)5 SelfPopulatingCache (net.sf.ehcache.constructs.blocking.SelfPopulatingCache)5 IOException (java.io.IOException)4 URL (java.net.URL)3 Element (net.sf.ehcache.Element)3 Before (org.junit.Before)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 Statistics (net.sf.ehcache.Statistics)2