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;
|
||||
if (dataSourceMap.size() > 1) {
|
||||
String dataSourceKey = DataSourceKey.get();
|
||||
|
||||
@ -11,12 +11,12 @@ import javax.sql.DataSource;
|
||||
* @author noear
|
||||
* @since 2.8
|
||||
*/
|
||||
public class FlexDataSourcePlus extends FlexDataSource implements RoutingDataSource {
|
||||
public FlexDataSourcePlus(String dataSourceKey, DataSource dataSource) {
|
||||
public class FlexRoutingDataSource extends FlexDataSource implements RoutingDataSource {
|
||||
public FlexRoutingDataSource(String dataSourceKey, DataSource dataSource) {
|
||||
super(dataSourceKey, dataSource);
|
||||
}
|
||||
|
||||
public FlexDataSourcePlus(String dataSourceKey, DataSource dataSource, boolean needDecryptDataSource) {
|
||||
public FlexRoutingDataSource(String dataSourceKey, DataSource dataSource, boolean needDecryptDataSource) {
|
||||
super(dataSourceKey, dataSource, needDecryptDataSource);
|
||||
}
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
package com.mybatisflex.solon.integration;
|
||||
|
||||
import com.mybatisflex.core.FlexGlobalConfig;
|
||||
import com.mybatisflex.core.datasource.FlexDataSource;
|
||||
import com.mybatisflex.core.mybatis.FlexConfiguration;
|
||||
import com.mybatisflex.core.mybatis.FlexSqlSessionFactoryBuilder;
|
||||
import com.mybatisflex.core.row.RowMapperInvoker;
|
||||
@ -39,12 +38,9 @@ import javax.sql.DataSource;
|
||||
* @since 2.2
|
||||
*/
|
||||
public class MybatisAdapterFlex extends MybatisAdapterDefault {
|
||||
|
||||
FlexSqlSessionFactoryBuilder factoryBuilderPlus;
|
||||
|
||||
FlexGlobalConfig globalConfig;
|
||||
|
||||
RowMapperInvoker rowMapperInvoker;
|
||||
private FlexSqlSessionFactoryBuilder factoryBuilderPlus;
|
||||
private FlexGlobalConfig globalConfig;
|
||||
private RowMapperInvoker rowMapperInvoker;
|
||||
|
||||
protected MybatisAdapterFlex(BeanWrap dsWrap) {
|
||||
super(dsWrap);
|
||||
@ -66,7 +62,7 @@ public class MybatisAdapterFlex extends MybatisAdapterDefault {
|
||||
|
||||
@Override
|
||||
protected DataSource getDataSource() {
|
||||
return new FlexDataSourcePlus(dsWrap.name(), dsWrap.raw());
|
||||
return new FlexRoutingDataSource(dsWrap.name(), dsWrap.raw());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,7 +90,7 @@ public class MybatisAdapterFlex extends MybatisAdapterDefault {
|
||||
FlexGlobalConfig.setConfig(environment.getId(), globalConfig, false);
|
||||
|
||||
//增加事件扩展机制
|
||||
EventBus.push(globalConfig);
|
||||
EventBus.publish(globalConfig);
|
||||
|
||||
|
||||
if (dsWrap.typed()) {
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
package com.mybatisflex.solon.integration;
|
||||
|
||||
import org.apache.ibatis.solon.integration.MybatisAdapterManager;
|
||||
import org.noear.solon.core.AopContext;
|
||||
import org.noear.solon.core.AppContext;
|
||||
import org.noear.solon.core.Plugin;
|
||||
|
||||
@ -28,15 +27,6 @@ import org.noear.solon.core.Plugin;
|
||||
* @since 2.2
|
||||
*/
|
||||
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
|
||||
public void start(AppContext context) throws Throwable {
|
||||
// 此插件的 solon.plugin.priority 会大于 mybatis-solon-plugin 的值
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user