Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix sofa 非dubbo 子模块启动时获取 发生`No bean named referenceAnnotationBeanPost…
…Processor` 异常 (#10451)
liufeiyu1002 committed Aug 14, 2022
1 parent 5672148 commit 29e4e42
Showing 1 changed file with 5 additions and 0 deletions.
}
@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);

COLLECTOR-SAHAB / differentiating test: testServiceClass

applicationContext.resourceCaches.table[0]=null only occurs in the original version.

COLLECTOR-SAHAB / differentiating test: testServiceClass

applicationContext.resourceCaches.table[2]=null only occurs in the patched version.

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

0 comments on commit 29e4e42

Please sign in to comment.