Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Loading status checks…
fix sofa 非dubbo 子模块启动时获取 发生`No bean named referenceAnnotationBeanPost…
…Processor` 异常 (#10451)
liufeiyu1002
committed
Aug 14, 2022
Verified
This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent
5672148
commit 29e4e42
Showing
1 changed file
with
5 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...main/java/org/apache/dubbo/config/spring/context/DubboInfraBeanRegisterPostProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| } | |||
| @Override | |||
| public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { | |||
| // In Spring 3.2.x, registry may be null because do not call postProcessBeanDefinitionRegistry method before postProcessBeanFactory | |||
| if (registry != null) { | |||
| // register ReferenceAnnotationBeanPostProcessor early before PropertySourcesPlaceholderConfigurer/PropertyPlaceholderConfigurer | |||
| // for processing early init ReferenceBean | |||
| ReferenceAnnotationBeanPostProcessor referenceAnnotationBeanPostProcessor = beanFactory.getBean( | |||
| ReferenceAnnotationBeanPostProcessor.BEAN_NAME, ReferenceAnnotationBeanPostProcessor.class); | |||
| beanFactory.addBeanPostProcessor(referenceAnnotationBeanPostProcessor); | |||
| // register PropertySourcesPlaceholderConfigurer bean if not exits | |||
| DubboBeanUtils.registerPlaceholderConfigurerBeanIfNotExists(beanFactory, registry); | |||
| } | |||
| ApplicationModel applicationModel = DubboBeanUtils.getApplicationModel(beanFactory); | |||
| ModuleModel moduleModel = DubboBeanUtils.getModuleModel(beanFactory); | |||
| // Initialize SpringExtensionInjector | |||
| SpringExtensionInjector.get(applicationModel).init(applicationContext); | |||
|
|||
|
|||
| SpringExtensionInjector.get(moduleModel).init(applicationContext); | |||
| DubboBeanUtils.getInitializationContext(beanFactory).setApplicationContext(applicationContext); | |||
| // Initialize dubbo Environment before ConfigManager | |||
| // Extract dubbo props from Spring env and put them to app config | |||
| ConfigurableEnvironment environment = (ConfigurableEnvironment) applicationContext.getEnvironment(); | |||
| SortedMap<String, String> dubboProperties = EnvironmentUtils.filterDubboProperties(environment); | |||
| applicationModel.getModelEnvironment().setAppConfigMap(dubboProperties); | |||
|
|
|||
| // register ConfigManager singleton | |||
| beanFactory.registerSingleton(ConfigManager.BEAN_NAME, applicationModel.getApplicationConfigManager()); | |||
|
|
|||
| // fix https://github.com/apache/dubbo/issues/10278 | |||
| if (registry != null){ | |||
| registry.removeBeanDefinition(BEAN_NAME); | |||
| } | |||
| } | |||
|
|
|||
| @Override | |||