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 2021/10/31 04:01:17 UTC

[GitHub] [dubbo] kylixs commented on issue #9126: Dubbo 3.0 Filter 中 获取Spring Bean 的问题。

kylixs commented on issue #9126:
URL: https://github.com/apache/dubbo/issues/9126#issuecomment-955632726


   > 原有的 ExtensionFactory :ExtensionLoader.getExtensionLoader(ExtensionFactory.class).getAdaptiveExtension(); 方法已经废弃,请问新的方法是哪个呢?是否能给出示例?
   
   3.0.3 Dubbo支持多应用实例后,ExtensionLoader也相应的支持多实例,改成通过SPI对应ScopeModel( ApplicationModel/ModuleModel/FrameworkModel) 获取ExtensionLoader。
   
   如Application层的一个SPI:
   ```java
      @SPI(scope = ExtensionScope.APPLICATION)
      public interface  FooSPI {
          ...
      }
   ```
   
   1、加载SPI实例:
   ```java
      ApplicationModel  applicataionModel = ...;
      applicataionModel.getExtensionLoader(FooSPI.class).getAdaptiveExtension();
   ```
   
   2、一般是通过上下文获取到ScopeModel,如:
   1) URL.getScopeModel()
   2) SPI 的构造函数注入
   ```java
      public class MyFooSPI implements FooSPI  {
          public MyFooSPI ( ApplicationModel  applicataionModel ) {
             ...
          }
      }
   ```
   3) DubboBootstrap
   4) Spring ApplicationContext 
   ```
   DubboBeanUtils.getApplicationModel(applicationContext);
   DubboBeanUtils.getModuleModel(applicationContext);
   ```


-- 
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