Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize: get real-time configuration according to Environment under file #6245

Merged
merged 4 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6227](https://github.com/apache/incubator-seata/pull/6227)] validate that the primary key is free of illegal characters
- [[#6004](https://github.com/apache/incubator-seata/pull/6004)] optimize RM TM startup connect server fail fast
- [[#6243](https://github.com/apache/incubator-seata/pull/6243)] optimize links in the console header
- [[#6245](https://github.com/apache/incubator-seata/pull/6245)] in file mode, the configuration in the application takes effect, when the spring configuration in the configuration center is changed
- [[#6247](https://github.com/apache/incubator-seata/pull/6247)] optimize asf.yml

### security:
Expand Down
2 changes: 2 additions & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
- [[#6227](https://github.com/apache/incubator-seata/pull/6227)] 校验pk中不含逗号
- [[#6004](https://github.com/apache/incubator-seata/pull/6004)] 优化RM,TM连接server快速失败
- [[#6243](https://github.com/apache/incubator-seata/pull/6243)] 优化控制台页眉中的链接
- [[#6245](https://github.com/apache/incubator-seata/pull/6245)] file模式下,在配置中心的spring配置改变时,使应用程序中的配置生效
- [[#6247](https://github.com/apache/incubator-seata/pull/6247)] 优化 asf.yml 配置


### security:
- [[#6069](https://github.com/apache/incubator-seata/pull/6069)] 升级Guava依赖版本,修复安全漏洞
- [[#6144](https://github.com/apache/incubator-seata/pull/6144)] 升级Nacos依赖版本至1.4.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,29 @@
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;

import static io.seata.common.Constants.OBJECT_KEY_SPRING_APPLICATION_CONTEXT;

/**
* The type spring application context provider
*/
public class SpringApplicationContextProvider implements ApplicationContextAware {
public class SpringApplicationContextProvider implements ApplicationContextAware, ApplicationListener<ContextClosedEvent> {

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
System.setProperty("file.listener.enabled", "false");
ObjectHolder.INSTANCE.setObject(OBJECT_KEY_SPRING_APPLICATION_CONTEXT, applicationContext);
}

/**
* Handle an application event.
*
* @param event the event to respond to
*/
@Override
public void onApplicationEvent(ContextClosedEvent event) {
// end the file listener as soon as possible in file config mode
System.setProperty("file.listener.enabled", "false");
}
}
Loading