diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index a2ea0b0b4a7..2486264a895 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 0c4892049b1..003a9beca63 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 b347490a1a4..00000000000 --- 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 05931662eee..77d27827c0b 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.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 { @@ -53,6 +55,10 @@ public class SeataPropertiesLoader implements ApplicationContextInitializer 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 27e069aa2ef..5613c77fce1 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