基于 SpringBoot2.4.1 快速搭建一个 Demo,主要 jar 包依赖版本分别是:
- org.apache.shardingsphere.sharding-jdbc-spring-boot-starter:4.1.1
- org.mybatis.spring.boot.mybatis-spring-boot-starter:2.1.4
在最新的ShardingSphere发行版中,提供了大量的SPI扩展点,开发可以利用SPI扩展点满足各式各样的业务场景。但在官方文档里并未找到对扩展点的详细介绍,因此只能通过阅读源码的方式,寻找ShardingSphere提供的扩展点。
首先通过源码目录结构上,我们看到一个shardingsphere-spi模块
通过该模块下的 NewInstanceServiceLoader
类引用,我们可以查看到Shardingsphere里提供的全部扩展点,下面对扩展点进行一个简单的分类梳理。
扩展点分类
钩子类
- org.apache.shardingsphere.underlying.common.hook.RootInvokeHook
- org.apache.shardingsphere.sql.parser.hook.ParsingHook
- org.apache.shardingsphere.underlying.route.hook.RoutingHook</