From 26d4f91835efecd2c16d537205e1da9292a405dc Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 24 Mar 2015 19:20:26 +0100 Subject: [PATCH] Compatibility with EhCache 3.0 M1 (as a JCache provider) Issue: SPR-12847 --- build.gradle | 5 +++-- .../org/springframework/cache/ehcache/package-info.java | 7 ++++++- .../springframework/cache/jcache/JCacheEhCacheTests.java | 9 ++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index b03e440ce4..dfb3b7afc1 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ configure(allprojects) { project -> ext.ehcachejcacheVersion = "1.0.1" ext.fileuploadVersion = "1.3.1" ext.freemarkerVersion = "2.3.22" - ext.groovyVersion = "2.4.2" + ext.groovyVersion = "2.4.3" ext.gsonVersion = "2.3.1" ext.hibernate3Version = "3.6.10.Final" ext.hibernate4Version = "4.3.8.Final" @@ -647,8 +647,9 @@ project("spring-context-support") { testCompile("commons-digester:commons-digester:1.8.1") // for Velocity/JasperReports testCompile("org.hsqldb:hsqldb:${hsqldbVersion}") testCompile("org.slf4j:slf4j-api:${slf4jVersion}") - testCompile("org.ehcache:jcache:${ehcachejcacheVersion}") testRuntime("com.sun.mail:javax.mail:1.5.2") + testCompile("org.ehcache:jcache:${ehcachejcacheVersion}") + // testCompile("org.ehcache:ehcache:3.0.0.m1") // alternative to ehcache-jcache above } } diff --git a/spring-context-support/src/main/java/org/springframework/cache/ehcache/package-info.java b/spring-context-support/src/main/java/org/springframework/cache/ehcache/package-info.java index 3263df5a36..4291b2deae 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/ehcache/package-info.java +++ b/spring-context-support/src/main/java/org/springframework/cache/ehcache/package-info.java @@ -1,7 +1,12 @@ /** * Support classes for the open source cache - * EhCache, + * EhCache 2.x, * allowing to set up an EhCache CacheManager and Caches * as beans in a Spring context. + * + *

Note: EhCache 3.x lives in a different package namespace + * and is not covered by the traditional support classes here. + * Instead, consider using it through JCache (JSR-107), with + * Spring's support in {@link org.springframework.cache.jcache}. */ package org.springframework.cache.ehcache; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheTests.java index e915779dc9..9879b2c477 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 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. @@ -20,7 +20,6 @@ import javax.cache.CacheManager; import javax.cache.Caching; import javax.cache.configuration.MutableConfiguration; -import org.ehcache.jcache.JCacheConfiguration; import org.junit.After; import org.junit.Ignore; import org.junit.Test; @@ -82,9 +81,9 @@ public class JCacheEhCacheTests extends AbstractAnnotationTests { CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(); MutableConfiguration mutableConfiguration = new MutableConfiguration(); mutableConfiguration.setStoreByValue(false); // otherwise value has to be Serializable - cacheManager.createCache("testCache", new JCacheConfiguration(mutableConfiguration)); - cacheManager.createCache("primary", new JCacheConfiguration(mutableConfiguration)); - cacheManager.createCache("secondary", new JCacheConfiguration(mutableConfiguration)); + cacheManager.createCache("testCache", mutableConfiguration); + cacheManager.createCache("primary", mutableConfiguration); + cacheManager.createCache("secondary", mutableConfiguration); return cacheManager; }