Search in sources :

Example 1 with PropertySourcesPropertyResolver

use of cn.taketoday.core.env.PropertySourcesPropertyResolver in project today-infrastructure by TAKETODAY.

the class ConfigurationPropertySourcesTests method attachShouldAddAdapterAtBeginning.

@Test
void attachShouldAddAdapterAtBeginning() {
    ConfigurableEnvironment environment = new StandardEnvironment();
    PropertySources sources = environment.getPropertySources();
    sources.addLast(new SystemEnvironmentPropertySource("system", Collections.singletonMap("SERVER_PORT", "1234")));
    sources.addLast(new MapPropertySource("config", Collections.singletonMap("server.port", "4568")));
    int size = sources.size();
    ConfigurationPropertySources.attach(environment);
    assertThat(sources.size()).isEqualTo(size + 1);
    PropertyResolver resolver = new PropertySourcesPropertyResolver(sources);
    assertThat(resolver.getProperty("server.port")).isEqualTo("1234");
}
Also used : PropertySourcesPropertyResolver(cn.taketoday.core.env.PropertySourcesPropertyResolver) SystemEnvironmentPropertySource(cn.taketoday.core.env.SystemEnvironmentPropertySource) PropertySources(cn.taketoday.core.env.PropertySources) ConfigurableEnvironment(cn.taketoday.core.env.ConfigurableEnvironment) MapPropertySource(cn.taketoday.core.env.MapPropertySource) PropertySourcesPropertyResolver(cn.taketoday.core.env.PropertySourcesPropertyResolver) PropertyResolver(cn.taketoday.core.env.PropertyResolver) StandardEnvironment(cn.taketoday.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 2 with PropertySourcesPropertyResolver

use of cn.taketoday.core.env.PropertySourcesPropertyResolver in project today-infrastructure by TAKETODAY.

the class ResourceBanner method getTitleResolver.

private PropertyResolver getTitleResolver(Class<?> sourceClass) {
    PropertySources sources = new PropertySources();
    String applicationTitle = getApplicationTitle(sourceClass);
    Map<String, Object> titleMap = Collections.singletonMap("application.title", (applicationTitle != null) ? applicationTitle : "");
    sources.addFirst(new MapPropertySource("title", titleMap));
    return new PropertySourcesPropertyResolver(sources);
}
Also used : PropertySourcesPropertyResolver(cn.taketoday.core.env.PropertySourcesPropertyResolver) PropertySources(cn.taketoday.core.env.PropertySources) MapPropertySource(cn.taketoday.core.env.MapPropertySource)

Example 3 with PropertySourcesPropertyResolver

use of cn.taketoday.core.env.PropertySourcesPropertyResolver in project today-infrastructure by TAKETODAY.

the class ResourceBanner method getAnsiResolver.

private PropertyResolver getAnsiResolver() {
    PropertySources sources = new PropertySources();
    sources.addFirst(new AnsiPropertySource("ansi", true));
    return new PropertySourcesPropertyResolver(sources);
}
Also used : PropertySourcesPropertyResolver(cn.taketoday.core.env.PropertySourcesPropertyResolver) PropertySources(cn.taketoday.core.env.PropertySources) AnsiPropertySource(cn.taketoday.framework.ansi.AnsiPropertySource)

Example 4 with PropertySourcesPropertyResolver

use of cn.taketoday.core.env.PropertySourcesPropertyResolver in project today-framework by TAKETODAY.

the class ResourceBanner method getVersionResolver.

private PropertyResolver getVersionResolver(Class<?> sourceClass) {
    PropertySources propertySources = new PropertySources();
    propertySources.addLast(new MapPropertySource("version", getVersionsMap(sourceClass)));
    return new PropertySourcesPropertyResolver(propertySources);
}
Also used : PropertySourcesPropertyResolver(cn.taketoday.core.env.PropertySourcesPropertyResolver) PropertySources(cn.taketoday.core.env.PropertySources) MapPropertySource(cn.taketoday.core.env.MapPropertySource)

Example 5 with PropertySourcesPropertyResolver

use of cn.taketoday.core.env.PropertySourcesPropertyResolver in project today-framework by TAKETODAY.

the class ResourceBanner method getAnsiResolver.

private PropertyResolver getAnsiResolver() {
    PropertySources sources = new PropertySources();
    sources.addFirst(new AnsiPropertySource("ansi", true));
    return new PropertySourcesPropertyResolver(sources);
}
Also used : PropertySourcesPropertyResolver(cn.taketoday.core.env.PropertySourcesPropertyResolver) PropertySources(cn.taketoday.core.env.PropertySources) AnsiPropertySource(cn.taketoday.framework.ansi.AnsiPropertySource)

Aggregations

PropertySources (cn.taketoday.core.env.PropertySources)8 PropertySourcesPropertyResolver (cn.taketoday.core.env.PropertySourcesPropertyResolver)8 MapPropertySource (cn.taketoday.core.env.MapPropertySource)6 ConfigurableEnvironment (cn.taketoday.core.env.ConfigurableEnvironment)2 PropertyResolver (cn.taketoday.core.env.PropertyResolver)2 StandardEnvironment (cn.taketoday.core.env.StandardEnvironment)2 SystemEnvironmentPropertySource (cn.taketoday.core.env.SystemEnvironmentPropertySource)2 AnsiPropertySource (cn.taketoday.framework.ansi.AnsiPropertySource)2 Test (org.junit.jupiter.api.Test)2