当前位置: 首页>>代码示例>>Java>>正文


Java RelaxedDataBinder.bind方法代码示例

本文整理汇总了Java中org.springframework.boot.bind.RelaxedDataBinder.bind方法的典型用法代码示例。如果您正苦于以下问题:Java RelaxedDataBinder.bind方法的具体用法?Java RelaxedDataBinder.bind怎么用?Java RelaxedDataBinder.bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.boot.bind.RelaxedDataBinder的用法示例。


在下文中一共展示了RelaxedDataBinder.bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMatchOutcome

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	ConfigurableEnvironment environment = (ConfigurableEnvironment) context
			.getEnvironment();
	ResourceProperties properties = new ResourceProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(properties, "spring.resources");
	binder.bind(new PropertySourcesPropertyValues(environment.getPropertySources()));
	Boolean match = properties.getChain().getEnabled();
	if (match == null) {
		boolean webJarsLocatorPresent = ClassUtils.isPresent(WEBJAR_ASSERT_LOCATOR,
				getClass().getClassLoader());
		return new ConditionOutcome(webJarsLocatorPresent,
				"Webjars locator (" + WEBJAR_ASSERT_LOCATOR + ") is "
						+ (webJarsLocatorPresent ? "present" : "absent"));
	}
	return new ConditionOutcome(match,
			"Resource chain is " + (match ? "enabled" : "disabled"));
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:20,代码来源:OnEnabledResourceChainCondition.java

