All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.antframework.configcenter.spring.ConfigsContexts Maven / Gradle / Ivy

There is a newer version: 1.7.3
Show newest version
/* 
 * 作者:钟勋 (e-mail:[email protected])
 */

/*
 * 修订记录:
 * @author 钟勋 2018-05-02 22:30 创建
 */
package org.antframework.configcenter.spring;

import org.antframework.configcenter.client.Config;
import org.antframework.configcenter.client.ConfigsContext;
import org.antframework.configcenter.spring.boot.ConfigcenterProperties;

import java.util.Objects;

/**
 * 配置上下文操作类
 */
public final class ConfigsContexts {
    // 配置上下文
    private static final ConfigsContext CONFIGS_CONTEXT = new ConfigsContext(
            ConfigcenterProperties.INSTANCE.getRequiredAppId(),
            ConfigcenterProperties.INSTANCE.getRequiredProfileId(),
            ConfigcenterProperties.INSTANCE.getTarget(),
            ConfigcenterProperties.INSTANCE.getServerUrl(),
            Objects.equals(ConfigcenterProperties.INSTANCE.getHome(), Boolean.FALSE.toString()) ? null : ConfigcenterProperties.INSTANCE.getHome());

    /**
     * 获取配置上下文
     */
    public static ConfigsContext getContext() {
        return CONFIGS_CONTEXT;
    }

    /**
     * 获取配置
     *
     * @param appId 被查询配置的应用id
     * @return 配置
     */
    public static Config getConfig(String appId) {
        return CONFIGS_CONTEXT.getConfig(appId);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy