Search in sources :

Example 66 with CacheManager

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

the class DefaultCacheManagerFactoryTest method testNoProvidedConfiguration.

@Test
public void testNoProvidedConfiguration() throws Exception {
    CacheManagerFactory factory = new DefaultCacheManagerFactory(getClass().getResourceAsStream("/ehcache.xml"), "/ehcache.xml");
    CacheManager manager = factory.getInstance();
    // CAMEL-7195
    assertThat("There should be no peer providers configured", manager.getCacheManagerPeerProviders().size(), is(0));
    assertThat("There should be no /ehcache.xml resource by default", getClass().getResourceAsStream("/ehcache.xml"), nullValue());
}
Also used : CacheManager(net.sf.ehcache.CacheManager) Test(org.junit.Test)

Example 67 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 68 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)

Example 69 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 70 with CacheManager

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

the class AttachmentManagerTest method setUp.

@Before
public void setUp() throws Exception {
    CacheManager m_cacheManager = CacheManager.getInstance();
    m_cacheManager.clearAll();
    m_cacheManager.removeAllCaches();
    m_engine = new TestEngine(props);
    m_manager = m_engine.getAttachmentManager();
    m_engine.saveText(NAME1, "Foobar");
    m_engine.saveText(NAMEU, "Foobar");
}
Also used : CacheManager(net.sf.ehcache.CacheManager) TestEngine(org.apache.wiki.TestEngine) Before(org.junit.Before)

Aggregations

CacheManager (net.sf.ehcache.CacheManager)102 Cache (net.sf.ehcache.Cache)55 ClassPathResource (org.springframework.core.io.ClassPathResource)21 Element (net.sf.ehcache.Element)20 Configuration (net.sf.ehcache.config.Configuration)18 Test (org.junit.Test)18 CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)17 MarkupCache (org.apache.wicket.markup.MarkupCache)10 CacheException (net.sf.ehcache.CacheException)9 IOException (java.io.IOException)7 Ehcache (net.sf.ehcache.Ehcache)7 UpdatingSelfPopulatingCache (net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache)6 URL (java.net.URL)5 BlockingCache (net.sf.ehcache.constructs.blocking.BlockingCache)5 SelfPopulatingCache (net.sf.ehcache.constructs.blocking.SelfPopulatingCache)5 DiskStoreConfiguration (net.sf.ehcache.config.DiskStoreConfiguration)4 PersistenceConfiguration (net.sf.ehcache.config.PersistenceConfiguration)4 Around (org.aspectj.lang.annotation.Around)4 Before (org.junit.Before)4 File (java.io.File)3