dubbo SPI扩展点,通过扩展点名称获取实例的详细流程图
2020-09-29 15:49:08 0 举报
dubbo SPI扩展点,通过扩展点名称获取实例的详细流程图
作者其他创作
大纲/内容
if cachedAdaptiveClass is null or the same as the clazz
load all the extension classes to global variableExtensionLoader.loadExtensionClasses()
no
get instance from EXTENSION_INSTANCESby class type
getHolder from cachedInstances
extensionClasses
check all fields which are not be annotated by DisableInject and has setter function
yes
return extension classes
obtain the instance by extension nameExtensionLoader.getExtensionLoader(Class type).getExtension(String name)
if clazz isAnnotationPresent(Adaptive.class)
getOrCreateHolder
Dubbo SPIThe Process of Getting an Instance by Instance Name
get clazz extension name
cacheDefaultExtensionName
wrap instance by cachedWrapperClasses
if name eqauls \"true\"
instance is null
injectExtension in the instance
createHolderthen put into cachedInstances
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 instance
instanceis null
validate extension name
getInstance
get instance from holder
if the interface type is annotated by @SPIfont color=\"#000000\
get class type by name
return the name of default extention class
noreturn instance
set of cachedWrapperClasses add this clazz
if clazz is annotated by Activate
get extension classes
return instance
cache ActivateClass
set cachedAdaptiveClass
if class type is null
if cachedInstances containsKey(name)
inject by reflective method
if name is empty
validate cached extension classesExtensionLoader.getExtensionClasses()
if clazz extension name is empty
put into EXTENSION_INSTANCES
create extension instance
get clazz simple name and toLowerCase
saveExtensionClasses
return classes then cache
load extension class include(adaptive / wrapper / activate / normal)
if cachedClassesis empty
set cachedDefaultName in global variable
throw exception(More than 1 adaptive class found)
initExtension(lifecycle.initialize)
cachedActivates.put(font color=\"#ff3333\
if clazz isWrapperClass(has a constructor with only one param of interface type)
throw exception
getDefaultExtension
get cached default extensionExtensionLoader.getExtension(String name)
0 条评论
回复 删除
下一页