From b17714bb7be15e411043c5b122128e43588e6b18 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 22 Nov 2023 12:38:04 +0100 Subject: [PATCH] Polishing --- .../springframework/cache/annotation/CacheConfig.java | 9 ++++++--- .../org/springframework/cache/annotation/Cacheable.java | 8 ++++++-- .../java/org/springframework/jdbc/core/JdbcTemplate.java | 6 ++---- .../jdbc/datasource/TransactionAwareDataSourceProxy.java | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/CacheConfig.java b/spring-context/src/main/java/org/springframework/cache/annotation/CacheConfig.java index 234f353b14..78da3a22e5 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/CacheConfig.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/CacheConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2023 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,6 +32,7 @@ import java.lang.annotation.Target; * @author Stephane Nicoll * @author Sam Brannen * @since 4.1 + * @see Cacheable */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -42,8 +43,10 @@ public @interface CacheConfig { * Names of the default caches to consider for caching operations defined * in the annotated class. *

If none is set at the operation level, these are used instead of the default. - *

May be used to determine the target cache (or caches), matching the - * qualifier value or the bean names of a specific bean definition. + *

Names may be used to determine the target cache(s), to be resolved via the + * configured {@link #cacheResolver()} which typically delegates to + * {@link org.springframework.cache.CacheManager#getCache}. + * For further details see {@link Cacheable#cacheNames()}. */ String[] cacheNames() default {}; diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/Cacheable.java b/spring-context/src/main/java/org/springframework/cache/annotation/Cacheable.java index 13e097ca2a..d91249da5e 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/Cacheable.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/Cacheable.java @@ -68,8 +68,12 @@ public @interface Cacheable { /** * Names of the caches in which method invocation results are stored. - *

Names may be used to determine the target cache (or caches), matching - * the qualifier value or bean name of a specific bean definition. + *

Names may be used to determine the target cache(s), to be resolved via the + * configured {@link #cacheResolver()} which typically delegates to + * {@link org.springframework.cache.CacheManager#getCache}. + *

This will usually be a single cache name. If multiple names are specified, + * they will be consulted for a cache hit in the order of definition, and they + * will all receive a put/evict request for the same newly cached value. * @since 4.2 * @see #value * @see CacheConfig#cacheNames diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java index 335a96022a..cb05218656 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java @@ -60,7 +60,7 @@ import org.springframework.util.LinkedCaseInsensitiveMap; import org.springframework.util.StringUtils; /** - * This is the central class in the JDBC core package. + * This is the central delegate in the JDBC core package. * It simplifies the use of JDBC and helps to avoid common errors. * It executes core JDBC workflow, leaving application code to provide SQL * and extract results. This class executes SQL queries or updates, initiating @@ -417,9 +417,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { logger.debug("Executing SQL statement [" + sql + "]"); } - /** - * Callback to execute the statement. - */ + // Callback to execute the statement. class ExecuteStatementCallback implements StatementCallback, SqlProvider { @Override @Nullable diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java index aed3ddb54b..c053666cc7 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 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. @@ -186,7 +186,7 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource { // Allow for differentiating between the proxy and the raw Connection. StringBuilder sb = new StringBuilder("Transaction-aware proxy for target Connection "); if (this.target != null) { - sb.append('[').append(this.target.toString()).append(']'); + sb.append('[').append(this.target).append(']'); } else { sb.append(" from DataSource [").append(this.targetDataSource).append(']');