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


Java RelaxedPropertyResolver.getProperty方法代码示例

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


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

示例1: getValue

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
private String getValue(String source, String defaultValue) {
	if (this.environment == null) {
		addWarn("No Spring Environment available to resolve " + source);
		return defaultValue;
	}
	String value = this.environment.getProperty(source);
	if (value != null) {
		return value;
	}
	int lastDot = source.lastIndexOf(".");
	if (lastDot > 0) {
		String prefix = source.substring(0, lastDot + 1);
		RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
				this.environment, prefix);
		return resolver.getProperty(source.substring(lastDot + 1), defaultValue);
	}
	return defaultValue;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:SpringPropertyAction.java

示例2: getMatchOutcome

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
	final RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(),
			"holon.swagger.");

	if (!resolver.getProperty("holon.swagger.enabled", boolean.class, true)) {
		return ConditionOutcome.noMatch(ConditionMessage.forCondition("SwaggerApiAutoDetectCondition")
				.because("holon.swagger.enabled is false"));
	}

	if (resolver.containsProperty("resourcePackage")) {
		return ConditionOutcome.noMatch(
				ConditionMessage.forCondition("SwaggerApiAutoDetectCondition").available("resourcePackage"));
	}
	Map<String, Object> ag = resolver.getSubProperties("apiGroups");
	if (ag != null && ag.size() > 0) {
		return ConditionOutcome
				.noMatch(ConditionMessage.forCondition("SwaggerApiAutoDetectCondition").available("apiGroups"));
	}
	return ConditionOutcome.match();
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:22,代码来源:SwaggerApiAutoDetectCondition.java

示例3: initTargetDataSources

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
/**
 * @param env
 * @Title: initTargetDataSources
 * @Description: 初始化更多数据源
 * @author Kola 6089555
 * @date 2017年4月24日 下午6:45:32
 */
private void initTargetDataSources(Environment env) {
    RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(env, "druid.slaveSource.");
    String slaveNodes = propertyResolver.getProperty("node");
    if (StringUtils.isNotBlank(slaveNodes)) {
        for (String dsPrefix : slaveNodes.split(",")) {
            if (StringUtils.isNotBlank(dsPrefix)) {
                String dataSourceClass = new RelaxedPropertyResolver(env, "druid.slaveSource." + dsPrefix + ".").getProperty("type");
                if (StringUtils.isNotBlank(dataSourceClass)) {
                    DataSource dataSource = buildDataSource(dataSourceClass);
                    dataBinder(dataSource, env, "druid.slaveSource." + dsPrefix);
                    targetDataSources.put(dsPrefix, dataSource);
                }
            }
        }
    }
}
 
开发者ID:6089555,项目名称:spring-boot-starter-dynamic-datasource,代码行数:24,代码来源:DynamicDataSourceRegister.java

示例4: isTemplateAvailable

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
@Override
public boolean isTemplateAvailable(String view, Environment environment,
		ClassLoader classLoader, ResourceLoader resourceLoader) {
	if (ClassUtils.isPresent("freemarker.template.Configuration", classLoader)) {
		RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
				"spring.freemarker.");
		String loaderPath = resolver.getProperty("template-loader-path",
				FreeMarkerProperties.DEFAULT_TEMPLATE_LOADER_PATH);
		String prefix = resolver.getProperty("prefix",
				FreeMarkerProperties.DEFAULT_PREFIX);
		String suffix = resolver.getProperty("suffix",
				FreeMarkerProperties.DEFAULT_SUFFIX);
		return resourceLoader.getResource(loaderPath + prefix + view + suffix)
				.exists();
	}
	return false;
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:18,代码来源:FreeMarkerTemplateAvailabilityProvider.java

