diff --git a/api-boot-project/api-boot-autoconfigure/pom.xml b/api-boot-project/api-boot-autoconfigure/pom.xml
index 287927c2..393e5ab9 100644
--- a/api-boot-project/api-boot-autoconfigure/pom.xml
+++ b/api-boot-project/api-boot-autoconfigure/pom.xml
@@ -280,7 +280,6 @@
guava
true
-
diff --git a/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/datasource/ApiBootDataSourceSwitchAutoConfiguration.java b/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/datasource/ApiBootDataSourceSwitchAutoConfiguration.java
index d69ad1bb..07acd878 100644
--- a/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/datasource/ApiBootDataSourceSwitchAutoConfiguration.java
+++ b/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/datasource/ApiBootDataSourceSwitchAutoConfiguration.java
@@ -7,9 +7,11 @@
import org.minbox.framework.datasource.aop.interceptor.DataSourceSwitchAnnotationInterceptor;
import org.minbox.framework.datasource.config.DataSourceConfig;
import org.minbox.framework.datasource.config.DataSourceDruidConfig;
-import org.minbox.framework.datasource.routing.ApiBootRoutingDataSource;
+import org.minbox.framework.datasource.routing.MinBoxSwitchRoutingDataSource;
+import org.minbox.framework.datasource.routing.customizer.DataSourceSelectionCustomizer;
import org.minbox.framework.datasource.support.MinBoxDruidDataSource;
import org.minbox.framework.datasource.support.MinBoxHikariDataSource;
+import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -38,10 +40,13 @@ public class ApiBootDataSourceSwitchAutoConfiguration {
/**
* ApiBoot DataSource Switch Properties
*/
- private ApiBootDataSourceSwitchProperties apiBootDataSourceSwitchProperties;
+ private ApiBootDataSourceSwitchProperties dataSourceSwitchProperties;
+ private DataSourceSelectionCustomizer selectionCustomizer;
- public ApiBootDataSourceSwitchAutoConfiguration(ApiBootDataSourceSwitchProperties apiBootDataSourceSwitchProperties) {
- this.apiBootDataSourceSwitchProperties = apiBootDataSourceSwitchProperties;
+ public ApiBootDataSourceSwitchAutoConfiguration(ApiBootDataSourceSwitchProperties dataSourceSwitchProperties,
+ ObjectProvider customizerObjectProvider) {
+ this.dataSourceSwitchProperties = dataSourceSwitchProperties;
+ this.selectionCustomizer = customizerObjectProvider.getIfAvailable();
}
/**
@@ -71,9 +76,9 @@ public DataSource dataSource(DataSourceFactoryBean dataSourceFactoryBean) {
Map dataSourceConfigMap = new HashMap(1);
// put druid datasource config to map
- dataSourceConfigMap.putAll(apiBootDataSourceSwitchProperties.getDruid());
+ dataSourceConfigMap.putAll(dataSourceSwitchProperties.getDruid());
// put hikari datasource config to map
- dataSourceConfigMap.putAll(apiBootDataSourceSwitchProperties.getHikari());
+ dataSourceConfigMap.putAll(dataSourceSwitchProperties.getHikari());
// convert all datasource config
dataSourceConfigMap.keySet().stream().forEach(poolName -> {
@@ -87,7 +92,7 @@ public DataSource dataSource(DataSourceFactoryBean dataSourceFactoryBean) {
dataSourceConfigList.add(dataSourceConfig);
});
- return new ApiBootRoutingDataSource(dataSourceFactoryBean, apiBootDataSourceSwitchProperties.getPrimary(), dataSourceConfigList);
+ return new MinBoxSwitchRoutingDataSource(dataSourceFactoryBean, dataSourceSwitchProperties.getPrimary(), dataSourceConfigList, selectionCustomizer);
}
/**
diff --git a/api-boot-project/api-boot-dependencies/pom.xml b/api-boot-project/api-boot-dependencies/pom.xml
index f5648443..50b4fbb6 100644
--- a/api-boot-project/api-boot-dependencies/pom.xml
+++ b/api-boot-project/api-boot-dependencies/pom.xml
@@ -14,11 +14,12 @@
api-boot-dependencies
${basedir}/../..
- 2.7.3
+ 2.7.15
3.1.0
3.6.2
3.2.0
1.0.2
+ 1.0.3
@@ -159,6 +160,11 @@
api-boot-starter-grace
${revision}
+
+ org.minbox.framework
+ minbox-datasource-switch
+ ${minbox-datasource-switch.version}
+
diff --git a/api-boot-samples/pom.xml b/api-boot-samples/pom.xml
index 9e2cd233..7bc77c8b 100644
--- a/api-boot-samples/pom.xml
+++ b/api-boot-samples/pom.xml
@@ -18,7 +18,8 @@
${project.version}
- 2.7.3
+ 2.7.15
+ 8.0.33
api-boot-samples
pom
@@ -48,4 +49,13 @@
api-boot-sample-ssh-agent
api-boot-sample-grace
+
+
+
+ mysql
+ mysql-connector-java
+ ${mysql.version}
+
+
+
diff --git a/pom.xml b/pom.xml
index 54a19c3a..ab882b8a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,7 +18,7 @@
${revision}
ApiBoot Build
- 2.3.9-SNAPSHOT
+ 2.3.9
1.8
UTF-8
UTF-8