You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2021/09/08 03:13:30 UTC
[shardingsphere] branch master updated: Add RequiredSPI for
DataSourceCreator (#12281)
This is an automated email from the ASF dual-hosted git repository.
panjuan 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 dd877cf Add RequiredSPI for DataSourceCreator (#12281)
dd877cf is described below
commit dd877cfcf210200e427639d6fc1696ce4c046f71
Author: Haoran Meng <me...@gmail.com>
AuthorDate: Wed Sep 8 11:12:36 2021 +0800
Add RequiredSPI for DataSourceCreator (#12281)
---
.../infra/config/datasource/creator/DataSourceCreator.java | 3 ++-
.../infra/config/datasource/creator/DataSourceCreatorFactory.java | 4 ++--
.../config/datasource/creator/impl/DefaultDataSourceCreator.java | 7 ++++++-
...hardingsphere.infra.config.datasource.creator.DataSourceCreator | 1 +
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/DataSourceCreator.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/DataSourceCreator.java
index 044c94e..ae40304 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/DataSourceCreator.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/DataSourceCreator.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.config.datasource.creator;
import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration;
+import org.apache.shardingsphere.spi.required.RequiredSPI;
import org.apache.shardingsphere.spi.typed.TypedSPI;
import javax.sql.DataSource;
@@ -25,7 +26,7 @@ import javax.sql.DataSource;
/**
* Data source creator.
*/
-public interface DataSourceCreator extends TypedSPI {
+public interface DataSourceCreator extends TypedSPI, RequiredSPI {
/**
* Create data source configuration by data source.
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/DataSourceCreatorFactory.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/DataSourceCreatorFactory.java
index 9bb18d5..2af12aa 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/DataSourceCreatorFactory.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/DataSourceCreatorFactory.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.infra.config.datasource.creator;
-import org.apache.shardingsphere.infra.config.datasource.creator.impl.DefaultDataSourceCreator;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.spi.required.RequiredSPIRegistry;
import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
import java.util.Properties;
@@ -39,6 +39,6 @@ public final class DataSourceCreatorFactory {
* @return data source creator
*/
public static DataSourceCreator getDataSourceCreator(final String dataSourceClassName) {
- return TypedSPIRegistry.findRegisteredService(DataSourceCreator.class, dataSourceClassName, new Properties()).orElse(new DefaultDataSourceCreator());
+ return TypedSPIRegistry.findRegisteredService(DataSourceCreator.class, dataSourceClassName, new Properties()).orElse(RequiredSPIRegistry.getRegisteredService(DataSourceCreator.class));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/impl/DefaultDataSourceCreator.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/impl/DefaultDataSourceCreator.java
index d2e0543..91912d5 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/impl/DefaultDataSourceCreator.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/creator/impl/DefaultDataSourceCreator.java
@@ -45,6 +45,11 @@ public final class DefaultDataSourceCreator extends AbstractDataSourceCreator {
@Override
public String getType() {
- return "";
+ return "Default";
+ }
+
+ @Override
+ public boolean isDefault() {
+ return true;
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.creator.DataSourceCreator b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.creator.DataSourceCreator
index 94136aa..f1fc3b0 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.creator.DataSourceCreator
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.creator.DataSourceCreator
@@ -16,3 +16,4 @@
#
org.apache.shardingsphere.infra.config.datasource.creator.impl.HikariDataSourceCreator
+org.apache.shardingsphere.infra.config.datasource.creator.impl.DefaultDataSourceCreator