本文整理汇总了Java中org.springframework.core.env.MutablePropertySources.addFirst方法的典型用法代码示例。如果您正苦于以下问题:Java MutablePropertySources.addFirst方法的具体用法?Java MutablePropertySources.addFirst怎么用?Java MutablePropertySources.addFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.core.env.MutablePropertySources
的用法示例。
在下文中一共展示了MutablePropertySources.addFirst方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: customizePropertySources
import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
@Override
protected void customizePropertySources(MutablePropertySources propertySources) {
super.customizePropertySources(propertySources);
propertySources.addFirst(new PropertySource<Object>("TestAppServerProperty"){
@Override
public Object getProperty(String name) {
if(name.equals("server.port")){
return String.valueOf(port);
}
return null;
}
});
}
示例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
示例4: getPropertyResolver
import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
private PropertyResolver getPropertyResolver(String file, String path) {
Map<String, Object> properties = new LinkedHashMap<String, Object>();
properties.put("logging.file", file);
properties.put("logging.path", path);
PropertySource<?> propertySource = new MapPropertySource("properties",
properties);
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(propertySource);
return new PropertySourcesPropertyResolver(propertySources);
}
示例5: addJsonPropertySource
import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
private void addJsonPropertySource(ConfigurableEnvironment environment,
PropertySource<?> source) {
MutablePropertySources sources = environment.getPropertySources();
String name = findPropertySource(sources);
if (sources.contains(name)) {
sources.addBefore(name, source);
}
else {
sources.addFirst(source);
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:SpringApplicationJsonEnvironmentPostProcessor.java
示例6: getTitleResolver
import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
private PropertyResolver getTitleResolver(Class<?> sourceClass) {
MutablePropertySources sources = new MutablePropertySources();
String applicationTitle = getApplicationTitle(sourceClass);
Map<String, Object> titleMap = Collections.<String, Object>singletonMap(
"application.title", (applicationTitle == null ? "" : applicationTitle));
sources.addFirst(new MapPropertySource("title", titleMap));
return new PropertySourcesPropertyResolver(sources);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:ResourceBanner.java
示例7: getOrAdd
import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static Map<String, Object> getOrAdd(MutablePropertySources sources,
String name) {
if (sources.contains(name)) {
return (Map<String, Object>) sources.get(name).getSource();
}
Map<String, Object> map = new HashMap<String, Object>();
sources.addFirst(new MapPropertySource(name, map));
return map;
}
示例8: testBindFromPropertySource
import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
@Test
public void testBindFromPropertySource() throws Exception {
this.targetName = "foo";
setupFactory();
MutablePropertySources sources = new MutablePropertySources();
sources.addFirst(new MapPropertySource("map",
Collections.singletonMap("foo.map.name", (Object) "blah")));
this.factory.setPropertySources(sources);
this.factory.afterPropertiesSet();
Foo foo = this.factory.getObject();
assertThat(foo.map.get("name")).isEqualTo("blah");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:PropertiesConfigurationFactoryMapTests.java
示例9: testBindFromCompositePropertySource
import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
@Test
public void testBindFromCompositePropertySource() throws Exception {
this.targetName = "foo";
setupFactory();
MutablePropertySources sources = new MutablePropertySources();
CompositePropertySource composite = new CompositePropertySource("composite");
composite.addPropertySource(new MapPropertySource("map",
Collections.singletonMap("foo.map.name", (Object) "blah")));
sources.addFirst(composite);
this.factory.setPropertySources(sources);
this.factory.afterPropertiesSet();
Foo foo = this.factory.getObject();
assertThat(foo.map.get("name")).isEqualTo("blah");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:PropertiesConfigurationFactoryMapTests.java
示例10: systemEnvironmentBindingFailuresAreIgnored
import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
@Test
public void systemEnvironmentBindingFailuresAreIgnored() throws Exception {
setupFactory();
MutablePropertySources propertySources = new MutablePropertySources();
MockPropertySource propertySource = new MockPropertySource(
StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME);
propertySource.setProperty("doesNotExist", "foo");
propertySource.setProperty("name", "bar");
propertySources.addFirst(propertySource);
this.factory.setPropertySources(propertySources);
this.factory.setIgnoreUnknownFields(false);
this.factory.afterPropertiesSet();
Foo foo = this.factory.getObject();
assertThat(foo.name).isEqualTo("bar");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:16,代码来源:PropertiesConfigurationFactoryTests.java
示例11: systemPropertyBindingFailuresAreIgnored
import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
@Test
public void systemPropertyBindingFailuresAreIgnored() throws Exception {
setupFactory();
MutablePropertySources propertySources = new MutablePropertySources();
MockPropertySource propertySource = new MockPropertySource(
StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
propertySource.setProperty("doesNotExist", "foo");
propertySource.setProperty("name", "bar");
propertySources.addFirst(propertySource);
this.factory.setPropertySources(propertySources);
this.factory.setIgnoreUnknownFields(false);
this.factory.afterPropertiesSet();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:PropertiesConfigurationFactoryTests.java
示例12: propertySourcesPlaceholderConfigurer
import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
/**
* Without this bean declared, the @Value placeholder above will not be resolved properly.
*
* Using @PropertySource by itself will not work; nor will it work if this method is not declared static.
*
* See {@link org.springframework.context.annotation.PropertySource} JavaDoc for more info.
*/
@Bean
static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() throws IOException {
PropertySourcesPlaceholderConfigurer result = new PropertySourcesPlaceholderConfigurer();
MutablePropertySources sources = new MutablePropertySources();
sources.addFirst(new ResourcePropertySource("classpath:app.properties"));
result.setPropertySources(sources);
result.setIgnoreUnresolvablePlaceholders(false);
return result;
}
示例13: getAnsiResolver
import org.springframework.core.env.MutablePropertySources; //导入方法依赖的package包/类
private PropertyResolver getAnsiResolver() {
MutablePropertySources sources = new MutablePropertySources();
sources.addFirst(new AnsiPropertySource("ansi", true));
return new PropertySourcesPropertyResolver(sources);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:6,代码来源:ResourceBanner.java