mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 16:48:24 +08:00
添加 solon 事务支持
This commit is contained in:
parent
924c085a49
commit
d04192c95f
@ -202,7 +202,7 @@ public class FlexDataSource extends AbstractDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private DataSource getDataSource() {
|
protected DataSource getDataSource() {
|
||||||
DataSource dataSource = defaultDataSource;
|
DataSource dataSource = defaultDataSource;
|
||||||
if (dataSourceMap.size() > 1) {
|
if (dataSourceMap.size() > 1) {
|
||||||
String dataSourceKey = DataSourceKey.get();
|
String dataSourceKey = DataSourceKey.get();
|
||||||
|
|||||||
@ -11,12 +11,12 @@ import javax.sql.DataSource;
|
|||||||
* @author noear
|
* @author noear
|
||||||
* @since 2.8
|
* @since 2.8
|
||||||
*/
|
*/
|
||||||
public class FlexDataSourcePlus extends FlexDataSource implements RoutingDataSource {
|
public class FlexRoutingDataSource extends FlexDataSource implements RoutingDataSource {
|
||||||
public FlexDataSourcePlus(String dataSourceKey, DataSource dataSource) {
|
public FlexRoutingDataSource(String dataSourceKey, DataSource dataSource) {
|
||||||
super(dataSourceKey, dataSource);
|
super(dataSourceKey, dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlexDataSourcePlus(String dataSourceKey, DataSource dataSource, boolean needDecryptDataSource) {
|
public FlexRoutingDataSource(String dataSourceKey, DataSource dataSource, boolean needDecryptDataSource) {
|
||||||
super(dataSourceKey, dataSource, needDecryptDataSource);
|
super(dataSourceKey, dataSource, needDecryptDataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,7 +17,6 @@
|
|||||||
package com.mybatisflex.solon.integration;
|
package com.mybatisflex.solon.integration;
|
||||||
|
|
||||||
import com.mybatisflex.core.FlexGlobalConfig;
|
import com.mybatisflex.core.FlexGlobalConfig;
|
||||||
import com.mybatisflex.core.datasource.FlexDataSource;
|
|
||||||
import com.mybatisflex.core.mybatis.FlexConfiguration;
|
import com.mybatisflex.core.mybatis.FlexConfiguration;
|
||||||
import com.mybatisflex.core.mybatis.FlexSqlSessionFactoryBuilder;
|
import com.mybatisflex.core.mybatis.FlexSqlSessionFactoryBuilder;
|
||||||
import com.mybatisflex.core.row.RowMapperInvoker;
|
import com.mybatisflex.core.row.RowMapperInvoker;
|
||||||
@ -39,12 +38,9 @@ import javax.sql.DataSource;
|
|||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
public class MybatisAdapterFlex extends MybatisAdapterDefault {
|
public class MybatisAdapterFlex extends MybatisAdapterDefault {
|
||||||
|
private FlexSqlSessionFactoryBuilder factoryBuilderPlus;
|
||||||
FlexSqlSessionFactoryBuilder factoryBuilderPlus;
|
private FlexGlobalConfig globalConfig;
|
||||||
|
private RowMapperInvoker rowMapperInvoker;
|
||||||
FlexGlobalConfig globalConfig;
|
|
||||||
|
|
||||||
RowMapperInvoker rowMapperInvoker;
|
|
||||||
|
|
||||||
protected MybatisAdapterFlex(BeanWrap dsWrap) {
|
protected MybatisAdapterFlex(BeanWrap dsWrap) {
|
||||||
super(dsWrap);
|
super(dsWrap);
|
||||||
@ -66,7 +62,7 @@ public class MybatisAdapterFlex extends MybatisAdapterDefault {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DataSource getDataSource() {
|
protected DataSource getDataSource() {
|
||||||
return new FlexDataSourcePlus(dsWrap.name(), dsWrap.raw());
|
return new FlexRoutingDataSource(dsWrap.name(), dsWrap.raw());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -94,7 +90,7 @@ public class MybatisAdapterFlex extends MybatisAdapterDefault {
|
|||||||
FlexGlobalConfig.setConfig(environment.getId(), globalConfig, false);
|
FlexGlobalConfig.setConfig(environment.getId(), globalConfig, false);
|
||||||
|
|
||||||
//增加事件扩展机制
|
//增加事件扩展机制
|
||||||
EventBus.push(globalConfig);
|
EventBus.publish(globalConfig);
|
||||||
|
|
||||||
|
|
||||||
if (dsWrap.typed()) {
|
if (dsWrap.typed()) {
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
package com.mybatisflex.solon.integration;
|
package com.mybatisflex.solon.integration;
|
||||||
|
|
||||||
import org.apache.ibatis.solon.integration.MybatisAdapterManager;
|
import org.apache.ibatis.solon.integration.MybatisAdapterManager;
|
||||||
import org.noear.solon.core.AopContext;
|
|
||||||
import org.noear.solon.core.AppContext;
|
import org.noear.solon.core.AppContext;
|
||||||
import org.noear.solon.core.Plugin;
|
import org.noear.solon.core.Plugin;
|
||||||
|
|
||||||
@ -28,15 +27,6 @@ import org.noear.solon.core.Plugin;
|
|||||||
* @since 2.2
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
public class XPluginImpl implements Plugin {
|
public class XPluginImpl implements Plugin {
|
||||||
|
|
||||||
//兼容 2.5 以下版本
|
|
||||||
@Override
|
|
||||||
public void start(AopContext context) throws Throwable {
|
|
||||||
// 此插件的 solon.plugin.priority 会大于 mybatis-solon-plugin 的值
|
|
||||||
MybatisAdapterManager.setAdapterFactory(new MybatisAdapterFactoryFlex());
|
|
||||||
}
|
|
||||||
|
|
||||||
//兼容 2.5 以上版本
|
|
||||||
@Override
|
@Override
|
||||||
public void start(AppContext context) throws Throwable {
|
public void start(AppContext context) throws Throwable {
|
||||||
// 此插件的 solon.plugin.priority 会大于 mybatis-solon-plugin 的值
|
// 此插件的 solon.plugin.priority 会大于 mybatis-solon-plugin 的值
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
<spring.version>5.3.27</spring.version>
|
<spring.version>5.3.27</spring.version>
|
||||||
<spring-boot.version>2.7.11</spring-boot.version>
|
<spring-boot.version>2.7.11</spring-boot.version>
|
||||||
<solon.version>2.8.4</solon.version>
|
<solon.version>2.9.3</solon.version>
|
||||||
|
|
||||||
<junit.version>4.13.2</junit.version>
|
<junit.version>4.13.2</junit.version>
|
||||||
<testcontainers.version>1.19.3</testcontainers.version>
|
<testcontainers.version>1.19.3</testcontainers.version>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user