From a09a0316b79f3c25949f83447530d1b3d62b9fb6 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 28 Nov 2011 15:05:53 +0000 Subject: [PATCH] exposed EHCache 1.7's "statisticsEnabled"/"sampledStatisticsEnabled" on EhCacheFactoryBean () --- .../cache/ehcache/EhCacheFactoryBean.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/org.springframework.context/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java index f2ec123a98..745742eca3 100644 --- a/org.springframework.context/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java @@ -99,6 +99,10 @@ public class EhCacheFactoryBean implements FactoryBean, BeanNameAware, private Set cacheEventListeners; + private boolean statisticsEnabled = false; + + private boolean sampledStatisticsEnabled = false; + private boolean disabled = false; private String beanName; @@ -268,6 +272,22 @@ public class EhCacheFactoryBean implements FactoryBean, BeanNameAware, this.cacheEventListeners = cacheEventListeners; } + /** + * Set whether to enable EhCache statistics on this cache. + * @see net.sf.ehcache.Cache#setStatisticsEnabled + */ + public void setStatisticsEnabled(boolean statisticsEnabled) { + this.statisticsEnabled = statisticsEnabled; + } + + /** + * Set whether to enable EhCache's sampled statistics on this cache. + * @see net.sf.ehcache.Cache#setSampledStatisticsEnabled + */ + public void setSampledStatisticsEnabled(boolean sampledStatisticsEnabled) { + this.sampledStatisticsEnabled = sampledStatisticsEnabled; + } + /** * Set whether this cache should be marked as disabled. * @see net.sf.ehcache.Cache#setDisabled @@ -341,6 +361,12 @@ public class EhCacheFactoryBean implements FactoryBean, BeanNameAware, cache.getCacheEventNotificationService().registerListener(listener); } } + if (this.statisticsEnabled) { + cache.setStatisticsEnabled(true); + } + if (this.sampledStatisticsEnabled) { + cache.setSampledStatisticsEnabled(true); + } if (this.disabled) { cache.setDisabled(true); }