Skip to content

Commit a09a031

Browse files
committed
exposed EHCache 1.7's "statisticsEnabled"/"sampledStatisticsEnabled" on EhCacheFactoryBean ()
1 parent 61a5ab9 commit a09a031

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

org.springframework.context/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ public class EhCacheFactoryBean implements FactoryBean<Ehcache>, BeanNameAware,
9999

100100
private Set<CacheEventListener> cacheEventListeners;
101101

102+
private boolean statisticsEnabled = false;
103+
104+
private boolean sampledStatisticsEnabled = false;
105+
102106
private boolean disabled = false;
103107

104108
private String beanName;
@@ -268,6 +272,22 @@ public void setCacheEventListeners(Set<CacheEventListener> cacheEventListeners)
268272
this.cacheEventListeners = cacheEventListeners;
269273
}
270274

275+
/**
276+
* Set whether to enable EhCache statistics on this cache.
277+
* @see net.sf.ehcache.Cache#setStatisticsEnabled
278+
*/
279+
public void setStatisticsEnabled(boolean statisticsEnabled) {
280+
this.statisticsEnabled = statisticsEnabled;
281+
}
282+
283+
/**
284+
* Set whether to enable EhCache's sampled statistics on this cache.
285+
* @see net.sf.ehcache.Cache#setSampledStatisticsEnabled
286+
*/
287+
public void setSampledStatisticsEnabled(boolean sampledStatisticsEnabled) {
288+
this.sampledStatisticsEnabled = sampledStatisticsEnabled;
289+
}
290+
271291
/**
272292
* Set whether this cache should be marked as disabled.
273293
* @see net.sf.ehcache.Cache#setDisabled
@@ -341,6 +361,12 @@ protected Cache createCache() {
341361
cache.getCacheEventNotificationService().registerListener(listener);
342362
}
343363
}
364+
if (this.statisticsEnabled) {
365+
cache.setStatisticsEnabled(true);
366+
}
367+
if (this.sampledStatisticsEnabled) {
368+
cache.setSampledStatisticsEnabled(true);
369+
}
344370
if (this.disabled) {
345371
cache.setDisabled(true);
346372
}

0 commit comments

Comments
 (0)