當前位置: 首頁>>代碼示例>>Java>>正文


Java Ehcache.setSampledStatisticsEnabled方法代碼示例

本文整理匯總了Java中net.sf.ehcache.Ehcache.setSampledStatisticsEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java Ehcache.setSampledStatisticsEnabled方法的具體用法?Java Ehcache.setSampledStatisticsEnabled怎麽用?Java Ehcache.setSampledStatisticsEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.ehcache.Ehcache的用法示例。


在下文中一共展示了Ehcache.setSampledStatisticsEnabled方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: afterPropertiesSet

import net.sf.ehcache.Ehcache; //導入方法依賴的package包/類
@Override
public void afterPropertiesSet() throws CacheException, IOException {
	// If no cache name given, use bean name as cache name.
	String cacheName = getName();
	if (cacheName == null) {
		cacheName = this.beanName;
		setName(cacheName);
	}

	// If no CacheManager given, fetch the default.
	if (this.cacheManager == null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Using default EhCache CacheManager for cache region '" + cacheName + "'");
		}
		this.cacheManager = CacheManager.getInstance();
	}

	synchronized (this.cacheManager) {
		// Fetch cache region: If none with the given name exists, create one on the fly.
		Ehcache rawCache;
		boolean cacheExists = this.cacheManager.cacheExists(cacheName);

		if (cacheExists) {
			if (logger.isDebugEnabled()) {
				logger.debug("Using existing EhCache cache region '" + cacheName + "'");
			}
			rawCache = this.cacheManager.getEhcache(cacheName);
		}
		else {
			if (logger.isDebugEnabled()) {
				logger.debug("Creating new EhCache cache region '" + cacheName + "'");
			}
			rawCache = createCache();
			rawCache.setBootstrapCacheLoader(this.bootstrapCacheLoader);
		}

		if (this.cacheEventListeners != null) {
			for (CacheEventListener listener : this.cacheEventListeners) {
				rawCache.getCacheEventNotificationService().registerListener(listener);
			}
		}

		// Needs to happen after listener registration but before setStatisticsEnabled
		if (!cacheExists) {
			this.cacheManager.addCache(rawCache);
		}

		// Only necessary on EhCache <2.7: As of 2.7, statistics are on by default.
		if (setStatisticsAvailable) {
			if (this.statisticsEnabled) {
				rawCache.setStatisticsEnabled(true);
			}
			if (this.sampledStatisticsEnabled) {
				rawCache.setSampledStatisticsEnabled(true);
			}
		}
		if (this.disabled) {
			rawCache.setDisabled(true);
		}

		Ehcache decoratedCache = decorateCache(rawCache);
		if (decoratedCache != rawCache) {
			this.cacheManager.replaceCacheWithDecoratedCache(rawCache, decoratedCache);
		}
		this.cache = decoratedCache;
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:68,代碼來源:EhCacheFactoryBean.java


注:本文中的net.sf.ehcache.Ehcache.setSampledStatisticsEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。