diff --git a/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java b/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java index 745742eca331..0bd8679c3d04 100644 --- a/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/cache/ehcache/EhCacheFactoryBean.java @@ -399,7 +399,24 @@ public Ehcache getObject() { } public Class getObjectType() { - return (this.cache != null ? this.cache.getClass() : Ehcache.class); + if (this.cache != null) { + return this.cache.getClass(); + } + + if (this.cacheEntryFactory != null) { + if (this.cacheEntryFactory instanceof UpdatingCacheEntryFactory) { + return UpdatingSelfPopulatingCache.class; + } + else { + return SelfPopulatingCache.class; + } + } + + if (this.blocking) { + return BlockingCache.class; + } + + return Cache.class; } public boolean isSingleton() { diff --git a/spring-context/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java b/spring-context/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java index 2d9b59d0adfa..43ed5d59dfc7 100644 --- a/spring-context/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java +++ b/spring-context/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java @@ -82,7 +82,7 @@ private void doTestEhCacheFactoryBean(boolean useCacheManagerFb) throws Exceptio EhCacheManagerFactoryBean cacheManagerFb = null; try { EhCacheFactoryBean cacheFb = new EhCacheFactoryBean(); - assertEquals(Ehcache.class, cacheFb.getObjectType()); + assertTrue(Ehcache.class.isAssignableFrom(cacheFb.getObjectType())); assertTrue("Singleton property", cacheFb.isSingleton()); if (useCacheManagerFb) { cacheManagerFb = new EhCacheManagerFactoryBean();