List of usage examples for org.springframework.boot.context.properties.bind Binder bind
public <T> BindResult<T> bind(ConfigurationPropertyName name, Bindable<T> target)
From source file:io.spring.initializr.metadata.InitializrMetadataBuilderTests.java
private static InitializrProperties load(Resource resource) { ConfigurationPropertySource source = new MapConfigurationPropertySource(loadProperties(resource)); Binder binder = new Binder(source); return binder.bind("initializr", InitializrProperties.class).get(); }
From source file:io.spring.initializr.web.autoconfigure.InitializrAutoConfiguration.java
@Bean @ConditionalOnMissingBean/*from w w w.j a v a 2 s . c om*/ public TemplateRenderer templateRenderer(Environment environment) { Binder binder = Binder.get(environment); boolean cache = binder.bind("spring.mustache.cache", Boolean.class).orElse(true); TemplateRenderer templateRenderer = new TemplateRenderer(); templateRenderer.setCache(cache); return templateRenderer; }
From source file:org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.java
private List<String> getExcludeAutoConfigurationsProperty() { if (getEnvironment() instanceof ConfigurableEnvironment) { Binder binder = Binder.get(getEnvironment()); return binder.bind(PROPERTY_NAME_AUTOCONFIGURE_EXCLUDE, String[].class).map(Arrays::asList) .orElse(Collections.emptyList()); }//from w ww. j a v a 2 s .c o m String[] excludes = getEnvironment().getProperty(PROPERTY_NAME_AUTOCONFIGURE_EXCLUDE, String[].class); return (excludes != null) ? Arrays.asList(excludes) : Collections.emptyList(); }
From source file:org.springframework.boot.context.logging.LoggingApplicationListener.java
protected void setLogLevels(LoggingSystem system, Environment environment) { if (!(environment instanceof ConfigurableEnvironment)) { return;//w w w. j a va2s . co m } Binder binder = Binder.get(environment); Map<String, String[]> groups = getGroups(); binder.bind("logging.group", STRING_STRINGS_MAP.withExistingValue(groups)); Map<String, String> levels = binder.bind("logging.level", STRING_STRING_MAP) .orElseGet(Collections::emptyMap); levels.forEach((name, level) -> { String[] groupedNames = groups.get(name); if (ObjectUtils.isEmpty(groupedNames)) { setLogLevel(system, name, level); } else { setLogLevel(system, groupedNames, level); } }); }
From source file:org.springframework.boot.jdbc.DataSourceBuilder.java
private void bind(DataSource result) { ConfigurationPropertySource source = new MapConfigurationPropertySource(this.properties); ConfigurationPropertyNameAliases aliases = new ConfigurationPropertyNameAliases(); aliases.addAliases("url", "jdbc-url"); aliases.addAliases("username", "user"); Binder binder = new Binder(source.withAliases(aliases)); binder.bind(ConfigurationPropertyName.EMPTY, Bindable.ofInstance(result)); }