if ( config.getDefaultCacheConfiguration() != null && config.getDefaultCacheConfiguration().isTerracottaClustered() ) { setupHibernateTimeoutBehavior( config.getDefaultCacheConfiguration() .getTerracottaConfiguration() .getNonstopConfiguration()
/** * @return the Default Cache * @throws net.sf.ehcache.CacheException if there is no default cache */ public final Ehcache createDefaultCache() throws CacheException { CacheConfiguration cacheConfiguration = configuration.getDefaultCacheConfiguration(); if (cacheConfiguration == null) { return null; } else { cacheConfiguration.name = Cache.DEFAULT_CACHE_NAME; return createCache(cacheConfiguration); } }
/** * Creates decorated ehcaches for the cache, if any configured in ehcache.xml * * @param cache the cache * @return List of the decorated ehcaches, if any configured in ehcache.xml otherwise returns empty list */ public List<Ehcache> createCacheDecorators(Ehcache cache) { CacheConfiguration cacheConfiguration = cache.getCacheConfiguration(); if (cacheConfiguration == null) { return createDefaultCacheDecorators(cache, configuration.getDefaultCacheConfiguration(), loader); } List<CacheDecoratorFactoryConfiguration> cacheDecoratorConfigurations = cacheConfiguration.getCacheDecoratorConfigurations(); if (cacheDecoratorConfigurations == null || cacheDecoratorConfigurations.size() == 0) { LOG.debug("CacheDecoratorFactory not configured. Skipping for '" + cache.getName() + "'."); return createDefaultCacheDecorators(cache, configuration.getDefaultCacheConfiguration(), loader); } List<Ehcache> result = new ArrayList<Ehcache>(); for (CacheDecoratorFactoryConfiguration factoryConfiguration : cacheDecoratorConfigurations) { Ehcache decoratedCache = createDecoratedCache(cache, factoryConfiguration, false, loader); if (decoratedCache != null) { result.add(decoratedCache); } } for (Ehcache defaultDecoratedCache : createDefaultCacheDecorators(cache, configuration.getDefaultCacheConfiguration(), loader)) { result.add(defaultDecoratedCache); } return result; }
private List<Ehcache> createDefaultCacheDecorators(Ehcache underlyingCache) { return ConfigurationHelper.createDefaultCacheDecorators(underlyingCache, runtimeCfg.getConfiguration() .getDefaultCacheConfiguration(), getClassLoader()); }
/** * Create a cache manager configuration from the supplied url, correcting it for Hibernate compatibility. * <p> * Currently correcting for Hibernate compatibility means simply switching any identity based value modes to serialization. */ static Configuration loadAndCorrectConfiguration(URL url) { Configuration config = ConfigurationFactory.parseConfiguration(url); if (config.getDefaultCacheConfiguration() != null && config.getDefaultCacheConfiguration().isTerracottaClustered()) { setupHibernateTimeoutBehavior(config.getDefaultCacheConfiguration().getTerracottaConfiguration().getNonstopConfiguration()); } for (CacheConfiguration cacheConfig : config.getCacheConfigurations().values()) { if (cacheConfig.isTerracottaClustered()) { setupHibernateTimeoutBehavior(cacheConfig.getTerracottaConfiguration().getNonstopConfiguration()); } } return config; }
/** * @return the Default Cache * @throws net.sf.ehcache.CacheException if there is no default cache */ public final Ehcache createDefaultCache() throws CacheException { CacheConfiguration cacheConfiguration = configuration.getDefaultCacheConfiguration(); if (cacheConfiguration == null) { return null; } else { cacheConfiguration.name = Cache.DEFAULT_CACHE_NAME; return createCache(cacheConfiguration); } }
testAddCacheManagerPeerListenerFactoryElement(); addChildElement(new DefaultCacheConfigurationElement(this, configuration, configuration.getDefaultCacheConfiguration()));
/** * @return the Default Cache * @throws net.sf.ehcache.CacheException if there is no default cache */ public final Ehcache createDefaultCache() throws CacheException { CacheConfiguration cacheConfiguration = configuration.getDefaultCacheConfiguration(); if (cacheConfiguration == null) { return null; } else { cacheConfiguration.name = Cache.DEFAULT_CACHE_NAME; return createCache(cacheConfiguration); } }
/** * @return the Default Cache * @throws net.sf.ehcache.CacheException if there is no default cache */ public final Ehcache createDefaultCache() throws CacheException { CacheConfiguration cacheConfiguration = configuration.getDefaultCacheConfiguration(); if (cacheConfiguration == null) { return null; } else { cacheConfiguration.name = Cache.DEFAULT_CACHE_NAME; return createCache(cacheConfiguration); } }
private List<Ehcache> createDefaultCacheDecorators(Ehcache underlyingCache) { return ConfigurationHelper.createDefaultCacheDecorators(underlyingCache, runtimeCfg.getConfiguration().getDefaultCacheConfiguration()); }
@Override public Properties getProperties() { Configuration ec = cacheManager.getConfiguration(); Properties p = new Properties(); p.put("name", ec.getName()); p.put("source", ec.getConfigurationSource().toString()); p.put("timeoutSeconds", ec.getDefaultTransactionTimeoutInSeconds()); p.put("maxBytesDisk", ec.getMaxBytesLocalDisk()); p.put("maxBytesHeap", ec.getMaxBytesLocalHeap()); p.put("maxDepth", ec.getSizeOfPolicyConfiguration().getMaxDepth()); p.put("defaultCacheMaxEntries", ec.getDefaultCacheConfiguration().getMaxEntriesLocalHeap()); p.put("defaultCacheTimeToIdleSecs", ec.getDefaultCacheConfiguration().getTimeToIdleSeconds()); p.put("defaultCacheTimeToLiveSecs", ec.getDefaultCacheConfiguration().getTimeToLiveSeconds()); p.put("defaultCacheEternal", ec.getDefaultCacheConfiguration().isEternal()); return p; }
private CacheConfiguration newCache(final String name) { try { final CacheConfiguration c; c = mgr.getDefaultCacheConfiguration().clone(); c.setName(name); return c; } catch (CloneNotSupportedException e) { throw new ProvisionException("Cannot configure cache " + name, e); } } }
private CacheConfiguration newCache(final String name) { try { final CacheConfiguration c; c = mgr.getDefaultCacheConfiguration().clone(); c.setName(name); return c; } catch (CloneNotSupportedException e) { throw new ProvisionException("Cannot configure cache " + name, e); } } }
private List<Ehcache> createDefaultCacheDecorators(Ehcache underlyingCache) { return ConfigurationHelper.createDefaultCacheDecorators(underlyingCache, runtimeCfg.getConfiguration() .getDefaultCacheConfiguration(), getClassLoader()); }
private List<Ehcache> createDefaultCacheDecorators(Ehcache underlyingCache) { return ConfigurationHelper.createDefaultCacheDecorators(underlyingCache, runtimeCfg.getConfiguration() .getDefaultCacheConfiguration(), getClassLoader()); }
static CacheManager workAroundCache95(CacheManager ehCacheManager) { final CacheConfiguration defaultConfig = ehCacheManager.getConfiguration().getDefaultCacheConfiguration(); final CacheConfiguration.CacheEventListenerFactoryConfiguration listenerConfig = new CacheConfiguration.CacheEventListenerFactoryConfiguration() .className(NoopCacheEventListenerFactory.class.getName()); defaultConfig.clone().addCacheEventListenerFactory(listenerConfig); if (defaultConfig.getCacheEventListenerConfigurations().isEmpty()) { LOG.warn("It looks like CACHE-95 has been fixed. This workaround should be removed."); } else { LOG.debug("Working around CACHE-95"); } return ehCacheManager; }
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; }
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; }
/** * Create a cache manager configuration from the supplied url, correcting it for Hibernate compatibility. * <p> * Currently correcting for Hibernate compatibility means simply switching any identity based value modes to serialization. */ static Configuration loadAndCorrectConfiguration(URL url) { Configuration config = ConfigurationFactory.parseConfiguration(url); if (config.getDefaultCacheConfiguration() != null && config.getDefaultCacheConfiguration().isTerracottaClustered()) { setupHibernateTimeoutBehavior(config.getDefaultCacheConfiguration().getTerracottaConfiguration().getNonstopConfiguration()); } for (CacheConfiguration cacheConfig : config.getCacheConfigurations().values()) { if (cacheConfig.isTerracottaClustered()) { setupHibernateTimeoutBehavior(cacheConfig.getTerracottaConfiguration().getNonstopConfiguration()); } } return config; }
@Override public Cache getCache(String id) { if (id == null) { throw new IllegalArgumentException("Cache instances require an ID"); } if (!cacheManager.cacheExists(id)) { CacheConfiguration temp = null; if (cacheConfiguration != null) { temp = cacheConfiguration.clone(); } else { // based on defaultCache temp = cacheManager.getConfiguration().getDefaultCacheConfiguration().clone(); } temp.setName(id); net.sf.ehcache.Cache cache = new net.sf.ehcache.Cache(temp); cacheManager.addCache(cache); } return new EhcacheCache(id, cacheManager.getEhcache(id)); }