Skip to content

Commit 81057a2

Browse files
committed
Require EhCache 2.10+
Issue: SPR-13794
1 parent 4478354 commit 81057a2

File tree

2 files changed

+2
-42
lines changed

2 files changed

+2
-42
lines changed

spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.cache.ehcache;
1818

19-
import java.lang.reflect.Method;
2019
import java.util.Set;
2120

2221
import net.sf.ehcache.Cache;
@@ -37,8 +36,6 @@
3736
import org.springframework.beans.factory.BeanNameAware;
3837
import org.springframework.beans.factory.FactoryBean;
3938
import org.springframework.beans.factory.InitializingBean;
40-
import org.springframework.util.ClassUtils;
41-
import org.springframework.util.ReflectionUtils;
4239

4340
/**
4441
* {@link FactoryBean} that creates a named EhCache {@link net.sf.ehcache.Cache} instance
@@ -64,15 +61,6 @@
6461
*/
6562
public class EhCacheFactoryBean extends CacheConfiguration implements FactoryBean<Ehcache>, BeanNameAware, InitializingBean {
6663

67-
// EhCache's setStatisticsEnabled(boolean) available? Not anymore as of EhCache 2.7...
68-
private static final Method setStatisticsEnabledMethod =
69-
ClassUtils.getMethodIfAvailable(Ehcache.class, "setStatisticsEnabled", boolean.class);
70-
71-
// EhCache's setSampledStatisticsEnabled(boolean) available? Not anymore as of EhCache 2.7...
72-
private static final Method setSampledStatisticsEnabledMethod =
73-
ClassUtils.getMethodIfAvailable(Ehcache.class, "setSampledStatisticsEnabled", boolean.class);
74-
75-
7664
protected final Log logger = LogFactory.getLog(getClass());
7765

7866
private CacheManager cacheManager;
@@ -195,26 +183,6 @@ public void setCacheEventListeners(Set<CacheEventListener> cacheEventListeners)
195183
this.cacheEventListeners = cacheEventListeners;
196184
}
197185

198-
/**
199-
* Set whether to enable EhCache statistics on this cache.
200-
* <p>Note: As of EhCache 2.7, statistics are enabled by default, and cannot be turned off.
201-
* This setter therefore has no effect in such a scenario.
202-
* @see net.sf.ehcache.Ehcache#setStatisticsEnabled
203-
*/
204-
public void setStatisticsEnabled(boolean statisticsEnabled) {
205-
this.statisticsEnabled = statisticsEnabled;
206-
}
207-
208-
/**
209-
* Set whether to enable EhCache's sampled statistics on this cache.
210-
* <p>Note: As of EhCache 2.7, statistics are enabled by default, and cannot be turned off.
211-
* This setter therefore has no effect in such a scenario.
212-
* @see net.sf.ehcache.Ehcache#setSampledStatisticsEnabled
213-
*/
214-
public void setSampledStatisticsEnabled(boolean sampledStatisticsEnabled) {
215-
this.sampledStatisticsEnabled = sampledStatisticsEnabled;
216-
}
217-
218186
/**
219187
* Set whether this cache should be marked as disabled.
220188
* @see net.sf.ehcache.Cache#setDisabled
@@ -276,14 +244,6 @@ public void afterPropertiesSet() throws CacheException {
276244
this.cacheManager.addCache(rawCache);
277245
}
278246

279-
// Only necessary on EhCache <2.7: As of 2.7, statistics are on by default.
280-
if (this.statisticsEnabled && setStatisticsEnabledMethod != null) {
281-
ReflectionUtils.invokeMethod(setStatisticsEnabledMethod, rawCache, true);
282-
}
283-
if (this.sampledStatisticsEnabled && setSampledStatisticsEnabledMethod != null) {
284-
ReflectionUtils.invokeMethod(setSampledStatisticsEnabledMethod, rawCache, true);
285-
}
286-
287247
if (this.disabled) {
288248
rawCache.setDisabled(true);
289249
}

spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheManagerFactoryBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* and cares for proper shutdown of the CacheManager. EhCacheManagerFactoryBean is
4242
* also necessary for loading EhCache configuration from a non-default config location.
4343
*
44-
* <p>Note: As of Spring 4.1, Spring's EhCache support requires EhCache 2.5 or higher.
44+
* <p>Note: As of Spring 5.0, Spring's EhCache support requires EhCache 2.10 or higher.
4545
*
4646
* @author Juergen Hoeller
4747
* @author Dmitriy Kopylenko

0 commit comments

Comments
 (0)