Search in sources :

Example 41 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project gocd by gocd.

the class CacheInformationProvider method getCacheConfigurationInformationAsJson.

public Map<String, Object> getCacheConfigurationInformationAsJson() {
    CacheConfiguration config = goCache.configuration();
    LinkedHashMap<String, Object> json = new LinkedHashMap<>();
    json.put("name", config.getName());
    json.put("Maximum Elements in Memory", config.getMaxElementsInMemory());
    json.put("Maximum Elements on Disk", config.getMaxElementsOnDisk());
    json.put("Memory Store Eviction Policy", config.getMemoryStoreEvictionPolicy());
    json.put("Clean or Flush", config.isClearOnFlush());
    json.put("Eternal", config.isEternal());
    json.put("Time To Idle Seconds", config.getTimeToIdleSeconds());
    json.put("time To Live Seconds", config.getTimeToLiveSeconds());
    json.put("Overflow To Disk", config.isOverflowToDisk());
    json.put("Disk Persistent", config.isDiskPersistent());
    json.put("Disk Store Path", config.getDiskStorePath());
    json.put("Disk Spool Buffer Size in MB", config.getDiskSpoolBufferSizeMB());
    json.put("Disk Access Stripes", config.getDiskAccessStripes());
    json.put("Disk Expiry Thread Interval Seconds", config.getDiskExpiryThreadIntervalSeconds());
    json.put("Logging Enabled", config.isLoggingEnabled());
    json.put("Cache Event Listener Configurations", config.getCacheEventListenerConfigurations());
    json.put("Cache Extension Configurations", config.getCacheExtensionConfigurations());
    json.put("Cache Extension Configurations", config.getCacheExtensionConfigurations());
    json.put("Bootstrap Cache Loader Factory Configuration", config.getBootstrapCacheLoaderFactoryConfiguration());
    json.put("Cache Exception Handler Factory Configuration", config.getCacheExceptionHandlerFactoryConfiguration());
    json.put("Terracotta Configuration", config.getTerracottaConfiguration());
    json.put("Cache Writer Configuration", config.getCacheWriterConfiguration());
    json.put("Cache Loader Configurations", config.getCacheLoaderConfigurations());
    json.put("Frozen", config.isFrozen());
    json.put("Transactional Mode", config.getTransactionalMode());
    json.put("Statistics", config.getStatistics());
    return json;
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) LinkedHashMap(java.util.LinkedHashMap)

Example 42 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration 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 43 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project cxf by apache.

the class EHCacheUtil method getCacheConfiguration.

public static CacheConfiguration getCacheConfiguration(String key, CacheManager cacheManager) {
    CacheConfiguration cc = cacheManager.getConfiguration().getCacheConfigurations().get(key);
    if (cc == null && key.contains("-")) {
        cc = cacheManager.getConfiguration().getCacheConfigurations().get(key.substring(0, key.lastIndexOf('-') - 1));
    }
    if (cc == null) {
        cc = cacheManager.getConfiguration().getDefaultCacheConfiguration();
    }
    if (cc == null) {
        cc = new CacheConfiguration();
    } else {
        cc = cc.clone();
    }
    cc.setName(key);
    return cc;
}
Also used : CacheConfiguration(net.sf.ehcache.config.CacheConfiguration)

Example 44 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project cxf by apache.

the class EHCacheXKMSClientCache method createCache.

private void createCache(String configFile, Bus cxfBus) {
    if (cxfBus == null) {
        cxfBus = BusFactory.getThreadDefaultBus(true);
    }
    URL configFileURL = null;
    try {
        configFileURL = ClassLoaderUtils.getResource(configFile, EHCacheXKMSClientCache.class);
    } catch (Exception ex) {
    // ignore
    }
    if (configFileURL == null) {
        cacheManager = EHCacheUtil.createCacheManager();
    } else {
        Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
        if (cxfBus != null) {
            conf.setName(cxfBus.getId());
            DiskStoreConfiguration dsc = conf.getDiskStoreConfiguration();
            if (dsc != null && "java.io.tmpdir".equals(dsc.getOriginalPath())) {
                String path = conf.getDiskStoreConfiguration().getPath() + File.separator + cxfBus.getId();
                conf.getDiskStoreConfiguration().setPath(path);
            }
        }
        cacheManager = EHCacheUtil.createCacheManager(conf);
    }
    CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(CACHE_KEY, cacheManager);
    Ehcache newCache = new Cache(cc);
    cache = cacheManager.addCacheIfAbsent(newCache);
}
Also used : DiskStoreConfiguration(net.sf.ehcache.config.DiskStoreConfiguration) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Configuration(net.sf.ehcache.config.Configuration) Ehcache(net.sf.ehcache.Ehcache) DiskStoreConfiguration(net.sf.ehcache.config.DiskStoreConfiguration) URL(java.net.URL) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Cache(net.sf.ehcache.Cache)

Example 45 with CacheConfiguration

use of net.sf.ehcache.config.CacheConfiguration in project cxf by apache.

the class EHCacheTokenReplayCache method createCache.

private void createCache(String configFile, Bus bus) {
    if (bus == null) {
        bus = BusFactory.getThreadDefaultBus(true);
    }
    URL configFileURL = null;
    try {
        configFileURL = ResourceUtils.getClasspathResourceURL(configFile, EHCacheTokenReplayCache.class, bus);
    } catch (Exception ex) {
    // ignore
    }
    if (configFileURL == null) {
        cacheManager = EHCacheUtil.createCacheManager();
    } else {
        Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
        if (bus != null) {
            conf.setName(bus.getId());
            DiskStoreConfiguration dsc = conf.getDiskStoreConfiguration();
            if (dsc != null && "java.io.tmpdir".equals(dsc.getOriginalPath())) {
                String path = conf.getDiskStoreConfiguration().getPath() + File.separator + bus.getId();
                conf.getDiskStoreConfiguration().setPath(path);
            }
        }
        cacheManager = EHCacheUtil.createCacheManager(conf);
    }
    CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(CACHE_KEY, cacheManager);
    Ehcache newCache = new Cache(cc);
    cache = cacheManager.addCacheIfAbsent(newCache);
}
Also used : DiskStoreConfiguration(net.sf.ehcache.config.DiskStoreConfiguration) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Configuration(net.sf.ehcache.config.Configuration) Ehcache(net.sf.ehcache.Ehcache) DiskStoreConfiguration(net.sf.ehcache.config.DiskStoreConfiguration) URL(java.net.URL) IOException(java.io.IOException) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration) Cache(net.sf.ehcache.Cache)

Aggregations

CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)71 Cache (net.sf.ehcache.Cache)26 CacheManager (net.sf.ehcache.CacheManager)16 Ehcache (net.sf.ehcache.Ehcache)14 Configuration (net.sf.ehcache.config.Configuration)14 Element (net.sf.ehcache.Element)9 PersistenceConfiguration (net.sf.ehcache.config.PersistenceConfiguration)8 DiskStoreConfiguration (net.sf.ehcache.config.DiskStoreConfiguration)6 Test (org.junit.Test)6 Resource (org.springframework.core.io.Resource)6 IOException (java.io.IOException)5 Bean (org.springframework.context.annotation.Bean)5 CachedResource (org.apereo.portal.utils.cache.resource.CachedResource)4 CachingResourceLoaderImpl (org.apereo.portal.utils.cache.resource.CachingResourceLoaderImpl)4 LoadedResource (org.apereo.portal.utils.cache.resource.LoadedResource)4 ResourcesElementsProvider (org.jasig.resourceserver.utils.aggr.ResourcesElementsProvider)4 FileSystemResource (org.springframework.core.io.FileSystemResource)4 FileReader (java.io.FileReader)3 URL (java.net.URL)3 SelfPopulatingCache (net.sf.ehcache.constructs.blocking.SelfPopulatingCache)3