Java 类org.springframework.boot.bind.RelaxedPropertyResolver 实例源码

项目:ARCLib    文件:VelocityTemplateAvailabilityProvider.java   
@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;
}
项目:holon-jaxrs    文件:SwaggerApiAutoDetectCondition.java   
@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();
}
项目:FCat    文件:MybatisConfiguration.java   
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");
}
项目:spring-boot-starter-dynamic-datasource    文件:DynamicDataSourceRegister.java   
/**
 * @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);
                }
            }
        }
    }
}
项目:spring-boot-concourse    文件:TemplateAvailabilityProviders.java   
/**
 * 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);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringPropertyAction.java   
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;
}
项目:spring-boot-concourse    文件:SessionCondition.java   
@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);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcManagementContextConfiguration.java   
@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");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ResourceServerTokenServicesConfiguration.java   
@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");
}
项目:spring-boot-concourse    文件:OAuth2ResourceServerConfiguration.java   
@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");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:TemplateAvailabilityProviders.java   
/**
 * 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);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:CacheCondition.java   
@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);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JCacheCacheConfiguration.java   
@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.");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:VelocityTemplateAvailabilityProvider.java   
@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;
}
项目:spring-boot-concourse    文件:CacheCondition.java   
@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);
}
项目:spring-boot-concourse    文件:JCacheCacheConfiguration.java   
@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.");
}
项目:spring-boot-concourse    文件:SpringPropertyAction.java   
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;
}
项目:spring-boot-concourse    文件:FileEncodingApplicationListener.java   
@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
                            + ").");
        }
    }
}
项目:spring-boot-concourse    文件:VelocityTemplateAvailabilityProvider.java   
@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;
}
项目:azure-application-insights-spring-boot-starter    文件:SpringBootContextInitializer.java   
@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);
    }
}
项目:cereebro    文件:OnEnabledDetectorCondition.java   
@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"));
}
项目:cereebro    文件:CereebroProperties.java   
@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());
    }
}
项目:cereebro    文件:CereebroEurekaInstanceAutoConfiguration.java   
@Bean
@ConditionalOnBean(SnitchEndpoint.class)
public EurekaMetadataPopulator eurekaMetadataPopulator(SnitchEndpoint snitch, ApplicationInfoManager manager,
        ObjectMapper mapper) {
    RelaxedPropertyResolver relaxedPropertyResolver = new RelaxedPropertyResolver(env, "cereebro.snitch.eureka.");
    EurekaInstanceSnitchProperties props = new EurekaInstanceSnitchProperties();
    props.setEndpointUrl(relaxedPropertyResolver.getProperty("endpointUrl"));
    props.setEndpointUrlPath(relaxedPropertyResolver.getProperty("endpointUrlPath"));
    EurekaMetadataPopulator metadataPopulator = new EurekaMetadataPopulator(snitch, manager, props, mapper);
    metadataPopulator.populate();
    return metadataPopulator;
}
项目:syndesis    文件:HttpComponentAutoConfiguration.java   
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);
}
项目:connectors    文件:HttpComponentAutoConfiguration.java   
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);
}
项目:FCat    文件:SwaggerConfiguration.java   
@Override
public void setEnvironment(Environment environment) {
    this.propertyResolver = new RelaxedPropertyResolver(environment, null);
    this.basePackage = propertyResolver.getProperty("swagger.basepackage");
    this.creatName = propertyResolver.getProperty("swagger.service.developer");
    this.serviceName = propertyResolver.getProperty("swagger.service.name");
    this.description = propertyResolver.getProperty("swagger.service.description");
}
项目:spring-boot-sample    文件:SwaggerConfiguration.java   
@Override
public void setEnvironment(Environment environment) {
    this.propertyResolver = new RelaxedPropertyResolver(environment, "swagger.");
    this.contact = new Contact(propertyResolver.getProperty("author"), propertyResolver.getProperty("url"), propertyResolver.getProperty("email"));
    String[] regex = propertyResolver.getProperty("apiPath").split(",");
    for (String str : regex) {
        components.add(regex(str));
    }
}
项目:microservices-dashboard-server    文件:ForwardOAuth2TokenStrategyConfiguration.java   
@Override
public ConditionOutcome getMatchOutcome(final ConditionContext context,
                                        final AnnotatedTypeMetadata metadata) {
    final RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(context.getEnvironment());
    final String propertiesProperty = resolver.getProperty("msdashboard.security.strategies.forward-oauth2-token", String.class);
    final String yamlProperty = resolver.getProperty("msdashboard.security.strategies.forward-oauth2-token[0]", String.class);
    return new ConditionOutcome(propertiesProperty != null || yamlProperty != null, "Conditional on forward-oauth2-token value");
}
项目:pebble-spring-boot-starter    文件:PebbleTemplateAvailabilityProvider.java   
@Override
public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader,
        ResourceLoader resourceLoader) {
    if (ClassUtils.isPresent("com.mitchellbosecke.pebble.PebbleEngine", classLoader)) {
        PropertyResolver resolver = new RelaxedPropertyResolver(environment, "pebble.");
        String prefix = resolver.getProperty("prefix", PebbleProperties.DEFAULT_PREFIX);
        String suffix = resolver.getProperty("suffix", PebbleProperties.DEFAULT_SUFFIX);
        return resourceLoader.getResource(ResourceLoader.CLASSPATH_URL_PREFIX + prefix + view + suffix).exists();
    } else {
        return false;
    }
}
项目:spring-boot-concourse    文件:ApplicationPidFileWriter.java   
@Override
public String getValue(SpringApplicationEvent event) {
    Environment environment = getEnvironment(event);
    if (environment == null) {
        return null;
    }
    return new RelaxedPropertyResolver(environment, this.prefix)
            .getProperty(this.key);
}
项目:jeesuite-libs    文件:KafkaProducerProperties.java   
@Override
public void setEnvironment(Environment environment) {
    String kafkaServers = environment.getProperty("kafka.bootstrap.servers");
    //String zkServers = environment.getProperty("zookeeper.servers");
    configs.put("bootstrap.servers", kafkaServers);
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment, "kafka.producer.");
    Map<String, Object> subProperties = resolver.getSubProperties("");
    if(subProperties != null && !subProperties.isEmpty()){
        configs.putAll(subProperties);
    }
}
项目:jeesuite-libs    文件:KafkaConsumerProperties.java   
@Override
public void setEnvironment(Environment environment) {
    String kafkaServers = environment.getProperty("kafka.bootstrap.servers");
    String zkServers = environment.getProperty("kafka.zkServers");
    configs.put("bootstrap.servers", kafkaServers);
    if(useNewAPI == false && zkServers != null){
        configs.put("zookeeper.connect", zkServers);
    }
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment, "kafka.consumer.");
    Map<String, Object> subProperties = resolver.getSubProperties("");
    if(subProperties != null && !subProperties.isEmpty()){
        configs.putAll(subProperties);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LoggingSystemProperties.java   
public void apply(LogFile logFile) {
    RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(
            this.environment, "logging.");
    setSystemProperty(propertyResolver, EXCEPTION_CONVERSION_WORD,
            "exception-conversion-word");
    setSystemProperty(propertyResolver, CONSOLE_LOG_PATTERN, "pattern.console");
    setSystemProperty(propertyResolver, FILE_LOG_PATTERN, "pattern.file");
    setSystemProperty(propertyResolver, LOG_LEVEL_PATTERN, "pattern.level");
    setSystemProperty(PID_KEY, new ApplicationPid().toString());
    if (logFile != null) {
        logFile.applyToSystemProperties();
    }
}
项目:spring-boot-concourse    文件:LocalDebugPortAvailableCondition.java   
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
        AnnotatedTypeMetadata metadata) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            context.getEnvironment(), "spring.devtools.remote.debug.");
    Integer port = resolver.getProperty("local-port", Integer.class);
    if (port == null) {
        port = RemoteDevToolsProperties.Debug.DEFAULT_LOCAL_PORT;
    }
    if (isPortAvailable(port)) {
        return ConditionOutcome.match("Local debug port available");
    }
    return ConditionOutcome.noMatch("Local debug port unavailable");
}
项目:spring-boot-concourse    文件:ThymeleafTemplateAvailabilityProvider.java   
@Override
public boolean isTemplateAvailable(String view, Environment environment,
        ClassLoader classLoader, ResourceLoader resourceLoader) {
    if (ClassUtils.isPresent("org.thymeleaf.spring4.SpringTemplateEngine",
            classLoader)) {
        PropertyResolver resolver = new RelaxedPropertyResolver(environment,
                "spring.thymeleaf.");
        String prefix = resolver.getProperty("prefix",
                ThymeleafProperties.DEFAULT_PREFIX);
        String suffix = resolver.getProperty("suffix",
                ThymeleafProperties.DEFAULT_SUFFIX);
        return resourceLoader.getResource(prefix + view + suffix).exists();
    }
    return false;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LoggingApplicationListener.java   
private void registerShutdownHookIfNecessary(Environment environment,
        LoggingSystem loggingSystem) {
    boolean registerShutdownHook = new RelaxedPropertyResolver(environment)
            .getProperty(REGISTER_SHUTDOWN_HOOK_PROPERTY, Boolean.class, false);
    if (registerShutdownHook) {
        Runnable shutdownHandler = loggingSystem.getShutdownHandler();
        if (shutdownHandler != null
                && shutdownHookRegistered.compareAndSet(false, true)) {
            registerShutdownHook(new Thread(shutdownHandler));
        }
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AnsiOutputApplicationListener.java   
@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));
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigFileApplicationListener.java   
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());
    }
}
项目:spring-boot-concourse    文件:OnEnabledEndpointCondition.java   
private ConditionOutcome determineAllEndpointsOutcome(ConditionContext context) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            context.getEnvironment(), "endpoints.");
    boolean match = Boolean.valueOf(resolver.getProperty("enabled", "true"));
    return new ConditionOutcome(match,
            "All endpoints are " + (match ? "enabled" : "disabled") + " by default");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OnEnabledEndpointElementCondition.java   
protected ConditionOutcome getEndpointOutcome(ConditionContext context,
        String endpointName) {
    RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
            context.getEnvironment(), this.prefix + endpointName + ".");
    if (resolver.containsProperty("enabled")) {
        boolean match = resolver.getProperty("enabled", Boolean.class, true);
        return new ConditionOutcome(match,
                getEndpointElementOutcomeMessage(endpointName, match));
    }
    return null;
}