示例5: getMatchOutcome

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	Environment environment = context.getEnvironment();
	RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
			"security.oauth2.resource.");
	Boolean preferTokenInfo = resolver.getProperty("prefer-token-info",
			Boolean.class);
	if (preferTokenInfo == null) {
		preferTokenInfo = environment
				.resolvePlaceholders("${OAUTH2_RESOURCE_PREFERTOKENINFO:true}")
				.equals("true");
	}
	String tokenInfoUri = resolver.getProperty("token-info-uri");
	String userInfoUri = resolver.getProperty("user-info-uri");
	if (!StringUtils.hasLength(userInfoUri)) {
		return ConditionOutcome.match("No user info provided");
	}
	if (StringUtils.hasLength(tokenInfoUri) && preferTokenInfo) {
		return ConditionOutcome.match(
				"Token info endpoint " + "is preferred and user info provided");
	}
	return ConditionOutcome.noMatch("Token info endpoint is not provided");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:25,代码来源:ResourceServerTokenServicesConfiguration.java

示例6: getProvider

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
/**
 * Get the provider that can be used to render the given view.
 * @param view the view to render
 * @param environment the environment
 * @param classLoader the class loader
 * @param resourceLoader the resource loader
 * @return a {@link TemplateAvailabilityProvider} or null
 */
public TemplateAvailabilityProvider getProvider(String view, Environment environment,
		ClassLoader classLoader, ResourceLoader resourceLoader) {
	Assert.notNull(view, "View must not be null");
	Assert.notNull(environment, "Environment must not be null");
	Assert.notNull(classLoader, "ClassLoader must not be null");
	Assert.notNull(resourceLoader, "ResourceLoader must not be null");

	RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(
			environment, "spring.template.provider.");
	if (!propertyResolver.getProperty("cache", Boolean.class, true)) {
		return findProvider(view, environment, classLoader, resourceLoader);
	}
	TemplateAvailabilityProvider provider = this.resolved.get(view);
	if (provider == null) {
		synchronized (this.cache) {
			provider = findProvider(view, environment, classLoader, resourceLoader);
			provider = (provider == null ? NONE : provider);
			this.resolved.put(view, provider);
			this.cache.put(view, provider);
		}
	}
	return (provider == NONE ? null : provider);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:32,代码来源:TemplateAvailabilityProviders.java

示例7: onApplicationEvent

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
	RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
			event.getEnvironment(), "spring.");
	if (resolver.containsProperty("mandatoryFileEncoding")) {
		String encoding = System.getProperty("file.encoding");
		String desired = resolver.getProperty("mandatoryFileEncoding");
		if (encoding != null && !desired.equalsIgnoreCase(encoding)) {
			logger.error("System property 'file.encoding' is currently '" + encoding
					+ "'. It should be '" + desired
					+ "' (as defined in 'spring.mandatoryFileEncoding').");
			logger.error("Environment variable LANG is '" + System.getenv("LANG")
					+ "'. You could use a locale setting that matches encoding='"
					+ desired + "'.");
			logger.error("Environment variable LC_ALL is '" + System.getenv("LC_ALL")
					+ "'. You could use a locale setting that matches encoding='"
					+ desired + "'.");
			throw new IllegalStateException(
					"The Java Virtual Machine has not been configured to use the "
							+ "desired default character encoding (" + desired
							+ ").");
		}
	}
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:25,代码来源:FileEncodingApplicationListener.java

示例8: initialize

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
@Override
public void initialize(TelemetryContext telemetryContext) {
    RelaxedPropertyResolver relaxedPropertyResolver = new RelaxedPropertyResolver(environment);
    telemetryContext.getTags().put("ai.spring-boot.version", SpringBootVersion.getVersion());
    telemetryContext.getTags().put("ai.spring.version", SpringVersion.getVersion());
    String ipAddress = relaxedPropertyResolver.getProperty("spring.cloud.client.ipAddress");
    if (ipAddress != null) {
        // if spring-cloud is available we can set ip address
        telemetryContext.getTags().put(ContextTagKeys.getKeys().getLocationIP(), ipAddress);
    }
}
 
开发者ID:gavlyukovskiy,项目名称:azure-application-insights-spring-boot-starter,代码行数:12,代码来源:SpringBootContextInitializer.java