示例2: testBindingSsh

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testBindingSsh() {
	ShellProperties props = new ShellProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
	binder.setConversionService(new DefaultConversionService());
	Map<String, String> map = new HashMap<String, String>();
	map.put("shell.ssh.enabled", "true");
	map.put("shell.ssh.port", "2222");
	map.put("shell.ssh.key_path", "~/.ssh/test.pem");
	binder.bind(new MutablePropertyValues(map));
	assertFalse(binder.getBindingResult().hasErrors());

	Properties p = props.asCrshShellConfig();

	assertEquals("2222", p.get("crash.ssh.port"));
	assertEquals("~/.ssh/test.pem", p.get("crash.ssh.keypath"));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:ShellPropertiesTests.java

示例3: testBindingSshIgnored

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testBindingSshIgnored() {
	ShellProperties props = new ShellProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
	binder.setConversionService(new DefaultConversionService());
	Map<String, String> map = new HashMap<String, String>();
	map.put("shell.ssh.enabled", "false");
	map.put("shell.ssh.port", "2222");
	map.put("shell.ssh.key_path", "~/.ssh/test.pem");
	binder.bind(new MutablePropertyValues(map));
	assertFalse(binder.getBindingResult().hasErrors());

	Properties p = props.asCrshShellConfig();

	assertNull(p.get("crash.ssh.port"));
	assertNull(p.get("crash.ssh.keypath"));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:ShellPropertiesTests.java

示例4: testBindingSimple

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testBindingSimple() {
	SimpleAuthenticationProperties props = new SimpleAuthenticationProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell.auth.simple");
	binder.setConversionService(new DefaultConversionService());
	Map<String, String> map = new HashMap<String, String>();
	map.put("shell.auth.simple.user.name", "username123");
	map.put("shell.auth.simple.user.password", "password123");
	binder.bind(new MutablePropertyValues(map));
	assertFalse(binder.getBindingResult().hasErrors());

	Properties p = new Properties();
	props.applyToCrshShellConfig(p);

	assertEquals("username123", p.get("crash.auth.simple.username"));
	assertEquals("password123", p.get("crash.auth.simple.password"));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:ShellPropertiesTests.java

示例5: getExcludeAutoConfigurationsProperty

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
private List<String> getExcludeAutoConfigurationsProperty() {
	if (getEnvironment() instanceof ConfigurableEnvironment) {
		Excludes excludes = new Excludes();
		RelaxedDataBinder binder = new RelaxedDataBinder(excludes,
				"spring.autoconfigure.");
		binder.bind(new PropertySourcesPropertyValues(
				((ConfigurableEnvironment) getEnvironment()).getPropertySources()));
		return excludes.getExclude();
	}
	RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(getEnvironment(),
			"spring.autoconfigure.");
	String[] exclude = resolver.getProperty("exclude", String[].class);
	return (Arrays.asList(exclude == null ? new String[0] : exclude));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:EnableAutoConfigurationImportSelector.java

示例6: testAddressBinding

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testAddressBinding() throws Exception {
	RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
	binder.bind(new MutablePropertyValues(
			Collections.singletonMap("server.address", "127.0.0.1")));
	assertThat(binder.getBindingResult().hasErrors()).isFalse();
	assertThat(this.properties.getAddress())
			.isEqualTo(InetAddress.getByName("127.0.0.1"));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ServerPropertiesTests.java

示例7: testServerHeader

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testServerHeader() throws Exception {
	RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
	binder.bind(new MutablePropertyValues(
			Collections.singletonMap("server.server-header", "Custom Server")));
	assertThat(this.properties.getServerHeader()).isEqualTo("Custom Server");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:ServerPropertiesTests.java

示例8: testServletPathAsMapping

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testServletPathAsMapping() throws Exception {
	RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
	binder.bind(new MutablePropertyValues(
			Collections.singletonMap("server.servletPath", "/foo/*")));
	assertThat(binder.getBindingResult().hasErrors()).isFalse();
	assertThat(this.properties.getServletMapping()).isEqualTo("/foo/*");
	assertThat(this.properties.getServletPrefix()).isEqualTo("/foo");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ServerPropertiesTests.java

示例9: testServletPathAsPrefix

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testServletPathAsPrefix() throws Exception {
	RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
	binder.bind(new MutablePropertyValues(
			Collections.singletonMap("server.servletPath", "/foo")));
	assertThat(binder.getBindingResult().hasErrors()).isFalse();
	assertThat(this.properties.getServletMapping()).isEqualTo("/foo/*");
	assertThat(this.properties.getServletPrefix()).isEqualTo("/foo");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ServerPropertiesTests.java

示例10: preInit

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Override
public void preInit(SpringProcessEngineConfiguration springProcessEngineConfiguration) {
  GenericProperties genericProperties = camundaBpmProperties.getGenericProperties();
  final Map<String, Object> properties = genericProperties.getProperties();
  if (!CollectionUtils.isEmpty(properties)) {
    RelaxedDataBinder relaxedDataBinder = new RelaxedDataBinder(springProcessEngineConfiguration);
    relaxedDataBinder.setIgnoreInvalidFields(genericProperties.isIgnoreInvalidFields());
    relaxedDataBinder.setIgnoreUnknownFields(genericProperties.isIgnoreUnknownFields());
    relaxedDataBinder.bind(getPropertyValues(properties));
    logger.debug("properties bound to configuration: {}", genericProperties);
  }
}
 
开发者ID:camunda,项目名称:camunda-bpm-spring-boot-starter,代码行数:13,代码来源:GenericPropertiesConfiguration.java

示例11: testBindingAuth

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testBindingAuth() {
	ShellProperties props = new ShellProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
	binder.bind(new MutablePropertyValues(
			Collections.singletonMap("shell.auth", "spring")));
	assertFalse(binder.getBindingResult().hasErrors());
	assertEquals("spring", props.getAuth());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:10,代码来源:ShellPropertiesTests.java

示例12: testServletPathAsMapping

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testServletPathAsMapping() throws Exception {
	RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
	binder.bind(new MutablePropertyValues(
			Collections.singletonMap("server.servletPath", "/foo/*")));
	assertFalse(binder.getBindingResult().hasErrors());
	assertEquals("/foo/*", this.properties.getServletMapping());
	assertEquals("/foo", this.properties.getServletPrefix());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:10,代码来源:ServerPropertiesTests.java

示例13: testBindingCommandRefreshInterval

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testBindingCommandRefreshInterval() {
	ShellProperties props = new ShellProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
	binder.setConversionService(new DefaultConversionService());
	binder.bind(new MutablePropertyValues(
			Collections.singletonMap("shell.command_refresh_interval", "1")));
	assertFalse(binder.getBindingResult().hasErrors());
	assertEquals(1, props.getCommandRefreshInterval());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:11,代码来源:ShellPropertiesTests.java

示例14: testBindingCommandPathPatterns

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testBindingCommandPathPatterns() {
	ShellProperties props = new ShellProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
	binder.setConversionService(new DefaultConversionService());
	binder.bind(new MutablePropertyValues(Collections
			.singletonMap("shell.command_path_patterns", "pattern1, pattern2")));
	assertFalse(binder.getBindingResult().hasErrors());
	assertEquals(2, props.getCommandPathPatterns().length);
	Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" },
			props.getCommandPathPatterns());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:13,代码来源:ShellPropertiesTests.java

示例15: testBindingConfigPathPatterns

import org.springframework.boot.bind.RelaxedDataBinder; //导入方法依赖的package包/类
@Test
public void testBindingConfigPathPatterns() {
	ShellProperties props = new ShellProperties();
	RelaxedDataBinder binder = new RelaxedDataBinder(props, "shell");
	binder.setConversionService(new DefaultConversionService());
	binder.bind(new MutablePropertyValues(Collections
			.singletonMap("shell.config_path_patterns", "pattern1, pattern2")));
	assertFalse(binder.getBindingResult().hasErrors());
	assertEquals(2, props.getConfigPathPatterns().length);
	Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" },
			props.getConfigPathPatterns());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:13,代码来源:ShellPropertiesTests.java


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