扩展点加载扩展

扩展点加载扩展

扩展说明

扩展点本身的加载容器,可从不同容器加载扩展点。

扩展接口

org.apache.dubbo.common.extension.ExtensionFactory

扩展配置

  1. <dubbo:application compiler="jdk" />

已知扩展

  • org.apache.dubbo.common.extension.factory.SpiExtensionFactory
  • org.apache.dubbo.config.spring.extension.SpringExtensionFactory

扩展示例

Maven 项目结构:

  1. src
  2. |-main
  3. |-java
  4. |-com
  5. |-xxx
  6. |-XxxExtensionFactory.java (实现ExtensionFactory接口)
  7. |-resources
  8. |-META-INF
  9. |-dubbo
  10. |-org.apache.dubbo.common.extension.ExtensionFactory (纯文本文件,内容为:xxx=com.xxx.XxxExtensionFactory)

XxxExtensionFactory.java:

  1. package com.xxx;
  2. import org.apache.dubbo.common.extension.ExtensionFactory;
  3. public class XxxExtensionFactory implements ExtensionFactory {
  4. public Object getExtension(Class<?> type, String name) {
  5. // ...
  6. }
  7. }

META-INF/dubbo/org.apache.dubbo.common.extension.ExtensionFactory:

  1. xxx=com.xxx.XxxExtensionFactory

最后修改 March 2, 2023: Fix alias forward in docs3-v2 (#2342) (f16c1535592)