Refine search
protected void setLogLevels(LoggingSystem system, Environment environment) { if (!(environment instanceof ConfigurableEnvironment)) { return; } 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); } }); }
@Override public <C extends AbstractConfig> void bind(String prefix, C dubboConfig) { Iterable<PropertySource<?>> propertySources = getPropertySources(); // Converts ConfigurationPropertySources Iterable<ConfigurationPropertySource> configurationPropertySources = from(propertySources); // Wrap Bindable from DubboConfig instance Bindable<C> bindable = Bindable.ofInstance(dubboConfig); Binder binder = new Binder(configurationPropertySources, new PropertySourcesPlaceholdersResolver(propertySources)); // Get BindHandler BindHandler bindHandler = getBindHandler(); // Bind binder.bind(prefix, bindable, bindHandler); }
/** * Bind the environment to the {@link SpringApplication}. * @param environment the environment to bind */ protected void bindToSpringApplication(ConfigurableEnvironment environment) { try { Binder.get(environment).bind("spring.main", Bindable.ofInstance(this)); } catch (Exception ex) { throw new IllegalStateException("Cannot bind to SpringApplication", ex); } }
private <P extends EnvironmentRepositoryProperties> P bindProperties( int index, Class<P> propertiesClass, Environment environment) { Binder binder = Binder.get(environment); String environmentConfigurationPropertyName = String.format("spring.cloud.config.server.composite[%d]", index); P properties = binder.bind(environmentConfigurationPropertyName, propertiesClass).orElseCreate(propertiesClass); properties.setOrder(index + 1); return properties; } }
/** * Returns list of values of the `type` field from the `spring.cloud.config.server.composite` collection. */ public static List<String> getCompositeTypeList(Environment environment) { return Binder.get(environment) .bind("spring.cloud.config.server", CompositeConfig.class) .get().getComposite().stream() .map(map -> (String)map.get("type")) .collect(Collectors.toList()); }
@Bean @ConditionalOnMissingBean 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; }
/** * Bind the specified target {@link Bindable} using this binder's * {@link ConfigurationPropertySource property sources}. * @param name the configuration property name to bind * @param target the target bindable * @param <T> the bound type * @return the binding result (never {@code null}) * @see #bind(ConfigurationPropertyName, Bindable, BindHandler) */ public <T> BindResult<T> bind(ConfigurationPropertyName name, Bindable<T> target) { return bind(name, target, null); }
return ConditionOutcome.match(message.foundExactly("client-id property")); Binder binder = Binder.get(environment); String prefix = "security.oauth2.resource."; if (binder.bind(prefix + "jwt", STRING_OBJECT_MAP).isBound()) { return ConditionOutcome .match(message.foundExactly("JWT resource configuration")); if (binder.bind(prefix + "jwk", STRING_OBJECT_MAP).isBound()) { return ConditionOutcome .match(message.foundExactly("JWK resource configuration"));
@Override public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) { ConfigurableEnvironment environment = event.getEnvironment(); Binder.get(environment) .bind("spring.output.ansi.enabled", AnsiOutput.Enabled.class) .ifBound(AnsiOutput::setEnabled); AnsiOutput.setConsoleAvailable(environment .getProperty("spring.output.ansi.console-available", Boolean.class)); }
/** * Extract the raw content based on the specified {@link PropertySource}. * @param propertySource the property source to use * @return the raw content */ protected Map<String, Object> extractContent(PropertySource<?> propertySource) { return new Binder(ConfigurationPropertySources.from(propertySource)) .bind("", STRING_OBJECT_MAP).orElseGet(LinkedHashMap::new); }
private List<Document> asDocuments(List<PropertySource<?>> loaded) { if (loaded == null) { return Collections.emptyList(); } return loaded.stream().map((propertySource) -> { Binder binder = new Binder( ConfigurationPropertySources.from(propertySource), this.placeholdersResolver); return new Document(propertySource, binder.bind("spring.profiles", STRING_ARRAY).orElse(null), getProfiles(binder, ACTIVE_PROFILES_PROPERTY), getProfiles(binder, INCLUDE_PROFILES_PROPERTY)); }).collect(Collectors.toList()); }
protected <T> T resolverSetting(Class<T> clazz, MutablePropertySources propertySources) { return new Binder(ConfigurationPropertySources.from(propertySources)) .bind("loc", Bindable.of(clazz)) .orElseThrow(() -> new FatalBeanException("Could not bind properties")); } }
private LocElasticJobProperties resolverJobProperties() { try { return Binder.get(environment) .bind("loc.elasticjob", Bindable.of(LocElasticJobProperties.class)) .orElseThrow( () -> new FatalBeanException("Could not bind DataSourceSettings properties")); } catch (Exception e) { //ignore log.error("Could not bind job properties, error message is {}", e.getMessage(), e); throw new FatalBeanException("Could not bind job properties", e); } }
@Override public NakadiClientsProperties parse(ConfigurableEnvironment environment) { final Iterable<ConfigurationPropertySource> sources = from(environment.getPropertySources()); final Binder binder = new Binder(sources); return binder.bind("fahrschein", NakadiClientsProperties.class) .orElseCreate(NakadiClientsProperties.class); }