Skip to content

Commit b6364e3

Browse files
committed
Polish Javadoc
1 parent f29bfd9 commit b6364e3

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/datasource/ShardingKeyDataSourceAdapter.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
/**
2929
* An adapter for a target {@link DataSource}, designed to apply sharding keys, if specified,
3030
* to every standard {@code #getConnection} call, returning a direct connection to the shard
31-
* corresponding to the specified sharding key value. All other methods are simply delegated
32-
* to the corresponding methods of the target DataSource.
31+
* corresponding to the specified sharding key value. All other methods simply delegate
32+
* to the corresponding methods of the target {@code DataSource}.
3333
*
34-
* <p>The target {@link DataSource} must implement the {@link #createConnectionBuilder} method;
34+
* <p>The target {@code DataSource} must implement the {@link #createConnectionBuilder} method;
3535
* otherwise, a {@link java.sql.SQLFeatureNotSupportedException} will be thrown when attempting
3636
* to acquire shard connections.
3737
*
@@ -40,7 +40,7 @@
4040
*
4141
* <pre class="code">
4242
* ShardingKeyDataSourceAdapter dataSourceAdapter = new ShardingKeyDataSourceAdapter(dataSource);
43-
* dataSourceAdapter.setShardingKeyProvider(() -> dataSource.createShardingKeyBuilder()
43+
* dataSourceAdapter.setShardingKeyProvider(() -&gt; dataSource.createShardingKeyBuilder()
4444
* .subkey(SecurityContextHolder.getContext().getAuthentication().getName(), JDBCType.VARCHAR).build());
4545
* </pre>
4646
*
@@ -58,17 +58,20 @@ public class ShardingKeyDataSourceAdapter extends DelegatingDataSource {
5858

5959

6060
/**
61-
* Create a new instance of ShardingKeyDataSourceAdapter, wrapping the given {@link DataSource}.
62-
* @param dataSource the target DataSource to be wrapped
61+
* Create a new instance of {@code ShardingKeyDataSourceAdapter}, wrapping the
62+
* given {@link DataSource}.
63+
* @param dataSource the target {@code DataSource} to be wrapped
6364
*/
6465
public ShardingKeyDataSourceAdapter(DataSource dataSource) {
6566
super(dataSource);
6667
}
6768

6869
/**
69-
* Create a new instance of ShardingKeyDataSourceAdapter, wrapping the given {@link DataSource}.
70-
* @param dataSource the target DataSource to be wrapped
71-
* @param shardingKeyProvider the ShardingKeyProvider used to get the sharding keys
70+
* Create a new instance of {@code ShardingKeyDataSourceAdapter}, wrapping the
71+
* given {@link DataSource}.
72+
* @param dataSource the target {@code DataSource} to be wrapped
73+
* @param shardingKeyProvider the {@code ShardingKeyProvider} used to get the
74+
* sharding keys
7275
*/
7376
public ShardingKeyDataSourceAdapter(DataSource dataSource, ShardingKeyProvider shardingKeyProvider) {
7477
super(dataSource);
@@ -87,8 +90,9 @@ public void setShardingKeyProvider(ShardingKeyProvider shardingKeyProvider) {
8790
/**
8891
* Obtain a connection to the database shard using the provided sharding key
8992
* and super sharding key (if available).
90-
* <p>The sharding key is obtained from the {@link ShardingKeyProvider}.
91-
* @return a Connection object representing a direct shard connection
93+
* <p>The sharding key is obtained from the configured
94+
* {@link #setShardingKeyProvider ShardingKeyProvider}.
95+
* @return a {@code Connection} object representing a direct shard connection
9296
* @throws SQLException if an error occurs while creating the connection
9397
* @see #createConnectionBuilder()
9498
*/
@@ -100,21 +104,22 @@ public Connection getConnection() throws SQLException {
100104
/**
101105
* Obtain a connection to the database shard using the provided username and password,
102106
* considering the sharding keys (if available) and the given credentials.
103-
* <p>The sharding key is obtained from the {@link ShardingKeyProvider}.
107+
* <p>The sharding key is obtained from the configured
108+
* {@link #setShardingKeyProvider ShardingKeyProvider}.
104109
* @param username the database user on whose behalf the connection is being made
105110
* @param password the user's password
106-
* @return a Connection object representing a direct shard connection.
107-
* @throws SQLException if an error occurs while creating the connection.
111+
* @return a {@code Connection} object representing a direct shard connection
112+
* @throws SQLException if an error occurs while creating the connection
108113
*/
109114
@Override
110115
public Connection getConnection(String username, String password) throws SQLException {
111116
return createConnectionBuilder().user(username).password(password).build();
112117
}
113118

114119
/**
115-
* Create a new instance of {@link ConnectionBuilder} using the target DataSource's
116-
* {@code createConnectionBuilder()} method, and sets the appropriate sharding keys
117-
* from the {@link ShardingKeyProvider}.
120+
* Create a new instance of {@link ConnectionBuilder} using the target {@code DataSource}'s
121+
* {@code createConnectionBuilder()} method and set the appropriate sharding keys
122+
* from the configured {@link #setShardingKeyProvider ShardingKeyProvider}.
118123
* @return a ConnectionBuilder object representing a builder for direct shard connections
119124
* @throws SQLException if an error occurs while creating the ConnectionBuilder
120125
*/

0 commit comments

Comments
 (0)