Prior to this commmit, any configuration class holding a CacheManager
bean would be eagerly instantiated. This is because the
CacheConfiguration infrastructure requests all beans of type
CacheManager.
This commit defers the resolution of the CacheManager as late
as possible.
Issue: SPR-12336
@ -83,7 +84,7 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
@@ -83,7 +84,7 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
}
publicCacheResolvergetCacheResolver(){
returnthis.cacheResolver;
returngetDefaultCacheResolver();
}
/**
@ -95,7 +96,7 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
@@ -95,7 +96,7 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
}
publicCacheResolvergetExceptionCacheResolver(){
returnthis.exceptionCacheResolver;
returngetDefaultExceptionCacheResolver();
}
@Override
@ -105,17 +106,13 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
@@ -105,17 +106,13 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
publicvoidafterSingletonsInstantiated(){// Make sure those are initialized on startup
Assert.notNull(getDefaultCacheResolver(),"Cache resolver should have been initialized.");
Assert.notNull(getDefaultExceptionCacheResolver(),"Exception cache resolver should have been initialized.");
}
@Override
@ -131,11 +128,17 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
@@ -131,11 +128,17 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
@ -144,4 +147,16 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
@@ -144,4 +147,16 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
@ -80,8 +81,7 @@ public class JCacheInterceptorTests extends AbstractJCacheTests {
@@ -80,8 +81,7 @@ public class JCacheInterceptorTests extends AbstractJCacheTests {
@ -117,6 +117,7 @@ public class JCacheInterceptorTests extends AbstractJCacheTests {
@@ -117,6 +117,7 @@ public class JCacheInterceptorTests extends AbstractJCacheTests {
@ -53,61 +53,28 @@ public abstract class AbstractCachingConfiguration<C extends CachingConfigurer>
@@ -53,61 +53,28 @@ public abstract class AbstractCachingConfiguration<C extends CachingConfigurer>
@ -167,15 +168,26 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -167,15 +168,26 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
}
publicvoidafterPropertiesSet(){
Assert.state(this.cacheResolver!=null,"'cacheResolver' is required. Either set the cache resolver "+
"to use or set the cache manager to create a default cache resolver based on it.");
Assert.state(this.cacheOperationSource!=null,"The 'cacheOperationSources' property is required: "+
"If there are no cacheable methods, then don't use a cache aspect.");
Assert.state(this.getErrorHandler()!=null,"The 'errorHandler' is required.");
Assert.state(this.applicationContext!=null,"The application context was not injected as it should.");
@ -73,7 +75,7 @@ public class EnableCachingTests extends AbstractAnnotationTests {
@@ -73,7 +75,7 @@ public class EnableCachingTests extends AbstractAnnotationTests {
@ -106,7 +108,7 @@ public class EnableCachingTests extends AbstractAnnotationTests {
@@ -106,7 +108,7 @@ public class EnableCachingTests extends AbstractAnnotationTests {