本文整理了Java中net.sf.ehcache.config.Configuration.getCacheConfigurations()
方法的一些代码示例,展示了Configuration.getCacheConfigurations()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getCacheConfigurations()
方法的具体详情如下:
包路径:net.sf.ehcache.config.Configuration
类名称:Configuration
方法名:getCacheConfigurations
[英]Gets a Map of cache configurations, keyed by name.
[中]获取缓存配置的映射,按名称键入。
代码示例来源:origin: hibernate/hibernate-orm
for ( CacheConfiguration cacheConfig : config.getCacheConfigurations().values() ) {
if ( cacheConfig.isTerracottaClustered() ) {
setupHibernateTimeoutBehavior( cacheConfig.getTerracottaConfiguration().getNonstopConfiguration() );
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* @return Total amount offheap configured by current caches
*/
public long getTotalConfiguredOffheap() {
long total = getMaxBytesLocalOffHeap();
for (String cacheName : getCacheConfigurationsKeySet()) {
CacheConfiguration config = getCacheConfigurations().get(cacheName);
total += config.getMaxBytesLocalOffHeap();
}
return total;
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* Creates unitialised caches for each cache configuration found
*
* @return an empty set if there are none,
*/
public final Set createCaches() {
Set caches = new HashSet();
Set cacheConfigurations = configuration.getCacheConfigurations().entrySet();
for (Iterator iterator = cacheConfigurations.iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
CacheConfiguration cacheConfiguration = (CacheConfiguration) entry.getValue();
Ehcache cache = createCache(cacheConfiguration);
caches.add(cache);
}
return caches;
}
代码示例来源:origin: net.sf.ehcache.internal/ehcache-core
/**
* @return Total amount offheap configured by current caches
*/
public long getTotalConfiguredOffheap() {
long total = getMaxBytesLocalOffHeap();
for (String cacheName : getCacheConfigurationsKeySet()) {
CacheConfiguration config = getCacheConfigurations().get(cacheName);
total += config.getMaxBytesLocalOffHeap();
}
return total;
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* Creates a cache from configuration where the configuration cache name matches the given name
*
* @return the cache, or null if there is no match
*/
final Ehcache createCacheFromName(String name) {
CacheConfiguration cacheConfiguration = null;
Set cacheConfigurations = configuration.getCacheConfigurations().entrySet();
for (Iterator iterator = cacheConfigurations.iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
CacheConfiguration cacheConfigurationCandidate = (CacheConfiguration) entry.getValue();
if (cacheConfigurationCandidate.name.equals(name)) {
cacheConfiguration = cacheConfigurationCandidate;
break;
}
}
if (cacheConfiguration == null) {
return null;
} else {
return createCache(cacheConfiguration);
}
}
代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache
/**
* @return Total amount offheap configured by current caches
*/
public long getTotalConfiguredOffheap() {
long total = getMaxBytesLocalOffHeap();
for (String cacheName : getCacheConfigurationsKeySet()) {
CacheConfiguration config = getCacheConfigurations().get(cacheName);
total += config.getMaxBytesLocalOffHeap();
}
return total;
}
代码示例来源:origin: net.sf.ehcache/ehcache
private String convertConfigurationToXMLString(net.sf.ehcache.config.Configuration configuration, String cacheManagerName, boolean stripCacheConfigs) {
net.sf.ehcache.config.Configuration targetConfiguration = cloneConfiguration(configuration);
targetConfiguration.setName(cacheManagerName);
if (stripCacheConfigs) {
targetConfiguration.getCacheConfigurations().clear();
}
return ConfigurationUtil.generateCacheManagerConfigurationText(targetConfiguration);
}
代码示例来源:origin: openmrs/openmrs-core
@Override
public CacheManager getObject() {
CacheManager cacheManager = super.getObject();
Map<String, CacheConfiguration> cacheConfig = cacheManager.getConfiguration().getCacheConfigurations();
List<CacheConfiguration> cacheConfigurations = CachePropertiesUtil.getCacheConfigurations();
cacheConfigurations.stream()
.filter(cc ->
cacheConfig.get(cc.getName()) == null)
.forEach(cc ->
cacheManager.addCache(new Cache(cc)));
return cacheManager;
}
}
代码示例来源:origin: net.sf.ehcache/ehcache
private void registerCacheConfiguration(final CacheManager cacheManager) {
Map<String, CacheConfiguration> configMap = cacheManager.getConfiguration().getCacheConfigurations();
if (!configMap.containsKey(getName())) {
cacheManager.getConfiguration().addCache(this, false);
}
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* Calculates the number of caches in the configuration that are diskPersistent
*/
public final int numberOfCachesThatUseDiskStorage() {
int count = 0;
Set cacheConfigurations = configuration.getCacheConfigurations().entrySet();
for (CacheConfiguration cacheConfig : configuration.getCacheConfigurations().values()) {
if (cacheConfig.isOverflowToDisk() || cacheConfig.isDiskPersistent() ||
(cacheConfig.isOverflowToOffHeap() && cacheConfig.isSearchable())) {
count++;
} else {
PersistenceConfiguration persistence = cacheConfig.getPersistenceConfiguration();
if (persistence != null) {
switch (persistence.getStrategy()) {
case LOCALTEMPSWAP:
case LOCALRESTARTABLE:
count++;
break;
default:
break;
}
}
}
}
return count;
}
代码示例来源:origin: net.sf.ehcache/ehcache
@Override
public void maxBytesLocalDiskChanged(final long oldValue, final long newValue) {
if (getMaxBytesLocalDisk() > 0
&& cacheManager.getConfiguration().getCacheConfigurations().keySet().contains(getName())
&& cacheManager.getConfiguration().isMaxBytesLocalDiskSet()) {
long previous = cacheManager.getOnDiskPool().getMaxSize();
long newPoolFreeSize = previous + oldValue - newValue;
//handle case of overallocation of cache
//Only resize the cache manager pool cache pool resizing will be handled by cache
if (newPoolFreeSize >= 0) {
cacheManager.getOnDiskPool().setMaxSize(newPoolFreeSize);
} else {
LOG.warn("Cannot allocate local disk size more than cache disk size, " +
"setting maxBytesLocalDisk {} to old value {}", maxBytesLocalDisk, oldValue);
maxBytesLocalDisk = oldValue;
throw new InvalidConfigurationException("Cannot allocate disk size more than " +
"the cache pool size reverting to previous size " + maxBytesLocalHeap);
}
}
}
}
代码示例来源:origin: net.sf.ehcache/ehcache
@Override
public void maxBytesLocalHeapChanged(final long oldValue, final long newValue) {
if (getMaxBytesLocalHeap() > 0
&& cacheManager.getConfiguration().getCacheConfigurations().keySet().contains(getName())
&& cacheManager.getConfiguration().isMaxBytesLocalHeapSet()) {
long oldCacheManagerPoolSize = cacheManager.getOnHeapPool().getMaxSize();
long newPoolFreeSize = oldCacheManagerPoolSize + oldValue - newValue;
//handle case of overallocation of cache
//Only resize the cache manager pool cache pool resizing will be handled by cache
if (newPoolFreeSize >= 0) {
cacheManager.getOnHeapPool().setMaxSize(newPoolFreeSize);
} else {
maxBytesLocalHeap = oldValue;
throw new InvalidConfigurationException("Cannot allocate heap size more " +
"than the cache pool size reverting to previous size " + maxBytesLocalHeap);
}
}
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* Returns the original configuration text for the input cacheName
*
* @param cacheName
* @return Returns the original configuration text for the input cacheName
* @throws CacheException if the cache with <code>cacheName</code> does not exist in the original config
*/
public String getOriginalConfigurationText(String cacheName) throws CacheException {
if (runtimeCfg.getConfiguration().getConfigurationSource() == null) {
return "Originally configured programmatically. No original configuration source text.";
} else {
Configuration originalConfiguration = runtimeCfg.getConfiguration().getConfigurationSource().createConfiguration();
CacheConfiguration cacheConfiguration = originalConfiguration.getCacheConfigurations().get(cacheName);
if (cacheConfiguration == null) {
throw new CacheException("Cache with name '" + cacheName + "' does not exist in the original configuration");
}
return ConfigurationUtil.generateCacheConfigurationText(runtimeCfg.getConfiguration(), cacheConfiguration);
}
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* Removes a cache from the known list
* @param cacheConfiguration the cacheConfiguration to be removed
*/
public void removeCache(final CacheConfiguration cacheConfiguration) {
if (cacheManager.getOnHeapPool() != null) {
cacheManager.getOnHeapPool().setMaxSize(cacheManager.getOnHeapPool()
.getMaxSize() + cacheConfiguration.getMaxBytesLocalHeap());
}
if (cacheManager.getOnDiskPool() != null) {
cacheManager.getOnDiskPool().setMaxSize(cacheManager.getOnDiskPool()
.getMaxSize() + cacheConfiguration.getMaxBytesLocalDisk());
}
getConfiguration().getCacheConfigurations().remove(cacheConfiguration.getName());
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* 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;
}
代码示例来源:origin: net.sf.ehcache/ehcache
if (terracottaClient.createClusteredInstanceFactory()) {
clustered = true;
if (configuration.getCacheConfigurations().isEmpty()) {
terracottaClient.getClusteredInstanceFactory().linkClusteredCacheManager(getName(), configuration);
代码示例来源:origin: net.sf.ehcache/ehcache
for (CacheConfiguration cacheConfiguration : configuration.getCacheConfigurations().values()) {
addChildElement(new CacheConfigurationElement(this, configuration, cacheConfiguration));
代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache
private void registerCacheConfiguration(final CacheManager cacheManager) {
Map<String, CacheConfiguration> configMap = cacheManager.getConfiguration().getCacheConfigurations();
if (!configMap.containsKey(getName())) {
cacheManager.getConfiguration().addCache(this, false);
}
}
代码示例来源:origin: net.sf.ehcache.internal/ehcache-core
private void registerCacheConfiguration(final CacheManager cacheManager) {
Map<String, CacheConfiguration> configMap = cacheManager.getConfiguration().getCacheConfigurations();
if (!configMap.containsKey(getName())) {
cacheManager.getConfiguration().addCache(this, false);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache
private void registerCacheConfiguration(final CacheManager cacheManager) {
Map<String, CacheConfiguration> configMap = cacheManager.getConfiguration().getCacheConfigurations();
if (!configMap.containsKey(getName())) {
cacheManager.getConfiguration().addCache(this, false);
}
}
内容来源于网络,如有侵权,请联系作者删除!