use of org.springframework.cache.interceptor.BasicOperation in project spring-framework by spring-projects.
the class JCacheAspectSupport method execute.
@SuppressWarnings("unchecked")
private Object execute(CacheOperationInvocationContext<?> context, CacheOperationInvoker invoker) {
CacheOperationInvoker adapter = new CacheOperationInvokerAdapter(invoker);
BasicOperation operation = context.getOperation();
if (operation instanceof CacheResultOperation) {
return this.cacheResultInterceptor.invoke((CacheOperationInvocationContext<CacheResultOperation>) context, adapter);
} else if (operation instanceof CachePutOperation) {
return this.cachePutInterceptor.invoke((CacheOperationInvocationContext<CachePutOperation>) context, adapter);
} else if (operation instanceof CacheRemoveOperation) {
return this.cacheRemoveEntryInterceptor.invoke((CacheOperationInvocationContext<CacheRemoveOperation>) context, adapter);
} else if (operation instanceof CacheRemoveAllOperation) {
return this.cacheRemoveAllInterceptor.invoke((CacheOperationInvocationContext<CacheRemoveAllOperation>) context, adapter);
} else {
throw new IllegalArgumentException("Cannot handle " + operation);
}
}
use of org.springframework.cache.interceptor.BasicOperation in project spring-framework by spring-projects.
the class SimpleExceptionCacheResolver method getCacheNames.
@Override
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
BasicOperation operation = context.getOperation();
if (!(operation instanceof CacheResultOperation)) {
throw new IllegalStateException("Could not extract exception cache name from " + operation);
}
CacheResultOperation cacheResultOperation = (CacheResultOperation) operation;
String exceptionCacheName = cacheResultOperation.getExceptionCacheName();
if (exceptionCacheName != null) {
return Collections.singleton(exceptionCacheName);
}
return null;
}
Aggregations