mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
增加RowMapperInvoker可注入;增加FlexGlobalConfig可事件扩展
This commit is contained in:
parent
028f2c58bd
commit
b415491a4b
@ -4,13 +4,15 @@ import com.mybatisflex.core.FlexGlobalConfig;
|
|||||||
import com.mybatisflex.core.datasource.FlexDataSource;
|
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 org.apache.ibatis.mapping.Environment;
|
import org.apache.ibatis.mapping.Environment;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.apache.ibatis.solon.integration.MybatisAdapterDefault;
|
||||||
import org.noear.solon.Utils;
|
import org.noear.solon.Utils;
|
||||||
import org.noear.solon.core.BeanWrap;
|
import org.noear.solon.core.BeanWrap;
|
||||||
import org.noear.solon.core.Props;
|
import org.noear.solon.core.Props;
|
||||||
import org.noear.solon.core.VarHolder;
|
import org.noear.solon.core.VarHolder;
|
||||||
import org.apache.ibatis.solon.integration.MybatisAdapterDefault;
|
import org.noear.solon.core.event.EventBus;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
@ -84,6 +86,9 @@ public class MybatisAdapterFlex extends MybatisAdapterDefault {
|
|||||||
globalConfig.setConfiguration(config);
|
globalConfig.setConfiguration(config);
|
||||||
|
|
||||||
FlexGlobalConfig.setConfig(environment.getId(), globalConfig, false);
|
FlexGlobalConfig.setConfig(environment.getId(), globalConfig, false);
|
||||||
|
|
||||||
|
//增加事件扩展机制
|
||||||
|
EventBus.push(globalConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,14 +107,25 @@ public class MybatisAdapterFlex extends MybatisAdapterDefault {
|
|||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RowMapperInvoker rowMapperInvoker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void injectTo(VarHolder varH) {
|
public void injectTo(VarHolder varH) {
|
||||||
super.injectTo(varH);
|
super.injectTo(varH);
|
||||||
|
|
||||||
//@Db("db1") SqlSessionFactory factory;
|
//@Db("db1") FlexGlobalConfig globalConfig;
|
||||||
if (FlexGlobalConfig.class.isAssignableFrom(varH.getType())) {
|
if (FlexGlobalConfig.class.isAssignableFrom(varH.getType())) {
|
||||||
varH.setValue(this.getGlobalConfig());
|
varH.setValue(this.getGlobalConfig());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@Db("db1") RowMapperInvoker rowMapper;
|
||||||
|
if (RowMapperInvoker.class.equals(varH.getType())) {
|
||||||
|
if (rowMapperInvoker == null) {
|
||||||
|
rowMapperInvoker = new RowMapperInvoker(getFactory());
|
||||||
|
}
|
||||||
|
varH.setValue(rowMapperInvoker);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@ -65,7 +65,7 @@
|
|||||||
|
|
||||||
<spring.version>5.3.25</spring.version>
|
<spring.version>5.3.25</spring.version>
|
||||||
<spring-boot.version>2.7.10</spring-boot.version>
|
<spring-boot.version>2.7.10</spring-boot.version>
|
||||||
<solon.version>2.2.10</solon.version>
|
<solon.version>2.2.14</solon.version>
|
||||||
|
|
||||||
<junit.version>4.13.2</junit.version>
|
<junit.version>4.13.2</junit.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user