當前位置: 首頁>>代碼示例>>Java>>正文


Java RelaxedPropertyResolver類代碼示例

本文整理匯總了Java中org.springframework.boot.bind.RelaxedPropertyResolver的典型用法代碼示例。如果您正苦於以下問題:Java RelaxedPropertyResolver類的具體用法?Java RelaxedPropertyResolver怎麽用?Java RelaxedPropertyResolver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RelaxedPropertyResolver類屬於org.springframework.boot.bind包,在下文中一共展示了RelaxedPropertyResolver類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isTemplateAvailable

import org.springframework.boot.bind.RelaxedPropertyResolver; //導入依賴的package包/類
@Override
public boolean isTemplateAvailable(String view, Environment environment,
                                   ClassLoader classLoader, ResourceLoader resourceLoader) {
    if (ClassUtils.isPresent("org.apache.velocity.app.VelocityEngine", classLoader)) {
        PropertyResolver resolver = new RelaxedPropertyResolver(environment,
                "spring.velocity.");
        String loaderPath = resolver.getProperty("resource-loader-path",
                VelocityProperties.DEFAULT_RESOURCE_LOADER_PATH);
        String prefix = resolver.getProperty("prefix",
                VelocityProperties.DEFAULT_PREFIX);
        String suffix = resolver.getProperty("suffix",
                VelocityProperties.DEFAULT_SUFFIX);
        return resourceLoader.getResource(loaderPath + prefix + view + suffix)
                             .exists();
    }
    return false;
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:18,代碼來源:VelocityTemplateAvailabilityProvider.java

示例2: 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

示例3: 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

示例4: setEnvironment

import org.springframework.boot.bind.RelaxedPropertyResolver; //導入依賴的package包/類
public void setEnvironment(Environment environment) {
    this.propertyResolver = new RelaxedPropertyResolver(environment, null);
    this.url = propertyResolver.getProperty("spring.datasource.url");
    this.userName= propertyResolver.getProperty("spring.datasource.username");
    this.password = propertyResolver.getProperty("spring.datasource.password");
    this.driveClassName = propertyResolver.getProperty("spring.datasource.driver-class-name");
    this.filters = propertyResolver.getProperty("spring.datasource.filters");
    this.maxActive = propertyResolver.getProperty("spring.datasource.maxActive");
    this.initialSize = propertyResolver.getProperty("spring.datasource.initialSize");
    this.maxWait = propertyResolver.getProperty("spring.datasource.maxWait");
    this.minIdle = propertyResolver.getProperty("spring.datasource.minIdle");
    this.timeBetweenEvictionRunsMillis = propertyResolver.getProperty("spring.datasource.timeBetweenEvictionRunsMillis");
    this.minEvictableIdleTimeMillis = propertyResolver.getProperty("spring.datasource.minEvictableIdleTimeMillis");
    this.validationQuery = propertyResolver.getProperty("spring.datasource.validationQuery");
    this.testWhileIdle = propertyResolver.getProperty("spring.datasource.testWhileIdle");
    this.testOnBorrow = propertyResolver.getProperty("spring.datasource.testOnBorrow");
    this.testOnReturn = propertyResolver.getProperty("spring.datasource.testOnReturn");
    this.poolPreparedStatements = propertyResolver.getProperty("spring.datasource.poolPreparedStatements");
    this.maxOpenPreparedStatements = propertyResolver.getProperty("spring.datasource.maxOpenPreparedStatements");
    this.typeAliasesPackage = propertyResolver.getProperty("mybatis.typeAliasesPackage");
    this.xmlLocation = propertyResolver.getProperty("mybatis.xmlLocation");
}
 
開發者ID:fier-liu,項目名稱:FCat,代碼行數:23,代碼來源:MybatisConfiguration.java

示例5: 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

示例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: getMatchOutcome

import org.springframework.boot.bind.RelaxedPropertyResolver; //導入依賴的package包/類
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
			context.getEnvironment(), "spring.session.");
	StoreType sessionStoreType = SessionStoreMappings
			.getType(((AnnotationMetadata) metadata).getClassName());
	if (!resolver.containsProperty("store-type")) {
		if (sessionStoreType == StoreType.REDIS && redisPresent) {
			return ConditionOutcome
					.match("Session store type default to redis (deprecated)");
		}
		return ConditionOutcome.noMatch("Session store type not set");
	}
	String value = resolver.getProperty("store-type").replace("-", "_").toUpperCase();
	if (value.equals(sessionStoreType.name())) {
		return ConditionOutcome.match("Session store type " + sessionStoreType);
	}
	return ConditionOutcome.noMatch("Session store type " + value);
}
 
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:21,代碼來源:SessionCondition.java

