当前位置: 首页>>代码示例>>Java>>正文


Java MutablePropertySources.addAfter方法代码示例

本文整理汇总了Java中org.springframework.core.env.MutablePropertySources.addAfter方法的典型用法代码示例。如果您正苦于以下问题:Java MutablePropertySources.addAfter方法的具体用法?Java MutablePropertySources.addAfter怎么用?Java MutablePropertySources.addAfter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.core.env.MutablePropertySources的用法示例。


在下文中一共展示了MutablePropertySources.addAfter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addKeyVaultPropertySource

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
public void addKeyVaultPropertySource() {
    final String clientId = getProperty(environment, Constants.AZURE_CLIENTID);
    final String clientKey = getProperty(environment, Constants.AZURE_CLIENTKEY);
    final String vaultUri = getProperty(environment, Constants.AZURE_KEYVAULT_VAULT_URI);

    final long timeAcquiringTimeoutInSeconds = environment.getProperty(
            Constants.AZURE_TOKEN_ACQUIRE_TIMEOUT_IN_SECONDS, Long.class, 60L);

    final KeyVaultClient kvClient = new KeyVaultClient(
            new AzureKeyVaultCredential(clientId, clientKey, timeAcquiringTimeoutInSeconds));

    try {
        final MutablePropertySources sources = environment.getPropertySources();
        final KeyVaultOperation kvOperation = new KeyVaultOperation(kvClient, vaultUri);

        if (sources.contains(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)) {
            sources.addAfter(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME,
                    new KeyVaultPropertySource(kvOperation));
        } else {
            sources.addFirst(new KeyVaultPropertySource(kvOperation));
        }

    } catch (Exception ex) {
        throw new IllegalStateException("Failed to configure KeyVault property source", ex);
    }
}
 
开发者ID:Microsoft,项目名称:azure-spring-boot,代码行数:27,代码来源:KeyVaultEnvironmentPostProcessorHelper.java

示例2: finishAndRelocate

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
public static void finishAndRelocate(MutablePropertySources propertySources) {
	String name = APPLICATION_CONFIGURATION_PROPERTY_SOURCE_NAME;
	ConfigurationPropertySources removed = (ConfigurationPropertySources) propertySources
			.get(name);
	if (removed != null) {
		for (PropertySource<?> propertySource : removed.sources) {
			if (propertySource instanceof EnumerableCompositePropertySource) {
				EnumerableCompositePropertySource composite = (EnumerableCompositePropertySource) propertySource;
				for (PropertySource<?> nested : composite.getSource()) {
					propertySources.addAfter(name, nested);
					name = nested.getName();
				}
			}
			else {
				propertySources.addAfter(name, propertySource);
			}
		}
		propertySources.remove(APPLICATION_CONFIGURATION_PROPERTY_SOURCE_NAME);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:21,代码来源:ConfigFileApplicationListener.java

示例3: postProcessEnvironment

import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
		SpringApplication application) {
	if (CloudPlatform.CLOUD_FOUNDRY.isActive(environment)) {
		Properties properties = new Properties();
		addWithPrefix(properties, getPropertiesFromApplication(environment),
				"vcap.application.");
		addWithPrefix(properties, getPropertiesFromServices(environment),
				"vcap.services.");
		MutablePropertySources propertySources = environment.getPropertySources();
		if (propertySources.contains(
				CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME)) {
			propertySources.addAfter(
					CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME,
					new PropertiesPropertySource("vcap", properties));
		}
		else {
			propertySources
					.addFirst(new PropertiesPropertySource("vcap", properties));
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:23,代码来源:CloudFoundryVcapEnvironmentPostProcessor.java


注:本文中的org.springframework.core.env.MutablePropertySources.addAfter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。