@ -95,7 +106,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -95,7 +106,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
privateCacheResolvercacheResolver;
privateApplicationContextapplicationContext;
privateBeanFactorybeanFactory;
privatebooleaninitialized=false;
@ -164,12 +175,26 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -164,12 +175,26 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
Assert.state(getCacheOperationSource()!=null,"The 'cacheOperationSources' property is required: "+
"If there are no cacheable methods, then don't use a cache aspect.");
@ -181,7 +206,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -181,7 +206,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
if(getCacheResolver()==null){
// Lazily initialize cache resolver via default cache manager...
thrownewIllegalStateException("No CacheResolver specified, and no unique bean of type "+
@ -282,7 +307,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -282,7 +307,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -294,13 +319,12 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -294,13 +319,12 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -329,12 +353,12 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -329,12 +353,12 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -358,7 +382,8 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -358,7 +382,8 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -366,42 +391,56 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -366,42 +391,56 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
// Collect puts from any @Cacheable miss, if no cached item is found
@ -453,7 +492,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -453,7 +492,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -551,7 +590,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -551,7 +590,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
if(cacheOperationContexts==null){// No @Cacheable operation
if(cacheOperationContexts==null){// no @Cacheable operation at all
returnfalse;
}
booleansyncEnabled=false;
@ -563,18 +602,18 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -563,18 +602,18 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
}
if(syncEnabled){
if(this.contexts.size()>1){
thrownewIllegalStateException("@Cacheable(sync=true) cannot be combined with other cache operations on '"+method+"'");
thrownewIllegalStateException("@Cacheable(sync=true) cannot be combined with other cache operations on '"+method+"'");
}
if(cacheOperationContexts.size()>1){
thrownewIllegalStateException("Only one @Cacheable(sync=true) entry is allowed on '"+method+"'");
thrownewIllegalStateException("Only one @Cacheable(sync=true) entry is allowed on '"+method+"'");
thrownewIllegalStateException("@Cacheable(sync=true) only allows a single cache on '"+operation+"'");
thrownewIllegalStateException("@Cacheable(sync=true) only allows a single cache on '"+operation+"'");
}
if(StringUtils.hasText(operation.getUnless())){
thrownewIllegalStateException("@Cacheable(sync=true) does not support unless attribute on '"+operation+"'");
thrownewIllegalStateException("@Cacheable(sync=true) does not support unless attribute on '"+operation+"'");
}
returntrue;
}
@ -702,9 +741,8 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -702,9 +741,8 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@ -790,4 +828,26 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
@@ -790,4 +828,26 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker
}
}
/**
*InnerclasstoavoidaharddependencyonJava8.
*/
@UsesJava8
privatestaticclassOptionalUnwrapper{
publicstaticObjectunwrap(ObjectoptionalObject){
Optional<?>optional=(Optional<?>)optionalObject;
if(!optional.isPresent()){
returnnull;
}
Objectresult=optional.get();
Assert.isTrue(!(resultinstanceofOptional),"Multi-level Optional usage not supported");