示例8: getMatchOutcome

import org.springframework.boot.bind.RelaxedPropertyResolver; //導入依賴的package包/類
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	Environment environment = context.getEnvironment();
	String config = environment.resolvePlaceholders("${logging.file:}");
	if (StringUtils.hasText(config)) {
		return ConditionOutcome.match("Found logging.file: " + config);
	}
	config = environment.resolvePlaceholders("${logging.path:}");
	if (StringUtils.hasText(config)) {
		return ConditionOutcome.match("Found logging.path: " + config);
	}
	config = new RelaxedPropertyResolver(environment, "endpoints.logfile.")
			.getProperty("external-file");
	if (StringUtils.hasText(config)) {
		return ConditionOutcome
				.match("Found endpoints.logfile.external-file: " + config);
	}
	return ConditionOutcome.noMatch("Found no log file configuration");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:21,代碼來源:EndpointWebMvcManagementContextConfiguration.java

示例9: 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

示例10: 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.");
	if (hasOAuthClientId(environment)) {
		return ConditionOutcome.match("found client id");
	}
	if (!resolver.getSubProperties("jwt").isEmpty()) {
		return ConditionOutcome.match("found JWT resource configuration");
	}
	if (StringUtils.hasText(resolver.getProperty("user-info-uri"))) {
		return ConditionOutcome
				.match("found UserInfo " + "URI resource configuration");
	}
	if (ClassUtils.isPresent(AUTHORIZATION_ANNOTATION, null)) {
		if (AuthorizationServerEndpointsConfigurationBeanCondition
				.matches(context)) {
			return ConditionOutcome.match(
					"found authorization " + "server endpoints configuration");
		}
	}
	return ConditionOutcome.noMatch("found neither client id nor "
			+ "JWT resource nor authorization server");
}
 
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:27,代碼來源:OAuth2ResourceServerConfiguration.java

示例11: getMatchOutcome

import org.springframework.boot.bind.RelaxedPropertyResolver; //導入依賴的package包/類
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
			context.getEnvironment(), "spring.cache.");
	if (!resolver.containsProperty("type")) {
		return ConditionOutcome.match("Automatic cache type");
	}
	CacheType cacheType = CacheConfigurations
			.getType(((AnnotationMetadata) metadata).getClassName());
	String value = resolver.getProperty("type").replace("-", "_").toUpperCase();
	if (value.equals(cacheType.name())) {
		return ConditionOutcome.match("Cache type " + cacheType);
	}
	return ConditionOutcome.noMatch("Cache type " + value);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:17,代碼來源:CacheCondition.java

示例12: getMatchOutcome

import org.springframework.boot.bind.RelaxedPropertyResolver; //導入依賴的package包/類
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
		AnnotatedTypeMetadata metadata) {
	RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
			context.getEnvironment(), "spring.cache.jcache.");
	if (resolver.containsProperty("provider")) {
		return ConditionOutcome.match("JCache provider specified");
	}
	Iterator<CachingProvider> providers = Caching.getCachingProviders()
			.iterator();
	if (!providers.hasNext()) {
		return ConditionOutcome.noMatch("No JSR-107 compliant providers");
	}
	providers.next();
	if (providers.hasNext()) {
		return ConditionOutcome.noMatch(
				"Multiple default JSR-107 compliant " + "providers found");

	}
	return ConditionOutcome.match("Default JSR-107 compliant provider found.");
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:22,代碼來源:JCacheCacheConfiguration.java

示例13: isTemplateAvailable

import org.springframework.boot.bind.RelaxedPropertyResolver; //導入依賴的package包/類
@Override
public boolean isTemplateAvailable(String view, Environment environment,
		ClassLoader classLoader, ResourceLoader resourceLoader) {
	if (ClassUtils.isPresent("org.apache.velocity.app.VelocityEngine", classLoader)) {
		PropertyResolver resolver = new RelaxedPropertyResolver(environment,
				"spring.velocity.");
		String loaderPath = resolver.getProperty("resource-loader-path",
				VelocityProperties.DEFAULT_RESOURCE_LOADER_PATH);
		String prefix = resolver.getProperty("prefix",
				VelocityProperties.DEFAULT_PREFIX);
		String suffix = resolver.getProperty("suffix",
				VelocityProperties.DEFAULT_SUFFIX);
		return resourceLoader.getResource(loaderPath + prefix + view + suffix)
				.exists();
	}
	return false;
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:18,代碼來源:VelocityTemplateAvailabilityProvider.java

示例14: 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

示例15: 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


注:本文中的org.springframework.boot.bind.RelaxedPropertyResolver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。