|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2014 the original author or authors. |
| 2 | + * Copyright 2002-2016 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.cache.ehcache;
|
18 | 18 |
|
19 |
| -import java.lang.reflect.Method; |
20 | 19 | import java.util.Set;
|
21 | 20 |
|
22 | 21 | import net.sf.ehcache.Cache;
|
|
37 | 36 | import org.springframework.beans.factory.BeanNameAware;
|
38 | 37 | import org.springframework.beans.factory.FactoryBean;
|
39 | 38 | import org.springframework.beans.factory.InitializingBean;
|
40 |
| -import org.springframework.util.ClassUtils; |
41 |
| -import org.springframework.util.ReflectionUtils; |
42 | 39 |
|
43 | 40 | /**
|
44 | 41 | * {@link FactoryBean} that creates a named EhCache {@link net.sf.ehcache.Cache} instance
|
|
64 | 61 | */
|
65 | 62 | public class EhCacheFactoryBean extends CacheConfiguration implements FactoryBean<Ehcache>, BeanNameAware, InitializingBean {
|
66 | 63 |
|
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 |
| - |
76 | 64 | protected final Log logger = LogFactory.getLog(getClass());
|
77 | 65 |
|
78 | 66 | private CacheManager cacheManager;
|
@@ -195,26 +183,6 @@ public void setCacheEventListeners(Set<CacheEventListener> cacheEventListeners)
|
195 | 183 | this.cacheEventListeners = cacheEventListeners;
|
196 | 184 | }
|
197 | 185 |
|
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 |
| - |
218 | 186 | /**
|
219 | 187 | * Set whether this cache should be marked as disabled.
|
220 | 188 | * @see net.sf.ehcache.Cache#setDisabled
|
@@ -276,14 +244,6 @@ public void afterPropertiesSet() throws CacheException {
|
276 | 244 | this.cacheManager.addCache(rawCache);
|
277 | 245 | }
|
278 | 246 |
|
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 |
| - |
287 | 247 | if (this.disabled) {
|
288 | 248 | rawCache.setDisabled(true);
|
289 | 249 | }
|
|
0 commit comments