DUBBO 源码分析(1):SPI与自适应拓展点
2019-09-03 09:54:54 2 举报
dubbo源码分析
作者其他创作
大纲/内容
.java
.class
cachedWrapperClasses;
cachedAdaptiveClass;
instance
缓存
className1
wrap
DUBBO 源码分析: SPI 与自适应拓展
className3
ExtensionLoader2
cachedInstances;
EXTENSION_INSTANCES;
javassist/JDK
...
N
getExtension();
dubbo
ExtensionLoaderN
ExtensionLoader
ExtensionLoader<T> getExtensionLoader(Class<T> type);
generate
dubbo internal
getAdaptiveExtension();
createAdaptiveExtensionClass()
injection
private T createExtension(String name);
init: cachedAdaptiveInstance
adaptive extension: 1) class和 instance 都唯一; 2) @Adaptive method 可能有多个.span style=\"font-size: inherit;\
createAdaptiveExtension()
newInstance()
className2
createExtension(name)
创建AdaptiveExtension
Classin JVM
load
spi
创建 Extension
getExtensionClass(String name) ->getExtensionClasses() ->loadExtensionClasses()
is
init: cachedAdaptiveClass
EXTENSION_LOADERS;
cachedAdaptiveInstance;
init: cachedWrapperClasses;cachedAdaptiveClass;cachedClasses;
ExtensionLoader3
方法调用由下面的instance执行; 具体哪个 instance 通过 url 指定
ExtensionLoader1
cachedClasses;
String createAdaptiveExtensionClass();1. adaptiveExtension类代码生成; 2. 查找classLoader;3. 查找 compiler; 4. 利用2)的 classLoader和3)的 compiler对步骤1)里的代码进行编译和加载;
service directory
classLoader
loop cachedWrapperClasses
源码版本: 2.6.7-release. 参考文档: http://dubbo.apache.org/zh-cn/docs/source_code_guide/adaptive-extension.html
0 条评论
下一页