diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractFallbackJCacheOperationSource.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractFallbackJCacheOperationSource.java
index 8b20e4b1482..d59bd01a49a 100644
--- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractFallbackJCacheOperationSource.java
+++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractFallbackJCacheOperationSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2021 the original author or authors.
+ * Copyright 2002-2024 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.
@@ -29,12 +29,10 @@ import org.springframework.core.MethodClassKey;
import org.springframework.lang.Nullable;
/**
- * Abstract implementation of {@link JCacheOperationSource} that caches attributes
+ * Abstract implementation of {@link JCacheOperationSource} that caches operations
* for methods and implements a fallback policy: 1. specific target method;
* 2. declaring method.
*
- *
This implementation caches attributes by method after they are first used.
- *
* @author Stephane Nicoll
* @author Juergen Hoeller
* @since 4.1
@@ -43,24 +41,25 @@ import org.springframework.lang.Nullable;
public abstract class AbstractFallbackJCacheOperationSource implements JCacheOperationSource {
/**
- * Canonical value held in cache to indicate no caching attribute was
- * found for this method and we don't need to look again.
+ * Canonical value held in cache to indicate no cache operation was
+ * found for this method, and we don't need to look again.
*/
- private static final Object NULL_CACHING_ATTRIBUTE = new Object();
+ private static final Object NULL_CACHING_MARKER = new Object();
protected final Log logger = LogFactory.getLog(getClass());
- private final Map cache = new ConcurrentHashMap<>(1024);
+ private final Map operationCache = new ConcurrentHashMap<>(1024);
@Override
+ @Nullable
public JCacheOperation> getCacheOperation(Method method, @Nullable Class> targetClass) {
MethodClassKey cacheKey = new MethodClassKey(method, targetClass);
- Object cached = this.cache.get(cacheKey);
+ Object cached = this.operationCache.get(cacheKey);
if (cached != null) {
- return (cached != NULL_CACHING_ATTRIBUTE ? (JCacheOperation>) cached : null);
+ return (cached != NULL_CACHING_MARKER ? (JCacheOperation>) cached : null);
}
else {
JCacheOperation> operation = computeCacheOperation(method, targetClass);
@@ -68,10 +67,10 @@ public abstract class AbstractFallbackJCacheOperationSource implements JCacheOpe
if (logger.isDebugEnabled()) {
logger.debug("Adding cacheable method '" + method.getName() + "' with operation: " + operation);
}
- this.cache.put(cacheKey, operation);
+ this.operationCache.put(cacheKey, operation);
}
else {
- this.cache.put(cacheKey, NULL_CACHING_ATTRIBUTE);
+ this.operationCache.put(cacheKey, NULL_CACHING_MARKER);
}
return operation;
}
@@ -84,7 +83,7 @@ public abstract class AbstractFallbackJCacheOperationSource implements JCacheOpe
return null;
}
- // The method may be on an interface, but we need attributes from the target class.
+ // The method may be on an interface, but we need metadata from the target class.
// If the target class is null, the method will be unchanged.
Method specificMethod = AopUtils.getMostSpecificMethod(method, targetClass);
diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java
index b289b14715f..ba7b5d8e9c1 100644
--- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java
+++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2024 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.
@@ -212,10 +212,8 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJC
for (Class> parameterType : parameterTypes) {
parameters.add(parameterType.getName());
}
-
- return method.getDeclaringClass().getName()
- + '.' + method.getName()
- + '(' + StringUtils.collectionToCommaDelimitedString(parameters) + ')';
+ return method.getDeclaringClass().getName() + '.' + method.getName() +
+ '(' + StringUtils.collectionToCommaDelimitedString(parameters) + ')';
}
private int countNonNull(Object... instances) {
diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/BeanFactoryJCacheOperationSourceAdvisor.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/BeanFactoryJCacheOperationSourceAdvisor.java
index 51fda366b04..54e4dcaefb6 100644
--- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/BeanFactoryJCacheOperationSourceAdvisor.java
+++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/BeanFactoryJCacheOperationSourceAdvisor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2023 the original author or authors.
+ * Copyright 2002-2024 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.
@@ -46,6 +46,7 @@ public class BeanFactoryJCacheOperationSourceAdvisor extends AbstractBeanFactory
* Set the cache operation attribute source which is used to find cache
* attributes. This should usually be identical to the source reference
* set on the cache interceptor itself.
+ * @see JCacheInterceptor#setCacheOperationSource
*/
public void setCacheOperationSource(JCacheOperationSource cacheOperationSource) {
this.pointcut.setCacheOperationSource(cacheOperationSource);
diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheOperationSource.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheOperationSource.java
index 445a7ef8282..2aa8c2ddb9f 100644
--- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheOperationSource.java
+++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheOperationSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2024 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.
@@ -34,7 +34,7 @@ public interface JCacheOperationSource {
* Return the cache operations for this method, or {@code null}
* if the method contains no JSR-107 related metadata.
* @param method the method to introspect
- * @param targetClass the target class (may be {@code null}, in which case
+ * @param targetClass the target class (can be {@code null}, in which case
* the declaring class of the method must be used)
* @return the cache operation for this method, or {@code null} if none found
*/
diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheOperationSourcePointcut.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheOperationSourcePointcut.java
index 34693866eea..a61779b0517 100644
--- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheOperationSourcePointcut.java
+++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheOperationSourcePointcut.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2023 the original author or authors.
+ * Copyright 2002-2024 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.
@@ -24,7 +24,7 @@ import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
- * A Pointcut that matches if the underlying {@link JCacheOperationSource}
+ * A {@code Pointcut} that matches if the underlying {@link JCacheOperationSource}
* has an operation for a given method.
*
* @author Stephane Nicoll
diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java
index d20993ae27a..2883826495f 100644
--- a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java
+++ b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2021 the original author or authors.
+ * Copyright 2002-2024 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.
@@ -32,20 +32,16 @@ import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
/**
- * Abstract implementation of {@link CacheOperation} that caches attributes
+ * Abstract implementation of {@link CacheOperationSource} that caches operations
* for methods and implements a fallback policy: 1. specific target method;
* 2. target class; 3. declaring method; 4. declaring class/interface.
*
- *
Defaults to using the target class's caching attribute if none is
- * associated with the target method. Any caching attribute associated with
- * the target method completely overrides a class caching attribute.
+ *
Defaults to using the target class's declared cache operations if none are
+ * associated with the target method. Any cache operations associated with
+ * the target method completely override any class-level declarations.
* If none found on the target class, the interface that the invoked method
* has been called through (in case of a JDK proxy) will be checked.
*
- *
This implementation caches attributes by method after they are first
- * used. If it is ever desirable to allow dynamic changing of cacheable
- * attributes (which is very unlikely), caching could be made configurable.
- *
* @author Costin Leau
* @author Juergen Hoeller
* @since 3.1
@@ -53,10 +49,10 @@ import org.springframework.util.ClassUtils;
public abstract class AbstractFallbackCacheOperationSource implements CacheOperationSource {
/**
- * Canonical value held in cache to indicate no caching attribute was
- * found for this method and we don't need to look again.
+ * Canonical value held in cache to indicate no cache operation was
+ * found for this method, and we don't need to look again.
*/
- private static final Collection NULL_CACHING_ATTRIBUTE = Collections.emptyList();
+ private static final Collection NULL_CACHING_MARKER = Collections.emptyList();
/**
@@ -71,14 +67,14 @@ public abstract class AbstractFallbackCacheOperationSource implements CacheOpera
*
As this base class is not marked Serializable, the cache will be recreated
* after serialization - provided that the concrete subclass is Serializable.
*/
- private final Map