shikeyin
2024-01-11 65da8373531677b1c37a98f53eaa30c892f35e5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.iplatform.core.config;
 
import com.iplatform.core.BeanContextAware;
import com.iplatform.core.PlatformConfiguration;
import com.walker.infrastructure.ServerId;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
@Configuration
public class BasicConfig extends PlatformConfiguration {
 
    /**
     * 平台集群模式,配置核心参数。目前只有主机服务ID。
     * @return
     * @date 2023-09-29
     */
    @Bean
    public LoadBalanceProperties loadBalanceProperties(){
        return new LoadBalanceProperties();
    }
 
    @Bean
    public BeanContextAware beanContextAware(ApplicationContext applicationContext, LoadBalanceProperties loadBalanceProperties){
        // 2023-09-29 启动之前先设置负载模式,相关参数
        ServerId.setId(loadBalanceProperties.getServerId());
 
        BeanContextAware beanContextAware = new BeanContextAware();
        beanContextAware.setApplicationContext(applicationContext);
        return beanContextAware;
    }
}