/** * @return the disk store path, or null if not set. */ public final String getDiskStorePath() { DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration(); if (diskStoreConfiguration == null) { return null; } else { return diskStoreConfiguration.getPath(); } }
private void testAddDiskStoreElement() { DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration(); if (diskStoreConfiguration != null) { addChildElement(new DiskStoreConfigurationElement(this, diskStoreConfiguration)); } }
/** * @return the disk store path, or null if not set. */ public final String getDiskStorePath() { DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration(); if (diskStoreConfiguration == null) { return null; } else { return diskStoreConfiguration.getPath(); } }
/** * @return the disk store path, or null if not set. */ public final String getDiskStorePath() { DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration(); if (diskStoreConfiguration == null) { return null; } else { return diskStoreConfiguration.getPath(); } }
/** * @return the disk store path, or null if not set. */ public final String getDiskStorePath() { DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration(); if (diskStoreConfiguration == null) { return null; } else { return diskStoreConfiguration.getPath(); } }
protected void configureDiskStore( final AppContext appContext, final Configuration ehConfig ) { if ( ehConfig.getDiskStoreConfiguration() != null && ehConfig.getDiskStoreConfiguration().getPath() != null ) { final String path = ehConfig.getDiskStoreConfiguration().getPath(); final String interpolatedPath = appContext != null ? appContext.interpolate( path ) : path; try { ehConfig.getDiskStoreConfiguration().setPath( new File( interpolatedPath ).getCanonicalPath() ); } catch ( IOException e ) { getLogger().warn( "Could not canonize the path \"{}\"!", interpolatedPath, e ); // set the best we can ehConfig.getDiskStoreConfiguration().setPath( new File( interpolatedPath ).getAbsolutePath() ); } } } }
private void testAddDiskStoreElement() { DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration(); if (diskStoreConfiguration != null) { addChildElement(new DiskStoreConfigurationElement(this, diskStoreConfiguration)); } }
private void testAddDiskStoreElement() { DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration(); if (diskStoreConfiguration != null) { addChildElement(new DiskStoreConfigurationElement(this, diskStoreConfiguration)); } }
private static CacheManager findDefaultCacheManager(String confName, URL configFileURL) { try { Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL); conf.setName(confName); if ("java.io.tmpdir".equals(conf.getDiskStoreConfiguration().getOriginalPath())) { String path = conf.getDiskStoreConfiguration().getPath() + File.separator + confName; conf.getDiskStoreConfiguration().setPath(path); } return createCacheManager(conf); } catch (Throwable t) { return null; } }
private void testAddDiskStoreElement() { DiskStoreConfiguration diskStoreConfiguration = configuration.getDiskStoreConfiguration(); if (diskStoreConfiguration != null) { addChildElement(new DiskStoreConfigurationElement(this, diskStoreConfiguration)); } }
configuration.getDiskStoreConfiguration().setPath( cacheStorage.getAbsolutePath() ); ehcacheManager = new net.sf.ehcache.CacheManager( configuration );
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); }
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); }
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); }
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);
@Override public void start() { final Configuration cfg = ConfigurationFactory.parseConfiguration(); cfg.setSource("ehcache defaults"); if (defaultCacheConfiguration != null) { cfg.setDefaultCacheConfiguration(defaultCacheConfiguration); cfg.setSource(cfg.getConfigurationSource() + " + Magnolia-based defaultCacheConfiguration"); } if (diskStorePath != null) { cfg.getDiskStoreConfiguration().setPath(diskStorePath); cfg.setSource(cfg.getConfigurationSource() + " + Magnolia-based diskStorePath"); } cacheManager = new CacheManager(cfg); // TODO cacheManager.setName(...magnolia instance name ...); final MBeanServer mBeanServer = MBeanUtil.getMBeanServer(); ManagementService.registerMBeans(cacheManager, mBeanServer, true, true, true, true); }
private void configureDefaultCache() { final CacheConfiguration c = new CacheConfiguration(); c.setMaxElementsInMemory(1024); c.setMemoryStoreEvictionPolicyFromObject(MemoryStoreEvictionPolicy.LFU); c.setTimeToIdleSeconds(0); c.setTimeToLiveSeconds(0 /* infinite */); c.setEternal(true); if (mgr.getDiskStoreConfiguration() != null) { c.setMaxElementsOnDisk(16384); c.setOverflowToDisk(false); c.setDiskPersistent(false); c.setDiskSpoolBufferSizeMB(5); c.setDiskExpiryThreadIntervalSeconds(60 * 60); } mgr.setDefaultCacheConfiguration(c); }
private void configureDefaultCache() { final CacheConfiguration c = new CacheConfiguration(); c.setMaxElementsInMemory(1024); c.setMemoryStoreEvictionPolicyFromObject(MemoryStoreEvictionPolicy.LFU); c.setTimeToIdleSeconds(0); c.setTimeToLiveSeconds(0 /* infinite */); c.setEternal(true); if (mgr.getDiskStoreConfiguration() != null) { c.setMaxElementsOnDisk(16384); c.setOverflowToDisk(false); c.setDiskPersistent(false); c.setDiskSpoolBufferSizeMB(5); c.setDiskExpiryThreadIntervalSeconds(60 * 60); } mgr.setDefaultCacheConfiguration(c); }
Configuration toConfiguration() { configureDiskStore(); configureDefaultCache(); for (CacheProvider<?, ?> p : caches.values()) { final String name = p.getName(); final CacheConfiguration c = newCache(name); c.setMemoryStoreEvictionPolicyFromObject(toPolicy(p.evictionPolicy())); c.setMaxElementsInMemory(getInt(name, "memorylimit", p.memoryLimit())); c.setTimeToIdleSeconds(0); c.setTimeToLiveSeconds(getSeconds(name, "maxage", p.maxAge())); c.setEternal(c.getTimeToLiveSeconds() == 0); if (p.disk() && mgr.getDiskStoreConfiguration() != null) { c.setMaxElementsOnDisk(getInt(name, "disklimit", p.diskLimit())); int v = c.getDiskSpoolBufferSizeMB() * MB; v = getInt(name, "diskbuffer", v) / MB; c.setDiskSpoolBufferSizeMB(Math.max(1, v)); c.setOverflowToDisk(c.getMaxElementsOnDisk() > 0); c.setDiskPersistent(c.getMaxElementsOnDisk() > 0); } mgr.addCache(c); } return mgr; }
Configuration toConfiguration() { configureDiskStore(); configureDefaultCache(); for (CacheProvider<?, ?> p : caches.values()) { final String name = p.getName(); final CacheConfiguration c = newCache(name); c.setMemoryStoreEvictionPolicyFromObject(toPolicy(p.evictionPolicy())); c.setMaxElementsInMemory(getInt(name, "memorylimit", p.memoryLimit())); c.setTimeToIdleSeconds(0); c.setTimeToLiveSeconds(getSeconds(name, "maxage", p.maxAge())); c.setEternal(c.getTimeToLiveSeconds() == 0); if (p.disk() && mgr.getDiskStoreConfiguration() != null) { c.setMaxElementsOnDisk(getInt(name, "disklimit", p.diskLimit())); int v = c.getDiskSpoolBufferSizeMB() * MB; v = getInt(name, "diskbuffer", v) / MB; c.setDiskSpoolBufferSizeMB(Math.max(1, v)); c.setOverflowToDisk(c.getMaxElementsOnDisk() > 0); c.setDiskPersistent(c.getMaxElementsOnDisk() > 0); } mgr.addCache(c); } return mgr; }