万隆的笔记 万隆的笔记
博文索引
笔试面试
  • 在线学站

    • 菜鸟教程 (opens new window)
    • 入门教程 (opens new window)
    • Coursera (opens new window)
  • 在线文档

    • w3school (opens new window)
    • Bootstrap (opens new window)
    • Vue (opens new window)
    • 阿里开发者藏经阁 (opens new window)
  • 在线工具

    • tool 工具集 (opens new window)
    • bejson 工具集 (opens new window)
    • 文档转换 (opens new window)
  • 更多在线资源
  • Changlog
  • Aboutme
GitHub (opens new window)
博文索引
笔试面试
  • 在线学站

    • 菜鸟教程 (opens new window)
    • 入门教程 (opens new window)
    • Coursera (opens new window)
  • 在线文档

    • w3school (opens new window)
    • Bootstrap (opens new window)
    • Vue (opens new window)
    • 阿里开发者藏经阁 (opens new window)
  • 在线工具

    • tool 工具集 (opens new window)
    • bejson 工具集 (opens new window)
    • 文档转换 (opens new window)
  • 更多在线资源
  • Changlog
  • Aboutme
GitHub (opens new window)
  • ShardingSphere简介
  • ShardingSphere-JDBC
  • 数据分片剖析
  • 读写分离剖析
  • 强制路由剖析
  • 数据脱敏剖析
  • 分布式事务剖析
  • SPI 加载剖析
  • 编排治理剖析
  • ShardingSphere-Proxy
  • ShardingSphere-Sidecar(TODO)
  • ShardingShpere
2022-03-26

SPI 加载剖析

# SPI 加载剖析

Concepts & Features > SPI (opens new window)

新版文档:ShardingSphere > 开发者手册 (opens new window)

在Apache ShardingSphere中,很多功能实现类的加载方式是通过SPI注入的方式完成的。 Service Provider Interface (SPI)是Java提供的一套被第三方实现或扩展的API,它可以用于实现框架扩展或组件替换。

顺便提一句:SPI是一种破坏了类加载的双亲委派机制行为(属于第二次破坏双亲委派机制),这里的破坏不代表他不好,也是有他实际上的使用的。

本节汇总了Apache ShardingSphere所有通过SPI方式载入的功能模块:

  • SQL解析:SQL解析的接口用于规定用于解析SQL的ANTLR语法文件。

    主要接口是SQLParserEntry,其内置实现类有MySQLParserEntry, PostgreSQLParserEntry,SQLServerParserEntry和OracleParserEntry。

  • 数据库协议:数据库协议的接口用于Sharding-Proxy解析与适配访问数据库的协议。

    主要接口是DatabaseProtocolFrontendEngine,其内置实现类有MySQLProtocolFrontendEngine和PostgreSQLProtocolFrontendEngine。

  • 数据脱敏:数据脱敏的接口用于规定加解密器的加密、解密、类型获取、属性设置等方式。

    主要接口有两个:Encryptor和QueryAssistedEncryptor,其中Encryptor的内置实现类有AESEncryptor和MD5Encryptor。

  • 分布式主键:分布式主键的接口主要用于规定如何生成全局性的自增、类型获取、属性设置等。

    主要接口为ShardingKeyGenerator,其内置实现类有UUIDShardingKeyGenerator和SnowflakeShardingKeyGenerator。

  • 分布式事务:分布式事务的接口主要用于规定如何将分布式事务适配为本地事务接口。

    主要接口为ShardingTransactionManager,其内置实现类有XAShardingTransactionManager和 SeataATShardingTransactionManager。

  • XA事务管理器:XA事务管理器的接口主要用于规定如何将XA事务的实现者适配为统一的XA事务接口。

    主要接口为XATransactionManager,其内置实现类有AtomikosTransactionManager,NarayanaXATransactionManager和BitronixXATransactionManager。

  • 注册中心:注册中心的接口主要用于规定注册中心初始化、存取数据、更新数据、监控等行为。

    主要接口为RegistryCenter,其内置实现类有Zookeeper。

上次更新: 5/30/2023, 11:42:20 PM
编排治理剖析

编排治理剖析→

最近更新
01
2025
01-15
02
Elasticsearch面试题
07-17
03
Elasticsearch进阶
07-16
更多文章>
Theme by Vdoing
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式