dubbo SPI扩展点,自适应扩展点获取实例的详细流程图
2020-09-30 14:26:13 0 举报
dubbo SPI扩展点,自适应扩展点获取实例的详细流程图
作者其他创作
大纲/内容
if clazz is annotated by Activate
inject by reflective method
no
final instance
set the compiled class to cachedAdaptiveClass
yes
get clazz simple name and toLowerCase
get code compilerby SPI
createAdaptiveExtensionClass
set cachedDefaultName in global variable
if cachedAdaptiveClass is null
load extension class include(adaptive / wrapper / activate / normal)
get ClassLoader
AdaptiveClassCodeGenerator.generate() by interface type and cachedDefaultName
get extension classesin order to load cachedAdaptiveClass by class which is annotated by Ataptive
if cachedClassesis empty
if instance is null
return classes then cache
if cachedAdaptiveClass is null or the same as the clazz
injectExtension in the instance
saveExtensionClasses
if clazz isAnnotationPresent(Adaptive.class)
if the interface type is annotated by @SPIfont color=\"#000000\
extensionClasses
getAdaptiveExtension
return class
obtain the instance by adaptive classExtensionLoader.getExtensionLoader(Class type).getAdaptiveExtension()
if clazz extension name is empty
if clazz isWrapperClass(has a constructor with only one param of interface type)
return instance
get adaptive extension classExtensionLoader.getAdaptiveExtensionClass()
noreturn cachedClasses
set of cachedWrapperClasses add this clazz
noreturn instance
get JavassistCompiler(Compiler interface is annotated by @SPI(\"javassist\"))
cachedActivates.put(font color=\"#ff3333\
get instance from cachedAdaptiveInstance
cache ActivateClass
create an adaptive extension classExtensionLoader.createAdaptiveExtensionClass()
lock cachedAdaptiveInstance
set cachedAdaptiveInstance
load all extention classes of this type by strategies(actually load the classes in \"META-INF/dubbo/internal/\" \"META-INF/dubbo/\" \"META-INF/services/\" of this type)
get class code
Dubbo SPIThe Process of Getting an Instance by Adaptive Way
throw exception(More than 1 adaptive class found)
get clazz extension name
check all fields which are not be annotated by DisableInject and has setter function
compile class then load into jvm
set cachedAdaptiveClass
new instance
cacheDefaultExtensionName
createAdaptiveExtension
load all the extension classes to global variableExtensionLoader.loadExtensionClasses()
0 条评论
下一页