package com.elab.spring.config;

import com.elab.redis.componts.config.scope.RedisConfigRefreshCallback;
import com.elab.spring.componts.config.ConfigRefresh;
import com.elab.spring.componts.config.RedisConfigRefresh;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 自动配置
 *
 * @author liukaixiong
 * @Email liukx@elab-plus.com
 */
@Configuration
public class ConfigRefreshAutoConfig {

    @Bean
    @ConditionalOnBean(value = {RedisConfigRefreshCallback.class})
    @ConditionalOnProperty(prefix = "elab.spring", value = "config-refresh", havingValue = "REDIS")
    public ConfigRefresh configRefresh() {
        return new RedisConfigRefresh();
    }

}
