This is an automated email from the ASF dual-hosted git repository.

xjlgod pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.x by this push:
     new 90aa994848 bugfix: impl of supportsSourceType is not defined (#7104)
90aa994848 is described below

commit 90aa99484816af25e0f2cea5a4e7286b46f02f3b
Author: funkye <jian...@apache.org>
AuthorDate: Sun Jan 12 15:18:22 2025 +0800

    bugfix: impl of supportsSourceType is not defined (#7104)
    
    * bugfix: impl of supportsSourceType is not defined
---
 changes/en-us/2.x.md                               |  3 +-
 changes/zh-cn/2.x.md                               |  2 +-
 .../listener/SeataApplicationListener.java         | 59 ----------------------
 .../loader/SeataPropertiesLoader.java              |  6 +++
 .../src/main/resources/META-INF/spring.factories   |  3 --
 5 files changed, 9 insertions(+), 64 deletions(-)

diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index a2ea0b0b4a..2486264a89 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -10,7 +10,8 @@ Add changes here for all PR submitted to the 2.x branch.
 
 ### bugfix:
 
-- [[#PR_NO](https://github.com/apache/incubator-seata/pull/#PR_NO)] fix XXX
+- [[#7104](https://github.com/apache/incubator-seata/pull/7104)] fix impl of 
supportsSourceType is not defined
+
 
 ### optimize:
 
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 0c4892049b..003a9beca6 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -10,7 +10,7 @@
 
 ### bugfix:
 
-- [[#PR_NO](https://github.com/apache/incubator-seata/pull/#PR_NO)] 修复XXX
+- [[#7104](https://github.com/apache/incubator-seata/pull/7104)] 
修复SeataApplicationListener在低版本springboot未实现supportsSourceType方法的问题
 
 ### optimize:
 
diff --git 
a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/java/org/apache/seata/spring/boot/autoconfigure/listener/SeataApplicationListener.java
 
b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/java/org/apache/seata/spring/boot/autoconfigure/listener/SeataApplicationListener.java
deleted file mode 100644
index b347490a1a..0000000000
--- 
a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/java/org/apache/seata/spring/boot/autoconfigure/listener/SeataApplicationListener.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 org.apache.seata.spring.boot.autoconfigure.listener;
-
-import org.apache.seata.common.holder.ObjectHolder;
-import 
org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
-import org.springframework.boot.context.event.ApplicationReadyEvent;
-import org.springframework.boot.context.logging.LoggingApplicationListener;
-import org.springframework.context.ApplicationEvent;
-import org.springframework.context.event.GenericApplicationListener;
-import org.springframework.core.ResolvableType;
-import org.springframework.core.env.ConfigurableEnvironment;
-
-import static 
org.apache.seata.common.Constants.OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT;
-
-
-public class SeataApplicationListener implements GenericApplicationListener {
-
-    @Override
-    public boolean supportsEventType(ResolvableType eventType) {
-        return eventType.getRawClass() != null
-                && 
(ApplicationEnvironmentPreparedEvent.class.isAssignableFrom(eventType.getRawClass())
 ||
-                
ApplicationReadyEvent.class.isAssignableFrom(eventType.getRawClass()));
-    }
-
-    @Override
-    public void onApplicationEvent(ApplicationEvent event) {
-        if (!(event instanceof ApplicationEnvironmentPreparedEvent)) {
-            return;
-        }
-        ApplicationEnvironmentPreparedEvent environmentPreparedEvent = 
(ApplicationEnvironmentPreparedEvent)event;
-        ConfigurableEnvironment environment = 
environmentPreparedEvent.getEnvironment();
-        
ObjectHolder.INSTANCE.setObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT, 
environment);
-    }
-
-    /**
-     * higher than LoggingApplicationListener
-     *
-     * @return the order
-     */
-    @Override
-    public int getOrder() {
-        return LoggingApplicationListener.DEFAULT_ORDER - 1;
-    }
-}
\ No newline at end of file
diff --git 
a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/java/org/apache/seata/spring/boot/autoconfigure/loader/SeataPropertiesLoader.java
 
b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/java/org/apache/seata/spring/boot/autoconfigure/loader/SeataPropertiesLoader.java
index 05931662ee..77d27827c0 100644
--- 
a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/java/org/apache/seata/spring/boot/autoconfigure/loader/SeataPropertiesLoader.java
+++ 
b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/java/org/apache/seata/spring/boot/autoconfigure/loader/SeataPropertiesLoader.java
@@ -16,6 +16,7 @@
  */
 package org.apache.seata.spring.boot.autoconfigure.loader;
 
+import org.apache.seata.common.holder.ObjectHolder;
 import org.apache.seata.common.util.CollectionUtils;
 import org.apache.seata.common.util.StringUtils;
 import org.apache.seata.config.ConfigurationFactory;
@@ -43,6 +44,7 @@ import static 
org.apache.seata.common.ConfigurationKeys.SEATA_FILE_PREFIX_ROOT_C
 import static org.apache.seata.common.ConfigurationKeys.SERVER_PREFIX;
 import static org.apache.seata.common.ConfigurationKeys.STORE_PREFIX;
 import static org.apache.seata.common.ConfigurationKeys.TRANSPORT_PREFIX;
+import static 
org.apache.seata.common.Constants.OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT;
 
 @Order(Ordered.HIGHEST_PRECEDENCE)
 public class SeataPropertiesLoader implements 
ApplicationContextInitializer<ConfigurableApplicationContext> {
@@ -53,6 +55,10 @@ public class SeataPropertiesLoader implements 
ApplicationContextInitializer<Conf
     @Override
     public void initialize(ConfigurableApplicationContext applicationContext) {
         ConfigurableEnvironment environment = 
applicationContext.getEnvironment();
+        if 
(ObjectHolder.INSTANCE.getObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT) == 
null) {
+            
ObjectHolder.INSTANCE.setObject(OBJECT_KEY_SPRING_CONFIGURABLE_ENVIRONMENT,
+                    applicationContext.getEnvironment());
+        }
         FileConfiguration configuration = 
ConfigurationFactory.getOriginFileInstanceRegistry();
         FileConfig fileConfig = configuration.getFileConfig();
         Map<String, Object> configs = fileConfig.getAllConfig();
diff --git 
a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/resources/META-INF/spring.factories
 
b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/resources/META-INF/spring.factories
index 27e069aa2e..5613c77fce 100644
--- 
a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/resources/META-INF/spring.factories
+++ 
b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/main/resources/META-INF/spring.factories
@@ -24,6 +24,3 @@ 
org.apache.seata.spring.boot.autoconfigure.SeataCoreEnvironmentPostProcessor
 
 org.springframework.context.ApplicationContextInitializer=\
 org.apache.seata.spring.boot.autoconfigure.loader.SeataPropertiesLoader
-
-org.springframework.context.ApplicationListener=\
-org.apache.seata.spring.boot.autoconfigure.listener.SeataApplicationListener
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to