Search in sources :

Example 1 with DefaultConfigFileMetadata

use of com.tencent.polaris.configuration.client.internal.DefaultConfigFileMetadata in project spring-cloud-tencent by Tencent.

the class PolarisConfigFileLocator method getInternalConfigFiles.

private List<ConfigFileMetadata> getInternalConfigFiles() {
    String namespace = polarisContextProperties.getNamespace();
    String serviceName = polarisContextProperties.getService();
    if (StringUtils.isEmpty(serviceName)) {
        serviceName = environment.getProperty("spring.application.name");
    }
    List<ConfigFileMetadata> internalConfigFiles = new LinkedList<>();
    // priority: application-${profile} > application > boostrap-${profile} > boostrap
    String[] activeProfiles = environment.getActiveProfiles();
    for (String activeProfile : activeProfiles) {
        if (StringUtils.isEmpty(activeProfile)) {
            continue;
        }
        internalConfigFiles.add(new DefaultConfigFileMetadata(namespace, serviceName, "application-" + activeProfile + ".properties"));
        internalConfigFiles.add(new DefaultConfigFileMetadata(namespace, serviceName, "application-" + activeProfile + ".yml"));
    }
    internalConfigFiles.add(new DefaultConfigFileMetadata(namespace, serviceName, "application.properties"));
    internalConfigFiles.add(new DefaultConfigFileMetadata(namespace, serviceName, "application.yml"));
    for (String activeProfile : activeProfiles) {
        if (StringUtils.isEmpty(activeProfile)) {
            continue;
        }
        internalConfigFiles.add(new DefaultConfigFileMetadata(namespace, serviceName, "bootstrap-" + activeProfile + ".properties"));
        internalConfigFiles.add(new DefaultConfigFileMetadata(namespace, serviceName, "bootstrap-" + activeProfile + ".yml"));
    }
    internalConfigFiles.add(new DefaultConfigFileMetadata(namespace, serviceName, "bootstrap.properties"));
    internalConfigFiles.add(new DefaultConfigFileMetadata(namespace, serviceName, "bootstrap.yml"));
    return internalConfigFiles;
}
Also used : DefaultConfigFileMetadata(com.tencent.polaris.configuration.client.internal.DefaultConfigFileMetadata) LinkedList(java.util.LinkedList) DefaultConfigFileMetadata(com.tencent.polaris.configuration.client.internal.DefaultConfigFileMetadata) ConfigFileMetadata(com.tencent.polaris.configuration.api.core.ConfigFileMetadata)

Aggregations

ConfigFileMetadata (com.tencent.polaris.configuration.api.core.ConfigFileMetadata)1 DefaultConfigFileMetadata (com.tencent.polaris.configuration.client.internal.DefaultConfigFileMetadata)1 LinkedList (java.util.LinkedList)1