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

menghaoran 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 413037d  Remove DataSourcePoolCreatorUtil.getDataSource() (#14786)
413037d is described below

commit 413037d518ba5f3f7c65187b9b0e11068cd2cbd6
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Jan 14 20:17:00 2022 +0800

    Remove DataSourcePoolCreatorUtil.getDataSource() (#14786)
---
 .../config/datasource/pool/creator/DataSourcePoolCreatorUtil.java   | 3 ++-
 .../config/datasource/props/DataSourcePropertiesValidator.java      | 6 +++---
 .../datasource/pool/creator/DataSourcePoolCreatorUtilTest.java      | 4 ++--
 .../infra/config/datasource/props/DataSourcePropertiesTest.java     | 3 ++-
 .../datasource/creator/impl/StandardPipelineDataSourceCreator.java  | 4 ++--
 .../mode/manager/cluster/ClusterContextManagerBuilder.java          | 5 +++--
 .../mode/manager/standalone/StandaloneContextManagerBuilder.java    | 5 +++--
 7 files changed, 17 insertions(+), 13 deletions(-)

diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtil.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtil.java
index 91017dc..02ca6bb 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtil.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtil.java
@@ -61,7 +61,8 @@ public final class DataSourcePoolCreatorUtil {
      * @return data source map
      */
     public static Map<String, DataSource> getDataSourceMap(final Map<String, 
DataSourceProperties> dataSourcePropsMap) {
-        return 
dataSourcePropsMap.entrySet().stream().collect(Collectors.toMap(Entry::getKey, 
entry -> getDataSource(entry.getValue()), (oldValue, currentValue) -> oldValue, 
LinkedHashMap::new));
+        return dataSourcePropsMap.entrySet().stream().collect(
+            Collectors.toMap(Entry::getKey, entry -> 
DataSourcePoolCreator.createDataSource(entry.getValue()), (oldValue, 
currentValue) -> oldValue, LinkedHashMap::new));
     }
     
     /**
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesValidator.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesValidator.java
index e4fa5f0..bbee628 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesValidator.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesValidator.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.infra.config.datasource.props;
 
-import 
org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreatorUtil;
+import 
org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
 import 
org.apache.shardingsphere.infra.config.datasource.pool.destroyer.DataSourcePoolDestroyerFactory;
 import 
org.apache.shardingsphere.infra.distsql.exception.resource.InvalidResourcesException;
 
@@ -53,10 +53,10 @@ public final class DataSourcePropertiesValidator {
         }
     }
     
-    private void validate(final String dataSourcePropertyName, final 
DataSourceProperties dataSourceProperties) throws 
InvalidDataSourcePropertiesException {
+    private void validate(final String dataSourcePropertyName, final 
DataSourceProperties dataSourceProps) throws 
InvalidDataSourcePropertiesException {
         DataSource dataSource = null;
         try {
-            dataSource = 
DataSourcePoolCreatorUtil.getDataSource(dataSourceProperties);
+            dataSource = 
DataSourcePoolCreator.createDataSource(dataSourceProps);
             // CHECKSTYLE:OFF
         } catch (final Exception ex) {
             // CHECKSTYLE:ON
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtilTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtilTest.java
index fadc176..898ff43 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtilTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtilTest.java
@@ -71,7 +71,7 @@ public final class DataSourcePoolCreatorUtilTest {
     
     @Test
     public void assertGetDataSource() {
-        HikariDataSource actual = (HikariDataSource) 
DataSourcePoolCreatorUtil.getDataSource(createDataSourceProperties());
+        HikariDataSource actual = (HikariDataSource) 
DataSourcePoolCreator.createDataSource(createDataSourceProperties());
         assertThat(actual.getDriverClassName(), 
is(MockedDataSource.class.getCanonicalName()));
         assertThat(actual.getJdbcUrl(), is("jdbc:mock://127.0.0.1/foo_ds"));
         assertThat(actual.getUsername(), is("root"));
@@ -91,7 +91,7 @@ public final class DataSourcePoolCreatorUtilTest {
         props.put("loginTimeout", "5000");
         DataSourceProperties dataSourceProps = new 
DataSourceProperties(HikariDataSource.class.getName());
         dataSourceProps.getProps().putAll(props);
-        HikariDataSource actual = (HikariDataSource) 
DataSourcePoolCreatorUtil.getDataSource(dataSourceProps);
+        HikariDataSource actual = (HikariDataSource) 
DataSourcePoolCreator.createDataSource(dataSourceProps);
         assertThat(actual.getDriverClassName(), 
is(MockedDataSource.class.getCanonicalName()));
         assertThat(actual.getJdbcUrl(), is("jdbc:mock://127.0.0.1/foo_ds"));
         assertThat(actual.getUsername(), is("root"));
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesTest.java
index b5fb188..d81d65f 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesTest.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.infra.config.datasource.props;
 
 import com.zaxxer.hikari.HikariDataSource;
 import org.apache.commons.dbcp2.BasicDataSource;
+import 
org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
 import 
org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreatorUtil;
 import org.apache.shardingsphere.test.mock.MockedDataSource;
 import org.junit.Rule;
@@ -160,7 +161,7 @@ public final class DataSourcePropertiesTest {
         DataSourceProperties dataSourceProps = new 
DataSourceProperties(HikariDataSource.class.getName());
         dataSourceProps.getProps().putAll(props);
         dataSourceProps.getProps().putAll(new HashMap(customPoolProps));
-        HikariDataSource actual = (HikariDataSource) 
DataSourcePoolCreatorUtil.getDataSource(dataSourceProps);
+        HikariDataSource actual = (HikariDataSource) 
DataSourcePoolCreator.createDataSource(dataSourceProps);
         assertThat(actual.getDriverClassName(), 
is(MockedDataSource.class.getCanonicalName()));
         assertThat(actual.getJdbcUrl(), is("jdbc:mock://127.0.0.1/foo_ds"));
         assertThat(actual.getUsername(), is("root"));
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/impl/StandardPipelineDataSourceCreator.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/impl/StandardPipelineDataSourceCreator.java
index 341a76a..ee644c5 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/impl/StandardPipelineDataSourceCreator.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/impl/StandardPipelineDataSourceCreator.java
@@ -19,8 +19,8 @@ package 
org.apache.shardingsphere.data.pipeline.core.datasource.creator.impl;
 
 import 
org.apache.shardingsphere.data.pipeline.api.datasource.config.impl.StandardPipelineDataSourceConfiguration;
 import 
org.apache.shardingsphere.data.pipeline.core.datasource.creator.PipelineDataSourceCreator;
+import 
org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
 import 
org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
-import 
org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreatorUtil;
 
 import javax.sql.DataSource;
 
@@ -31,7 +31,7 @@ public final class StandardPipelineDataSourceCreator 
implements PipelineDataSour
     
     @Override
     public DataSource createPipelineDataSource(final Object 
pipelineDataSourceConfig) {
-        return DataSourcePoolCreatorUtil.getDataSource((DataSourceProperties) 
pipelineDataSourceConfig);
+        return DataSourcePoolCreator.createDataSource((DataSourceProperties) 
pipelineDataSourceConfig);
     }
     
     @Override
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index 2a9de97..9ffc5e3 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -21,9 +21,10 @@ import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import 
org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
+import 
org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
 import 
org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreatorUtil;
 import 
org.apache.shardingsphere.infra.config.datasource.pool.destroyer.DataSourcePoolDestroyerFactory;
+import 
org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
 import org.apache.shardingsphere.infra.instance.InstanceContext;
 import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
 import org.apache.shardingsphere.infra.metadata.schema.QualifiedSchema;
@@ -190,7 +191,7 @@ public final class ClusterContextManagerBuilder implements 
ContextManagerBuilder
                         && 
DataSourcePoolCreatorUtil.getDataSourceProperties(localDataSources.get(entry.getKey())).equals(entry.getValue()))
 {
                     dataSources.put(entry.getKey(), 
localDataSources.get(entry.getKey()));
                 } else {
-                    dataSources.put(entry.getKey(), 
DataSourcePoolCreatorUtil.getDataSource(entry.getValue()));
+                    dataSources.put(entry.getKey(), 
DataSourcePoolCreator.createDataSource(entry.getValue()));
                 }
             }
             result.put(each.getKey(), dataSources);
diff --git 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
index b37cdab..9d2df90 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
@@ -20,9 +20,10 @@ package org.apache.shardingsphere.mode.manager.standalone;
 import com.google.common.base.Strings;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import 
org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
+import 
org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
 import 
org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreatorUtil;
 import 
org.apache.shardingsphere.infra.config.datasource.pool.destroyer.DataSourcePoolDestroyerFactory;
+import 
org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
 import 
org.apache.shardingsphere.infra.config.mode.PersistRepositoryConfiguration;
 import org.apache.shardingsphere.infra.instance.InstanceContext;
 import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
@@ -143,7 +144,7 @@ public final class StandaloneContextManagerBuilder 
implements ContextManagerBuil
                         && 
DataSourcePoolCreatorUtil.getDataSourceProperties(localDataSources.get(entry.getKey())).equals(entry.getValue()))
 {
                     dataSources.put(entry.getKey(), 
localDataSources.get(entry.getKey()));
                 } else {
-                    dataSources.put(entry.getKey(), 
DataSourcePoolCreatorUtil.getDataSource(entry.getValue()));
+                    dataSources.put(entry.getKey(), 
DataSourcePoolCreator.createDataSource(entry.getValue()));
                 }
             }
             result.put(each.getKey(), dataSources);

Reply via email to