| | |
| | | package com.product; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.aspose.slides.p2cbca448.env; |
| | | import com.product.common.properties.PropertiesLoader; |
| | | import com.product.core.config.Global; |
| | | import com.product.core.spring.context.SpringContextHolder; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.cloud.context.environment.EnvironmentChangeEvent; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.env.Environment; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * @Author cheng |
| | | * @Date 2024/12/19 17:22 |
| | | * @Desc nacos 配置监听器 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class AuthNacosConfigListener implements ApplicationListener<EnvironmentChangeEvent> { |
| | | |
| | | @Resource |
| | | PropertiesLoader propertiesLoader; |
| | | |
| | | @Override |
| | | public void onApplicationEvent(EnvironmentChangeEvent environmentChangeEvent) { |
| | | log.info("监听到权限配置变更事件,刷新权限配置,系统变化事件:{}", JSONObject.toJSONString(environmentChangeEvent)); |
| | | |
| | | Set<String> keys = environmentChangeEvent.getKeys(); |
| | | for (String key : keys) { |
| | | log.info("监听到权限配置变更事件,刷新权限配置,系统变化事件:{}", key); |
| | | Object property = propertiesLoader.getProperty(key, ""); |
| | | Global.setPropertyValue(key, property); |
| | | } |
| | | } |
| | | } |
| | | //package com.product; |
| | | // |
| | | //import com.alibaba.fastjson.JSONObject; |
| | | //import com.aspose.slides.p2cbca448.env; |
| | | //import com.product.common.properties.PropertiesLoader; |
| | | //import com.product.core.config.Global; |
| | | //import com.product.core.spring.context.SpringContextHolder; |
| | | //import lombok.extern.slf4j.Slf4j; |
| | | //import org.springframework.cloud.context.environment.EnvironmentChangeEvent; |
| | | //import org.springframework.context.ApplicationListener; |
| | | //import org.springframework.context.annotation.Configuration; |
| | | //import org.springframework.core.env.Environment; |
| | | //import org.springframework.stereotype.Component; |
| | | // |
| | | //import javax.annotation.Resource; |
| | | //import java.util.Set; |
| | | // |
| | | ///** |
| | | // * @Author cheng |
| | | // * @Date 2024/12/19 17:22 |
| | | // * @Desc nacos 配置监听器 |
| | | // */ |
| | | //@Slf4j |
| | | //@Component |
| | | //public class AuthNacosConfigListener implements ApplicationListener<EnvironmentChangeEvent> { |
| | | // |
| | | // @Resource |
| | | // PropertiesLoader propertiesLoader; |
| | | // |
| | | // @Override |
| | | // public void onApplicationEvent(EnvironmentChangeEvent environmentChangeEvent) { |
| | | // log.info("监听到权限配置变更事件,刷新权限配置,系统变化事件:{}", JSONObject.toJSONString(environmentChangeEvent)); |
| | | // |
| | | // Set<String> keys = environmentChangeEvent.getKeys(); |
| | | // for (String key : keys) { |
| | | // log.info("监听到权限配置变更事件,刷新权限配置,系统变化事件:{}", key); |
| | | // Object property = propertiesLoader.getProperty(key, ""); |
| | | // Global.setPropertyValue(key, property); |
| | | // } |
| | | // } |
| | | //} |