You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/07/01 15:29:40 UTC

[GitHub] [dubbo] 6westboy9 opened a new issue, #10255: `@Adaptive`注解标注在类上有什么特别之处?

6westboy9 opened a new issue, #10255:
URL: https://github.com/apache/dubbo/issues/10255

   ```
   ExtensionLoader(Class<?> type, ExtensionDirector extensionDirector, ScopeModel scopeModel) {
       this.type = type;
       this.extensionDirector = extensionDirector;
       this.extensionPostProcessors = extensionDirector.getExtensionPostProcessors();
       initInstantiationStrategy();
       this.injector = (type == ExtensionInjector.class ? null : 
                        extensionDirector.getExtensionLoader(ExtensionInjector.class).getAdaptiveExtension()); // ①
       this.activateComparator = new ActivateComparator(extensionDirector);
       this.scopeModel = scopeModel;
   }
   ```
   
   为什么①处不直接使用`this.injector = (type == ExtensionInjector.class ? null : 
                        extensionDirector.getExtensionLoader(ExtensionInjector.class).getExtension("adaptive"));`呢?不太明白`@Adaptive`注解标注在类上有什么特别之处?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] Trying-hc commented on issue #10255: `@Adaptive`注解标注在类上有什么特别之处?

Posted by GitBox <gi...@apache.org>.
Trying-hc commented on issue #10255:
URL: https://github.com/apache/dubbo/issues/10255#issuecomment-1179459784

   我的理解是,使用@Adaptive标注类而非通过getExtension指定类有以下好处:
   1. 自定义扩展:像AdaptiveExtensionInjector、AdaptiveCompiler这些使用@Adaptive标注的类,其内部并没有实现具体的业务逻辑,而是通过一些逻辑调用其他的拓展类,可以满足一些通过方法标注@Adaptive不能实现的拓展逻辑。
   2. 方便理解调用:使用@Adaptive标注类可以让人知道这是静态拓展,约定俗成。而直接指定拓展类则无这层语义。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wangzhenxyz1 commented on issue #10255: `@Adaptive`注解标注在类上有什么特别之处?

Posted by GitBox <gi...@apache.org>.
wangzhenxyz1 commented on issue #10255:
URL: https://github.com/apache/dubbo/issues/10255#issuecomment-1174503864

   dubbo的扩展点,一般是注解在方法上,根据url获取扩展信息,背后就是通过javassist动态生成代码并编译加载,如果是注解在类上的话,表明此扩展点为静态扩展,逻辑就在当前代码里


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org