Search in sources :

Example 6 with ConfigurationPropertySource

use of org.springframework.boot.context.properties.source.ConfigurationPropertySource in project spring-boot by spring-projects.

the class SpringBootTestContextBootstrapper method getWebApplicationType.

private WebApplicationType getWebApplicationType(MergedContextConfiguration configuration) {
    ConfigurationPropertySource source = new MapConfigurationPropertySource(TestPropertySourceUtils.convertInlinedPropertiesToMap(configuration.getPropertySourceProperties()));
    Binder binder = new Binder(source);
    return binder.bind("spring.main.web-application-type", Bindable.of(WebApplicationType.class)).orElseGet(this::deduceWebApplicationType);
}
Also used : Binder(org.springframework.boot.context.properties.bind.Binder) ConfigurationPropertySource(org.springframework.boot.context.properties.source.ConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource)

Example 7 with ConfigurationPropertySource

use of org.springframework.boot.context.properties.source.ConfigurationPropertySource in project spring-boot by spring-projects.

the class ServerPropertiesTests method bind.

private void bind(Map<String, String> map) {
    ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
    new Binder(source).bind("server", Bindable.ofInstance(this.properties));
}
Also used : Binder(org.springframework.boot.context.properties.bind.Binder) ConfigurationPropertySource(org.springframework.boot.context.properties.source.ConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource)

Example 8 with ConfigurationPropertySource

use of org.springframework.boot.context.properties.source.ConfigurationPropertySource in project spring-boot by spring-projects.

the class Saml2RelyingPartyPropertiesTests method bind.

private void bind(Map<String, String> map) {
    ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
    new Binder(source).bind("spring.security.saml2.relyingparty", Bindable.ofInstance(this.properties));
}
Also used : Binder(org.springframework.boot.context.properties.bind.Binder) ConfigurationPropertySource(org.springframework.boot.context.properties.source.ConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource)

Example 9 with ConfigurationPropertySource

use of org.springframework.boot.context.properties.source.ConfigurationPropertySource in project spring-boot by spring-projects.

the class ConfigDataEnvironment method getIncludedProfiles.

private Collection<? extends String> getIncludedProfiles(ConfigDataEnvironmentContributors contributors, ConfigDataActivationContext activationContext) {
    PlaceholdersResolver placeholdersResolver = new ConfigDataEnvironmentContributorPlaceholdersResolver(contributors, activationContext, null, true);
    Set<String> result = new LinkedHashSet<>();
    for (ConfigDataEnvironmentContributor contributor : contributors) {
        ConfigurationPropertySource source = contributor.getConfigurationPropertySource();
        if (source != null && !contributor.hasConfigDataOption(ConfigData.Option.IGNORE_PROFILES)) {
            Binder binder = new Binder(Collections.singleton(source), placeholdersResolver);
            binder.bind(Profiles.INCLUDE_PROFILES, STRING_LIST).ifBound((includes) -> {
                if (!contributor.isActive(activationContext)) {
                    InactiveConfigDataAccessException.throwIfPropertyFound(contributor, Profiles.INCLUDE_PROFILES);
                    InactiveConfigDataAccessException.throwIfPropertyFound(contributor, Profiles.INCLUDE_PROFILES.append("[0]"));
                }
                result.addAll(includes);
            });
        }
    }
    return result;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Binder(org.springframework.boot.context.properties.bind.Binder) PlaceholdersResolver(org.springframework.boot.context.properties.bind.PlaceholdersResolver) ConfigurationPropertySource(org.springframework.boot.context.properties.source.ConfigurationPropertySource)

Example 10 with ConfigurationPropertySource

use of org.springframework.boot.context.properties.source.ConfigurationPropertySource in project spring-boot by spring-projects.

the class ServletWebServerFactoryCustomizerTests method bindProperties.

private void bindProperties(Map<String, String> map) {
    ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
    new Binder(source).bind("server", Bindable.ofInstance(this.properties));
}
Also used : Binder(org.springframework.boot.context.properties.bind.Binder) ConfigurationPropertySource(org.springframework.boot.context.properties.source.ConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource) MapConfigurationPropertySource(org.springframework.boot.context.properties.source.MapConfigurationPropertySource)

Aggregations

ConfigurationPropertySource (org.springframework.boot.context.properties.source.ConfigurationPropertySource)24 Binder (org.springframework.boot.context.properties.bind.Binder)17 MapConfigurationPropertySource (org.springframework.boot.context.properties.source.MapConfigurationPropertySource)11 Test (org.junit.jupiter.api.Test)6 ArrayList (java.util.ArrayList)4 BindHandler (org.springframework.boot.context.properties.bind.BindHandler)4 Bindable (org.springframework.boot.context.properties.bind.Bindable)4 HashMap (java.util.HashMap)3 PlaceholdersResolver (org.springframework.boot.context.properties.bind.PlaceholdersResolver)3 MapPropertySource (org.springframework.core.env.MapPropertySource)3 PropertySource (org.springframework.core.env.PropertySource)3 ConfigurationBeanBinder (com.alibaba.spring.context.config.ConfigurationBeanBinder)2 List (java.util.List)2 Map (java.util.Map)2 DubboConfigBinder (org.apache.dubbo.config.spring.context.properties.DubboConfigBinder)2 Test (org.junit.Test)2 PropertySourcesPlaceholdersResolver (org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver)2 IgnoreErrorsBindHandler (org.springframework.boot.context.properties.bind.handler.IgnoreErrorsBindHandler)2 NoUnboundElementsBindHandler (org.springframework.boot.context.properties.bind.handler.NoUnboundElementsBindHandler)2 ConfigurationProperty (org.springframework.boot.context.properties.source.ConfigurationProperty)2