Require EhCache 2.10+
Issue: SPR-13794
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cache.ehcache;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sf.ehcache.Cache;
|
||||
@@ -37,8 +36,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* {@link FactoryBean} that creates a named EhCache {@link net.sf.ehcache.Cache} instance
|
||||
@@ -64,15 +61,6 @@ import org.springframework.util.ReflectionUtils;
|
||||
*/
|
||||
public class EhCacheFactoryBean extends CacheConfiguration implements FactoryBean<Ehcache>, BeanNameAware, InitializingBean {
|
||||
|
||||
// EhCache's setStatisticsEnabled(boolean) available? Not anymore as of EhCache 2.7...
|
||||
private static final Method setStatisticsEnabledMethod =
|
||||
ClassUtils.getMethodIfAvailable(Ehcache.class, "setStatisticsEnabled", boolean.class);
|
||||
|
||||
// EhCache's setSampledStatisticsEnabled(boolean) available? Not anymore as of EhCache 2.7...
|
||||
private static final Method setSampledStatisticsEnabledMethod =
|
||||
ClassUtils.getMethodIfAvailable(Ehcache.class, "setSampledStatisticsEnabled", boolean.class);
|
||||
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private CacheManager cacheManager;
|
||||
@@ -195,26 +183,6 @@ public class EhCacheFactoryBean extends CacheConfiguration implements FactoryBea
|
||||
this.cacheEventListeners = cacheEventListeners;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to enable EhCache statistics on this cache.
|
||||
* <p>Note: As of EhCache 2.7, statistics are enabled by default, and cannot be turned off.
|
||||
* This setter therefore has no effect in such a scenario.
|
||||
* @see net.sf.ehcache.Ehcache#setStatisticsEnabled
|
||||
*/
|
||||
public void setStatisticsEnabled(boolean statisticsEnabled) {
|
||||
this.statisticsEnabled = statisticsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to enable EhCache's sampled statistics on this cache.
|
||||
* <p>Note: As of EhCache 2.7, statistics are enabled by default, and cannot be turned off.
|
||||
* This setter therefore has no effect in such a scenario.
|
||||
* @see net.sf.ehcache.Ehcache#setSampledStatisticsEnabled
|
||||
*/
|
||||
public void setSampledStatisticsEnabled(boolean sampledStatisticsEnabled) {
|
||||
this.sampledStatisticsEnabled = sampledStatisticsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this cache should be marked as disabled.
|
||||
* @see net.sf.ehcache.Cache#setDisabled
|
||||
@@ -276,14 +244,6 @@ public class EhCacheFactoryBean extends CacheConfiguration implements FactoryBea
|
||||
this.cacheManager.addCache(rawCache);
|
||||
}
|
||||
|
||||
// Only necessary on EhCache <2.7: As of 2.7, statistics are on by default.
|
||||
if (this.statisticsEnabled && setStatisticsEnabledMethod != null) {
|
||||
ReflectionUtils.invokeMethod(setStatisticsEnabledMethod, rawCache, true);
|
||||
}
|
||||
if (this.sampledStatisticsEnabled && setSampledStatisticsEnabledMethod != null) {
|
||||
ReflectionUtils.invokeMethod(setSampledStatisticsEnabledMethod, rawCache, true);
|
||||
}
|
||||
|
||||
if (this.disabled) {
|
||||
rawCache.setDisabled(true);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.springframework.core.io.Resource;
|
||||
* and cares for proper shutdown of the CacheManager. EhCacheManagerFactoryBean is
|
||||
* also necessary for loading EhCache configuration from a non-default config location.
|
||||
*
|
||||
* <p>Note: As of Spring 4.1, Spring's EhCache support requires EhCache 2.5 or higher.
|
||||
* <p>Note: As of Spring 5.0, Spring's EhCache support requires EhCache 2.10 or higher.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Dmitriy Kopylenko
|
||||
|
||||
Reference in New Issue
Block a user