Bughue commented on code in PR #5399:
URL: https://github.com/apache/incubator-seata/pull/5399#discussion_r1439127862


##########
spring/src/main/java/io/seata/spring/annotation/GlobalTransactionScanner.java:
##########
@@ -469,8 +480,71 @@ public void afterPropertiesSet() {
         if (initialized.compareAndSet(false, true)) {
             initClient();
         }
+
+        this.findBusinessBeanNamesNeededEnhancement();
     }
 
+    private void findBusinessBeanNamesNeededEnhancement() {
+        if (applicationContext instanceof ConfigurableApplicationContext) {
+            ConfigurableApplicationContext configurableApplicationContext = 
(ConfigurableApplicationContext) applicationContext;
+            ConfigurableListableBeanFactory configurableListableBeanFactory = 
configurableApplicationContext.getBeanFactory();
+
+            String[] beanNames = applicationContext.getBeanDefinitionNames();
+            for (String contextBeanName : beanNames) {
+                BeanDefinition beanDefinition = 
configurableListableBeanFactory.getBeanDefinition(contextBeanName);
+                if (StringUtils.isBlank(beanDefinition.getBeanClassName())) {
+                    continue;
+                }
+                if 
(IGNORE_ENHANCE_CHECK_SET.contains(beanDefinition.getBeanClassName())) {
+                    continue;
+                }
+                try {
+                    // get the class by bean definition class name
+                    Class<?> beanClass = 
Class.forName(beanDefinition.getBeanClassName());
+                    // check if it needs enhancement by the class
+                    IfNeedEnhanceBean ifNeedEnhanceBean = 
DefaultInterfaceParser.get().parseIfNeedEnhancement(beanClass);
+                    if (!ifNeedEnhanceBean.isIfNeed()) {
+                        continue;
+                    }
+                    if 
(ifNeedEnhanceBean.getNeedEnhanceEnum().equals(NeedEnhanceEnum.SERVICE_BEAN)) {
+                        // the native bean which dubbo, sofa bean service bean 
referenced
+                        PropertyValue propertyValue = 
beanDefinition.getPropertyValues().getPropertyValue("ref");
+                        if (propertyValue == null) {

Review Comment:
   这些逻辑看起来应该和parser强相关,是不是该挪到parser去?虽然这样做会带来一部分重复的代码
   This logic seems like it should be strongly related to the parser, so should 
it be moved to the parser, even though it would be a duplicate piece of code?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to