@@ -99,6 +99,10 @@ public class EhCacheFactoryBean implements FactoryBean<Ehcache>, BeanNameAware,
99
99
100
100
private Set <CacheEventListener > cacheEventListeners ;
101
101
102
+ private boolean statisticsEnabled = false ;
103
+
104
+ private boolean sampledStatisticsEnabled = false ;
105
+
102
106
private boolean disabled = false ;
103
107
104
108
private String beanName ;
@@ -268,6 +272,22 @@ public void setCacheEventListeners(Set<CacheEventListener> cacheEventListeners)
268
272
this .cacheEventListeners = cacheEventListeners ;
269
273
}
270
274
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
+
271
291
/**
272
292
* Set whether this cache should be marked as disabled.
273
293
* @see net.sf.ehcache.Cache#setDisabled
@@ -341,6 +361,12 @@ protected Cache createCache() {
341
361
cache .getCacheEventNotificationService ().registerListener (listener );
342
362
}
343
363
}
364
+ if (this .statisticsEnabled ) {
365
+ cache .setStatisticsEnabled (true );
366
+ }
367
+ if (this .sampledStatisticsEnabled ) {
368
+ cache .setSampledStatisticsEnabled (true );
369
+ }
344
370
if (this .disabled ) {
345
371
cache .setDisabled (true );
346
372
}
0 commit comments