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:
这些逻辑看起来应该和handler强相关,是不是该挪到handler去?虽然这样做会带来一部分重复的代码
This logic seems like it should be strongly related to the handler, so
should it be moved to the handler, even though it would be a duplicate piece of
code?
##########
integration-tx-api/src/main/java/io/seata/integration/tx/api/interceptor/parser/IfNeedEnhanceBean.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.integration.tx.api.interceptor.parser;
+
+public class IfNeedEnhanceBean {
+
+ private boolean ifNeed;
+
+ private NeedEnhanceEnum needEnhanceEnum;
+
+ public boolean isIfNeed() {
Review Comment:
Is need/isNeed() better than ifNeed/isIfNeed() ?
--
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]