示例9: getMatchOutcome

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    AnnotationAttributes attributes = AnnotationAttributes
            .fromMap(metadata.getAnnotationAttributes(ConditionalOnEnabledDetector.class.getName()));
    final String name = attributes.getString("value");
    final String prefix = attributes.getString("prefix");
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment(),
            prefix + "." + name + ".");
    Boolean enabled = resolver.getProperty("enabled", Boolean.class, true);
    return new ConditionOutcome(enabled, ConditionMessage.forCondition(ConditionalOnEnabledDetector.class, name)
            .because(enabled ? "enabled" : "disabled"));
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:13,代码来源:OnEnabledDetectorCondition.java

示例10: setEnvironment

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
@Override
public void setEnvironment(Environment env) {
    if (!StringUtils.hasText(application.getComponent().getName())) {
        // set the application name from the environment,
        // but allow the defaults to use relaxed binding
        // (shamelessly copied from Spring Boot)
        RelaxedPropertyResolver springPropertyResolver = new RelaxedPropertyResolver(env, "spring.application.");
        String appName = springPropertyResolver.getProperty("name");
        application.getComponent().setName(StringUtils.hasText(appName) ? appName : generateName());
    }
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:12,代码来源:CereebroProperties.java

示例11: isEnabled

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
private boolean isEnabled(
    org.springframework.context.annotation.ConditionContext context,
    java.lang.String prefix, boolean defaultValue) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
        context.getEnvironment(), prefix);
    return resolver.getProperty("enabled", Boolean.class, defaultValue);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:8,代码来源:HttpComponentAutoConfiguration.java

示例12: configureIgnoreBeanInfo

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
private void configureIgnoreBeanInfo(ConfigurableEnvironment environment) {
	if (System.getProperty(
			CachedIntrospectionResults.IGNORE_BEANINFO_PROPERTY_NAME) == null) {
		RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment,
				"spring.beaninfo.");
		Boolean ignore = resolver.getProperty("ignore", Boolean.class, Boolean.TRUE);
		System.setProperty(CachedIntrospectionResults.IGNORE_BEANINFO_PROPERTY_NAME,
				ignore.toString());
	}
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:11,代码来源:ConfigFileApplicationListener.java

示例13: onApplicationEvent

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
	RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
			event.getEnvironment(), "spring.output.ansi.");
	if (resolver.containsProperty("enabled")) {
		String enabled = resolver.getProperty("enabled");
		AnsiOutput.setEnabled(Enum.valueOf(Enabled.class, enabled.toUpperCase()));
	}

	if (resolver.containsProperty("console-available")) {
		AnsiOutput.setConsoleAvailable(
				resolver.getProperty("console-available", Boolean.class));
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:AnsiOutputApplicationListener.java

示例14: getMatchOutcome

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
			context.getEnvironment(), "security.oauth2.resource.jwt.");
	String keyValue = resolver.getProperty("key-value");
	String keyUri = resolver.getProperty("key-uri");
	if (StringUtils.hasText(keyValue) || StringUtils.hasText(keyUri)) {
		return ConditionOutcome.match("public key is provided");
	}
	return ConditionOutcome.noMatch("public key is not provided");
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:13,代码来源:ResourceServerTokenServicesConfiguration.java

示例15: determineEndpointOutcome

import org.springframework.boot.bind.RelaxedPropertyResolver; //导入方法依赖的package包/类
private ConditionOutcome determineEndpointOutcome(String endpointName,
		boolean enabledByDefault, ConditionContext context) {
	RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
			context.getEnvironment(), "endpoints." + endpointName + ".");
	if (resolver.containsProperty("enabled") || !enabledByDefault) {
		boolean match = resolver.getProperty("enabled", Boolean.class,
				enabledByDefault);
		return new ConditionOutcome(match, "The endpoint " + endpointName + " is "
				+ (match ? "enabled" : "disabled"));
	}
	return null;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:OnEnabledEndpointCondition.java


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