public interface DataSourceProcessor
DelegatingDataSourceProcessor 实例化
对动态数据源注解@UseDataSource 增强处理UseDataSource
使用区分Spring模式 和 非Spring模式,Spring模式下,代理处理逻辑 DataSourceInterceptorcom.mybatisflex.spring.datasource.DataSourceInterceptor 优先级高于 FlexMapperProxyFlexMapperProxy ;
所以Spring模式下仅 DataSourceInterceptor 生效(切面生效的前提下)。非Spring 模式下,仅支持注解使用到 Mapper(Dao层),使用到其他层(如Service层)不支持注解解析。
Spring模式下,不区分使用到程序的层(Controller、Service、Dao层都支持),下层控制粒度细上层控制粒粗,使用时根据需要进行灵活应用。
String process(String dataSourceKey, Object targetOrProxy, Method method, Object[] arguments)
dataSourceKey - 注解UseDataSource的value 值,调用process时不会为null,可能为空字符FlexMapperProxy.invoke(Object, Method, Object[])Andcom.mybatisflex.spring.datasource.DataSourceInterceptor#getDataSourceKey(Object, Method, Object[])targetOrProxy - AOP对象this或Mapper代理对象(当注解@UseDataSource使用到Mapper上时为proxy)method - Mapper当前执行的方法函数arguments - Mapper当前执行的函数参数Copyright © 2025. All rights reserved.