• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Binder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.boot.context.properties.bind.Binder的典型用法代码示例。如果您正苦于以下问题:Java Binder类的具体用法?Java Binder怎么用?Java Binder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Binder类属于org.springframework.boot.context.properties.bind包,在下文中一共展示了Binder类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: reinitializeLoggingSystem

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
private void reinitializeLoggingSystem(ConfigurableEnvironment environment,
		String oldLogConfig, LogFile oldLogFile) {
	Map<String, Object> props = Binder.get(environment)
			.bind("logging", Bindable.mapOf(String.class, Object.class)).orElseGet(Collections::emptyMap);
	if (!props.isEmpty()) {
		String logConfig = environment.resolvePlaceholders("${logging.config:}");
		LogFile logFile = LogFile.get(environment);
		LoggingSystem system = LoggingSystem
				.get(LoggingSystem.class.getClassLoader());
		try {
			ResourceUtils.getURL(logConfig).openStream().close();
			// Three step initialization that accounts for the clean up of the logging
			// context before initialization. Spring Boot doesn't initialize a logging
			// system that hasn't had this sequence applied (since 1.4.1).
			system.cleanUp();
			system.beforeInitialize();
			system.initialize(new LoggingInitializationContext(environment),
					logConfig, logFile);
		}
		catch (Exception ex) {
			PropertySourceBootstrapConfiguration.logger
					.warn("Logging config file location '" + logConfig
							+ "' cannot be opened and will be ignored");
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:27,代码来源:PropertySourceBootstrapConfiguration.java


示例2: getMatchOutcome

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
    AnnotatedTypeMetadata metadata) {
  String prefix = (String) attribute(metadata, "prefix");
  Class<?> value = (Class<?>) attribute(metadata, "value");
  ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment();
  try {
    new Binder(ConfigurationPropertySources.from(environment.getPropertySources()))
        .bind(prefix, Bindable.of(value))
        .orElseThrow(
            () -> new FatalBeanException("Could not bind DataSourceSettings properties"));
    return new ConditionOutcome(true, String.format("Map property [%s] is not empty", prefix));
  } catch (Exception e) {
    //ignore
  }
  return new ConditionOutcome(false, String.format("Map property [%s] is empty", prefix));
}
 
开发者ID:lord-of-code,项目名称:loc-framework,代码行数:18,代码来源:PrefixPropertyCondition.java


示例3: bindProperties

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
private Map<String, String> bindProperties() {
	Map<String, String> target;
	BindResult<Map<String, String>> bindResult = Binder.get(environment).bind("", STRING_STRING_MAP);
	if (bindResult.isBound()) {
		target = bindResult.get();
	}
	else {
		target = new HashMap<>();
	}
	return target;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:12,代码来源:ApplicationMetricsProperties.java


示例4: bindProperties

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
private Map<String, String> bindProperties(String namepace, Environment environment) {
	Map<String, String> target;
	BindResult<Map<String, String>> bindResult = Binder.get(environment).bind(namepace, STRING_STRING_MAP);
	if (bindResult.isBound()) {
		target = bindResult.get();
	}
	else {
		target = new HashMap<>();
	}
	return target;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:12,代码来源:AggregateApplicationBuilder.java


示例5: get

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
@Override
public T get(Object key) {
	if (!this.delegate.containsKey(key) && key instanceof String) {
		T entry = BeanUtils.instantiateClass(entryClass);
		Binder binder = new Binder(ConfigurationPropertySources.get(environment),new PropertySourcesPlaceholdersResolver(environment),this.conversionService);
		binder.bind(defaultsPrefix, Bindable.ofInstance(entry));
		this.delegate.put((String) key, entry);
	}
	return this.delegate.get(key);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:11,代码来源:EnvironmentEntryInitializingTreeMap.java


示例6: put

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
@Override
public T put(String key, T value) {
	// boot 2 call this first
	Binder binder = new Binder(ConfigurationPropertySources.get(environment),new PropertySourcesPlaceholdersResolver(environment),this.conversionService);
	binder.bind(defaultsPrefix, Bindable.ofInstance(value));
	return this.delegate.put(key, value);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:8,代码来源:EnvironmentEntryInitializingTreeMap.java


示例7: getMatchOutcome

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
	Map<String, String> subProperties = Binder.get(context.getEnvironment())
			.bind(ZOOKEEPER_DEPENDENCIES_PROP, STRING_STRING_MAP).orElseGet(Collections::emptyMap);
	if (!subProperties.isEmpty()) {
		return ConditionOutcome.match("Dependencies are defined in configuration");
	}
	Boolean dependenciesEnabled = context.getEnvironment()
			.getProperty("spring.cloud.zookeeper.dependency.enabled", Boolean.class, false);
	if (dependenciesEnabled) {
		return ConditionOutcome.match("Dependencies are not defined in configuration, but switch is turned on");
	}
	return ConditionOutcome.noMatch("No dependencies have been passed for the service");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-zookeeper,代码行数:15,代码来源:DependenciesPassedCondition.java


示例8: setLogLevels

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
protected void setLogLevels(LoggingSystem system, Environment environment) {
	Map<String, String> levels = Binder.get(environment)
			.bind("logging.level", STRING_STRING_MAP).orElseGet(Collections::emptyMap);
	for (Entry<String, String> entry : levels.entrySet()) {
		setLogLevel(system, environment, entry.getKey(), entry.getValue().toString());
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:8,代码来源:LoggingRebinder.java


示例9: insertPropertySources

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
private void insertPropertySources(MutablePropertySources propertySources,
		CompositePropertySource composite) {
	MutablePropertySources incoming = new MutablePropertySources();
	incoming.addFirst(composite);
	PropertySourceBootstrapProperties remoteProperties = new PropertySourceBootstrapProperties();
	Binder.get(environment(incoming)).bind("spring.cloud.config", Bindable.ofInstance(remoteProperties));
	if (!remoteProperties.isAllowOverride() || (!remoteProperties.isOverrideNone()
			&& remoteProperties.isOverrideSystemProperties())) {
		propertySources.addFirst(composite);
		return;
	}
	if (remoteProperties.isOverrideNone()) {
		propertySources.addLast(composite);
		return;
	}
	if (propertySources
			.contains(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)) {
		if (!remoteProperties.isOverrideSystemProperties()) {
			propertySources.addAfter(
					StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME,
					composite);
		}
		else {
			propertySources.addBefore(
					StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME,
					composite);
		}
	}
	else {
		propertySources.addLast(composite);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:33,代码来源:PropertySourceBootstrapConfiguration.java


示例10: getFirstNonLoopbackHostInfo

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
private HostInfo getFirstNonLoopbackHostInfo(ConfigurableEnvironment environment) {
	InetUtilsProperties target = new InetUtilsProperties();
	ConfigurationPropertySources.attach(environment);
	Binder.get(environment).bind(InetUtilsProperties.PREFIX,
			Bindable.ofInstance(target));
	try (InetUtils utils = new InetUtils(target)) {
		return utils.findFirstNonLoopbackHostInfo();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:10,代码来源:HostInfoEnvironmentPostProcessor.java


示例11: getDbInstanceConfigurations

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Map<String, Map<String, String>> getDbInstanceConfigurations() {
    Map<String, Object> subProperties = Binder.get(this.environment)
            .bind(PREFIX, Bindable.mapOf(String.class, Object.class)).orElseGet(Collections::emptyMap);
    Map<String, Map<String, String>> dbConfigurationMap = new HashMap<>(subProperties.keySet().size());
    for (Map.Entry<String, Object> subProperty : subProperties.entrySet()) {
        String instanceName = subProperty.getKey();
        if (!dbConfigurationMap.containsKey(instanceName)) {
            dbConfigurationMap.put(instanceName, new HashMap<>());
        }

        Object value = subProperty.getValue();

        if (value instanceof Map) {
            Map<String, String> map = (Map) value;
            for (Map.Entry<String, String> entry : map.entrySet()) {
                dbConfigurationMap.get(instanceName).put(entry.getKey(), entry.getValue());
            }
        } else if (value instanceof String) {
            String subPropertyName = extractConfigurationSubPropertyName(subProperty.getKey());
            if (StringUtils.hasText(subPropertyName)) {
                dbConfigurationMap.get(instanceName).put(subPropertyName, (String) subProperty.getValue());
            }
        }
    }
    return dbConfigurationMap;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:28,代码来源:AmazonRdsDatabaseAutoConfiguration.java


示例12: noop

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
@Test
public void noop() {
	this.listener.postProcessEnvironment(this.environment, new SpringApplication());
	Map<String, Object> properties = Binder.get(environment)
			.bind("security.oauth2", STRING_OBJECT_MAP).orElseGet(Collections::emptyMap);
	assertTrue(properties.isEmpty());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-cloudfoundry,代码行数:8,代码来源:VcapServiceCredentialsEnvironmentPostProcessorTests.java


示例13: getMatchOutcome

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	ConditionMessage.Builder message = ConditionMessage
			.forCondition("OAuth ResourceServer Condition");
	Environment environment = context.getEnvironment();
	if (!(environment instanceof ConfigurableEnvironment)) {
		return ConditionOutcome
				.noMatch(message.didNotFind("A ConfigurableEnvironment").atAll());
	}
	if (hasOAuthClientId(environment)) {
		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"));
	}
	if (StringUtils.hasText(environment.getProperty(prefix + "user-info-uri"))) {
		return ConditionOutcome
				.match(message.foundExactly("user-info-uri property"));
	}
	if (StringUtils.hasText(environment.getProperty(prefix + "token-info-uri"))) {
		return ConditionOutcome
				.match(message.foundExactly("token-info-uri property"));
	}
	if (ClassUtils.isPresent(AUTHORIZATION_ANNOTATION, null)) {
		if (AuthorizationServerEndpointsConfigurationBeanCondition
				.matches(context)) {
			return ConditionOutcome.match(
					message.found("class").items(AUTHORIZATION_ANNOTATION));
		}
	}
	return ConditionOutcome.noMatch(
			message.didNotFind("client ID, JWT resource or authorization server")
					.atAll());
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:43,代码来源:OAuth2ResourceServerConfiguration.java


示例14: resolverSetting

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
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 DataSourceSettings properties"));
}
 
开发者ID:lord-of-code,项目名称:loc-framework,代码行数:6,代码来源:LocBaseAutoConfiguration.java


示例15: getSubProperties

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
public static Map<String, String> getSubProperties(Environment environment,
		String keyPrefix) {
	return Binder.get(environment)
			.bind(keyPrefix, Bindable.mapOf(String.class, String.class))
			.orElseGet(Collections::emptyMap);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:7,代码来源:EnvironmentUtils.java


示例16: getClientProperties

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
private ClientProperties getClientProperties(ConditionContext context) {
    Iterable<ConfigurationPropertySource> sources = ConfigurationPropertySources.get(context.getEnvironment());
    ClientProperties clientProperties = new ClientProperties();
    new Binder(sources).bind("spring.boot.admin.client", Bindable.ofInstance(clientProperties));
    return clientProperties;
}
 
开发者ID:codecentric,项目名称:spring-boot-admin,代码行数:7,代码来源:SpringBootAdminClientEnabledCondition.java


示例17: postProcessEnvironment

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
		SpringApplication application) {
	Binder.get(environment).bind("vcap.services", STRING_OBJECT_MAP)
			.orElseGet(Collections::emptyMap);
	if (!hasChildProperties(environment, "vcap.services")) {
		return;
	}
	Map<String, Object> source = new HashMap<>();
	String serviceId;
	if (hasChildProperties(environment, "security.oauth2.resource")) {
		serviceId = environment.getProperty("security.oauth2.resource.service-id",
				"resource");
	}
	else {
		serviceId = environment.getProperty("security.oauth2.sso.service-id", "sso");
	}
	String authDomain = environment
			.getProperty("vcap.services." + serviceId + ".credentials.auth-domain");
	if (authDomain != null) {
		source.put("security.oauth2.resource.user-info-uri",
				authDomain + "/userinfo");
		source.put("security.oauth2.resource.jwt.key-uri", authDomain + "/token_key");
		source.put("security.oauth2.client.access-token-uri",
				authDomain + "/oauth/token");
		source.put("security.oauth2.client.user-authorization-uri",
				authDomain + "/oauth/authorize");
	}
	else {
		addProperty(source, environment, serviceId, "resource", "user-info-uri");
		addProperty(source, environment, serviceId, "resource", "token-info-uri");
		addProperty(source, environment, serviceId, "resource.jwt", "key-uri");
		addProperty(source, environment, serviceId, "resource", "key-value");
		addProperty(source, environment, serviceId, "client", "access-token-uri",
				"token-uri");
		addProperty(source, environment, serviceId, "client",
				"user-authorization-uri", "authorization-uri");
	}
	addProperty(source, environment, serviceId, "client", "client-id");
	addProperty(source, environment, serviceId, "client", "client-secret");
	addProperty(source, environment, serviceId, "client", "scope");
	String resourceId = environment
			.getProperty("vcap.services." + serviceId + ".credentials.id", "");
	if (StringUtils.hasText(resourceId)) {
		source.put("security.oauth2.resource.id", resourceId);
	}
	environment.getPropertySources()
			.addLast(new MapPropertySource("cloudDefaultSecurityBindings", source));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-cloudfoundry,代码行数:50,代码来源:VcapServiceCredentialsEnvironmentPostProcessor.java


示例18: hasChildProperties

import org.springframework.boot.context.properties.bind.Binder; //导入依赖的package包/类
private boolean hasChildProperties(ConfigurableEnvironment environment, String name) {
	Map<String, Object> properties = Binder.get(environment)
			.bind(name, STRING_OBJECT_MAP).orElseGet(Collections::emptyMap);
	return !properties.isEmpty();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-cloudfoundry,代码行数:6,代码来源:VcapServiceCredentialsEnvironmentPostProcessor.java



注:本文中的org.springframework.boot.context.properties.bind.Binder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Parser类代码示例发布时间:2022-05-23
下一篇:
Java MissingProperty类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap