This is an automated email from the ASF dual-hosted git repository.

zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new e44265cd180 Rename DataSourcePoolReflection (#28056)
e44265cd180 is described below

commit e44265cd18032ec328a668b171cdcc5ae7b30ff4
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Aug 12 22:59:19 2023 +0800

    Rename DataSourcePoolReflection (#28056)
    
    * Refactor DataSourceGeneratedDatabaseConfiguration
    
    * Rename DataSourcePoolReflection
---
 .../DataSourceGeneratedDatabaseConfiguration.java  |  2 +-
 .../pool/creator/DataSourcePoolCreator.java        | 32 +++++++++++-----------
 ...flection.java => DataSourcePoolReflection.java} |  6 ++--
 .../creator/DataSourcePoolPropertiesCreator.java   |  4 +--
 4 files changed, 22 insertions(+), 22 deletions(-)

diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/database/impl/DataSourceGeneratedDatabaseConfiguration.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/database/impl/DataSourceGeneratedDatabaseConfiguration.java
index 5e7d8ae29cb..022bdd5e8ed 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/database/impl/DataSourceGeneratedDatabaseConfiguration.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/database/impl/DataSourceGeneratedDatabaseConfiguration.java
@@ -49,7 +49,7 @@ public final class DataSourceGeneratedDatabaseConfiguration 
implements DatabaseC
         ruleConfigurations = ruleConfigs;
         dataSourcePoolPropertiesMap = dataSourceConfigs.entrySet().stream()
                 .collect(Collectors.toMap(Entry::getKey, entry -> 
DataSourcePoolPropertiesCreator.create(entry.getValue()), (oldValue, 
currentValue) -> oldValue, LinkedHashMap::new));
-        this.storageResource = 
DataSourcePoolCreator.createStorageResource(dataSourcePoolPropertiesMap);
+        storageResource = 
DataSourcePoolCreator.createStorageResource(dataSourcePoolPropertiesMap);
     }
     
     @Override
diff --git 
a/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourcePoolCreator.java
 
b/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourcePoolCreator.java
index 921907f0125..56b7855da27 100644
--- 
a/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourcePoolCreator.java
+++ 
b/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourcePoolCreator.java
@@ -202,14 +202,14 @@ public final class DataSourcePoolCreator {
     public static DataSource create(final DataSourcePoolProperties props) {
         DataSource result = createDataSource(props.getPoolClassName());
         Optional<DataSourcePoolMetaData> poolMetaData = 
TypedSPILoader.findService(DataSourcePoolMetaData.class, 
props.getPoolClassName());
-        DataSourceReflection dataSourceReflection = new 
DataSourceReflection(result);
+        DataSourcePoolReflection dataSourcePoolReflection = new 
DataSourcePoolReflection(result);
         if (poolMetaData.isPresent()) {
-            setDefaultFields(dataSourceReflection, poolMetaData.get());
-            setConfiguredFields(props, dataSourceReflection, 
poolMetaData.get());
-            appendJdbcUrlProperties(props.getCustomProperties(), result, 
poolMetaData.get(), dataSourceReflection);
-            
dataSourceReflection.addDefaultDataSourcePoolProperties(poolMetaData.get());
+            setDefaultFields(dataSourcePoolReflection, poolMetaData.get());
+            setConfiguredFields(props, dataSourcePoolReflection, 
poolMetaData.get());
+            appendJdbcUrlProperties(props.getCustomProperties(), result, 
poolMetaData.get(), dataSourcePoolReflection);
+            
dataSourcePoolReflection.addDefaultDataSourcePoolProperties(poolMetaData.get());
         } else {
-            setConfiguredFields(props, dataSourceReflection);
+            setConfiguredFields(props, dataSourcePoolReflection);
         }
         return result;
     }
@@ -235,24 +235,24 @@ public final class DataSourcePoolCreator {
         return (DataSource) 
Class.forName(dataSourceClassName).getConstructor().newInstance();
     }
     
-    private static void setDefaultFields(final DataSourceReflection 
dataSourceReflection, final DataSourcePoolMetaData poolMetaData) {
+    private static void setDefaultFields(final DataSourcePoolReflection 
dataSourcePoolReflection, final DataSourcePoolMetaData poolMetaData) {
         for (Entry<String, Object> entry : 
poolMetaData.getDefaultProperties().entrySet()) {
-            dataSourceReflection.setField(entry.getKey(), entry.getValue());
+            dataSourcePoolReflection.setField(entry.getKey(), 
entry.getValue());
         }
     }
     
-    private static void setConfiguredFields(final DataSourcePoolProperties 
props, final DataSourceReflection dataSourceReflection) {
+    private static void setConfiguredFields(final DataSourcePoolProperties 
props, final DataSourcePoolReflection dataSourcePoolReflection) {
         for (Entry<String, Object> entry : 
props.getAllLocalProperties().entrySet()) {
-            dataSourceReflection.setField(entry.getKey(), entry.getValue());
+            dataSourcePoolReflection.setField(entry.getKey(), 
entry.getValue());
         }
     }
     
-    private static void setConfiguredFields(final DataSourcePoolProperties 
props, final DataSourceReflection dataSourceReflection, final 
DataSourcePoolMetaData poolMetaData) {
+    private static void setConfiguredFields(final DataSourcePoolProperties 
props, final DataSourcePoolReflection dataSourcePoolReflection, final 
DataSourcePoolMetaData poolMetaData) {
         for (Entry<String, Object> entry : 
props.getAllLocalProperties().entrySet()) {
             String fieldName = entry.getKey();
             Object fieldValue = entry.getValue();
             if (isValidProperty(fieldName, fieldValue, poolMetaData) && 
!fieldName.equals(poolMetaData.getFieldMetaData().getJdbcUrlPropertiesFieldName()))
 {
-                dataSourceReflection.setField(fieldName, fieldValue);
+                dataSourcePoolReflection.setField(fieldName, fieldValue);
             }
         }
     }
@@ -263,20 +263,20 @@ public final class DataSourcePoolCreator {
     
     @SuppressWarnings("unchecked")
     private static void appendJdbcUrlProperties(final 
CustomDataSourcePoolProperties customPoolProps, final DataSource 
targetDataSource, final DataSourcePoolMetaData poolMetaData,
-                                                final DataSourceReflection 
dataSourceReflection) {
+                                                final DataSourcePoolReflection 
dataSourcePoolReflection) {
         String jdbcUrlPropertiesFieldName = 
poolMetaData.getFieldMetaData().getJdbcUrlPropertiesFieldName();
         if (null != jdbcUrlPropertiesFieldName && 
customPoolProps.getProperties().containsKey(jdbcUrlPropertiesFieldName)) {
             Map<String, Object> jdbcUrlProps = (Map<String, Object>) 
customPoolProps.getProperties().get(jdbcUrlPropertiesFieldName);
             DataSourcePoolMetaDataReflection dataSourcePoolMetaDataReflection 
= new DataSourcePoolMetaDataReflection(targetDataSource, 
poolMetaData.getFieldMetaData());
-            
dataSourcePoolMetaDataReflection.getJdbcConnectionProperties().ifPresent(optional
 -> setJdbcUrlProperties(dataSourceReflection, optional, jdbcUrlProps, 
jdbcUrlPropertiesFieldName));
+            
dataSourcePoolMetaDataReflection.getJdbcConnectionProperties().ifPresent(optional
 -> setJdbcUrlProperties(dataSourcePoolReflection, optional, jdbcUrlProps, 
jdbcUrlPropertiesFieldName));
         }
     }
     
-    private static void setJdbcUrlProperties(final DataSourceReflection 
dataSourceReflection, final Properties jdbcConnectionProps, final Map<String, 
Object> customProps,
+    private static void setJdbcUrlProperties(final DataSourcePoolReflection 
dataSourcePoolReflection, final Properties jdbcConnectionProps, final 
Map<String, Object> customProps,
                                              final String 
jdbcUrlPropertiesFieldName) {
         for (Entry<String, Object> entry : customProps.entrySet()) {
             jdbcConnectionProps.setProperty(entry.getKey(), 
entry.getValue().toString());
         }
-        dataSourceReflection.setField(jdbcUrlPropertiesFieldName, 
jdbcConnectionProps);
+        dataSourcePoolReflection.setField(jdbcUrlPropertiesFieldName, 
jdbcConnectionProps);
     }
 }
diff --git 
a/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourceReflection.java
 
b/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourcePoolReflection.java
similarity index 98%
rename from 
infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourceReflection.java
rename to 
infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourcePoolReflection.java
index 11337811147..acdab74d8b8 100644
--- 
a/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourceReflection.java
+++ 
b/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/creator/DataSourcePoolReflection.java
@@ -41,9 +41,9 @@ import java.util.Optional;
 import java.util.Properties;
 
 /**
- * Data source reflection.
+ * Data source pool reflection.
  */
-public final class DataSourceReflection {
+public final class DataSourcePoolReflection {
     
     private static final Collection<Class<?>> GENERAL_CLASS_TYPES;
     
@@ -65,7 +65,7 @@ public final class DataSourceReflection {
         SKIPPED_PROPERTY_KEYS = new HashSet<>(Arrays.asList("loginTimeout", 
"driverClassName"));
     }
     
-    public DataSourceReflection(final DataSource dataSource) {
+    public DataSourcePoolReflection(final DataSource dataSource) {
         this.dataSource = dataSource;
         dataSourceMethods = dataSource.getClass().getMethods();
     }
diff --git 
a/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/props/creator/DataSourcePoolPropertiesCreator.java
 
b/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/props/creator/DataSourcePoolPropertiesCreator.java
index 2be26427a08..f360989b617 100644
--- 
a/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/props/creator/DataSourcePoolPropertiesCreator.java
+++ 
b/infra/datasource/core/src/main/java/org/apache/shardingsphere/infra/datasource/pool/props/creator/DataSourcePoolPropertiesCreator.java
@@ -23,7 +23,7 @@ import 
org.apache.shardingsphere.infra.datasource.CatalogSwitchableDataSource;
 import 
org.apache.shardingsphere.infra.datasource.pool.config.ConnectionConfiguration;
 import 
org.apache.shardingsphere.infra.datasource.pool.config.DataSourceConfiguration;
 import 
org.apache.shardingsphere.infra.datasource.pool.config.PoolConfiguration;
-import 
org.apache.shardingsphere.infra.datasource.pool.creator.DataSourceReflection;
+import 
org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolReflection;
 import 
org.apache.shardingsphere.infra.datasource.pool.metadata.DataSourcePoolMetaData;
 import 
org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties;
 import 
org.apache.shardingsphere.infra.datasource.pool.props.domain.custom.CustomDataSourcePoolProperties;
@@ -87,7 +87,7 @@ public final class DataSourcePoolPropertiesCreator {
     private static Map<String, Object> createProperties(final DataSource 
dataSource) {
         Map<String, Object> result = new LinkedHashMap<>();
         Optional<DataSourcePoolMetaData> metaData = 
TypedSPILoader.findService(DataSourcePoolMetaData.class, 
dataSource.getClass().getName());
-        for (Entry<String, Object> entry : new 
DataSourceReflection(dataSource).convertToProperties().entrySet()) {
+        for (Entry<String, Object> entry : new 
DataSourcePoolReflection(dataSource).convertToProperties().entrySet()) {
             String propertyName = entry.getKey();
             Object propertyValue = entry.getValue();
             if (!metaData.isPresent() || isValidProperty(propertyName, 
propertyValue, metaData.get()) && 
!metaData.get().getTransientFieldNames().contains(propertyName)) {

Reply via email to