Polishing

This commit is contained in:
Juergen Hoeller
2019-07-17 23:25:50 +02:00
parent 9ffdf05d77
commit f5daa657f4
8 changed files with 32 additions and 30 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -59,7 +59,7 @@ abstract class AbstractCacheInterceptor<O extends AbstractJCacheOperation<A>, A
/**
* Resolve the cache to use.
* @param context the invocation context
* @return the cache to use (never null)
* @return the cache to use (never {@code null})
*/
protected Cache resolveCache(CacheOperationInvocationContext<O> context) {
Collection<? extends Cache> caches = context.getOperation().getCacheResolver().resolveCaches(context);
@@ -73,7 +73,7 @@ abstract class AbstractCacheInterceptor<O extends AbstractJCacheOperation<A>, A
/**
* Convert the collection of caches in a single expected element.
* <p>Throw an {@link IllegalStateException} if the collection holds more than one element
* @return the single element or {@code null} if the collection is empty
* @return the single element, or {@code null} if the collection is empty
*/
@Nullable
static Cache extractFrom(Collection<? extends Cache> caches) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -42,7 +42,6 @@ class CacheRemoveAllInterceptor extends AbstractCacheInterceptor<CacheRemoveAllO
CacheOperationInvocationContext<CacheRemoveAllOperation> context, CacheOperationInvoker invoker) {
CacheRemoveAllOperation operation = context.getOperation();
boolean earlyRemove = operation.isEarlyRemove();
if (earlyRemove) {
removeAll(context);
@@ -67,8 +66,8 @@ class CacheRemoveAllInterceptor extends AbstractCacheInterceptor<CacheRemoveAllO
protected void removeAll(CacheOperationInvocationContext<CacheRemoveAllOperation> context) {
Cache cache = resolveCache(context);
if (logger.isTraceEnabled()) {
logger.trace("Invalidating entire cache '" + cache.getName() + "' for operation "
+ context.getOperation());
logger.trace("Invalidating entire cache '" + cache.getName() + "' for operation " +
context.getOperation());
}
doClear(cache);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -42,7 +42,6 @@ class CacheRemoveEntryInterceptor extends AbstractKeyCacheInterceptor<CacheRemov
CacheOperationInvocationContext<CacheRemoveOperation> context, CacheOperationInvoker invoker) {
CacheRemoveOperation operation = context.getOperation();
boolean earlyRemove = operation.isEarlyRemove();
if (earlyRemove) {
removeValue(context);
@@ -68,8 +67,8 @@ class CacheRemoveEntryInterceptor extends AbstractKeyCacheInterceptor<CacheRemov
Object key = generateKey(context);
Cache cache = resolveCache(context);
if (logger.isTraceEnabled()) {
logger.trace("Invalidating key [" + key + "] on cache '" + cache.getName()
+ "' for operation " + context.getOperation());
logger.trace("Invalidating key [" + key + "] on cache '" + cache.getName() +
"' for operation " + context.getOperation());
}
doEvict(cache, key);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2019 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.
@@ -50,8 +50,8 @@ class CacheRemoveOperation extends AbstractJCacheKeyOperation<CacheRemove> {
}
/**
* Specify if the cache entry should be remove before invoking the method. By default, the
* cache entry is removed after the method invocation.
* Specify if the cache entry should be removed before invoking the method.
* <p>By default, the cache entry is removed after the method invocation.
* @see javax.cache.annotation.CacheRemove#afterInvocation()
*/
public boolean isEarlyRemove() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 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.
@@ -25,14 +25,16 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
import org.springframework.util.Assert;
/**
* Cache decorator which synchronizes its {@link #put}, {@link #evict} and {@link #clear}
* operations with Spring-managed transactions (through Spring's {@link TransactionSynchronizationManager},
* performing the actual cache put/evict/clear operation only in the after-commit phase of a
* successful transaction. If no transaction is active, {@link #put}, {@link #evict} and
* Cache decorator which synchronizes its {@link #put}, {@link #evict} and
* {@link #clear} operations with Spring-managed transactions (through Spring's
* {@link TransactionSynchronizationManager}, performing the actual cache
* put/evict/clear operation only in the after-commit phase of a successful
* transaction. If no transaction is active, {@link #put}, {@link #evict} and
* {@link #clear} operations will be performed immediately, as usual.
*
* <p>Use of more aggressive operations such as {@link #putIfAbsent} cannot be deferred
* to the after-commit phase of a running transaction. Use these with care.
* <p><b>Note:</b> Use of immediate operations such as {@link #putIfAbsent}
* cannot be deferred to the after-commit phase of a running transaction.
* Use these with care in a transactional environment.
*
* @author Juergen Hoeller
* @author Stephane Nicoll
@@ -54,6 +56,7 @@ public class TransactionAwareCacheDecorator implements Cache {
this.targetCache = targetCache;
}
/**
* Return the target Cache that this Cache should delegate to.
*/