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

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OnEnabledResourceChainCondition.java   
@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"));
}
项目:spring-boot-concourse    文件:OnEnabledResourceChainCondition.java   
@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"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EnableAutoConfigurationImportSelector.java   
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));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MustacheEnvironmentCollector.java   
@Override
public void setEnvironment(Environment environment) {
    this.environment = (ConfigurableEnvironment) environment;
    this.target = new HashMap<String, Object>();
    new RelaxedDataBinder(this.target).bind(
            new PropertySourcesPropertyValues(this.environment.getPropertySources()));
    this.propertyResolver = new RelaxedPropertyResolver(environment);
}
项目:spring-boot-concourse    文件:EnableAutoConfigurationImportSelector.java   
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));
}
项目:spring-boot-concourse    文件:MustacheEnvironmentCollector.java   
@Override
public void setEnvironment(Environment environment) {
    this.environment = (ConfigurableEnvironment) environment;
    this.target = new HashMap<String, Object>();
    new RelaxedDataBinder(this.target).bind(
            new PropertySourcesPropertyValues(this.environment.getPropertySources()));
    this.propertyResolver = new RelaxedPropertyResolver(environment);
}
项目:contestparser    文件:OnEnabledResourceChainCondition.java   
@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();
    return new ConditionOutcome(match,
            "Resource chain is " + (match ? "enabled" : "disabled"));
}
项目:contestparser    文件:MustacheEnvironmentCollector.java   
@Override
public void setEnvironment(Environment environment) {
    this.environment = (ConfigurableEnvironment) environment;
    this.target = new HashMap<String, Object>();
    new RelaxedDataBinder(this.target).bind(
            new PropertySourcesPropertyValues(this.environment.getPropertySources()));
    this.propertyResolver = new RelaxedPropertyResolver(environment);
}
项目:spring-cloud-config-support    文件:CloudConfigSupportConfiguration.java   
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
    if (!isHasCloudConfigLocator(this.propertySourceLocators)) {
        logger.info("未启用Config Server管理配置");
        return;
    }


    logger.info("检查Config Service配置资源");

    ConfigurableEnvironment environment = applicationContext.getEnvironment();

    MutablePropertySources propertySources = environment.getPropertySources();
    logger.info("加载PropertySources源:" + propertySources.size() + "个");

    CloudConfigSupportProperties configSupportProperties = new CloudConfigSupportProperties();
    new RelaxedDataBinder(configSupportProperties, CloudConfigSupportProperties.CONFIG_PREFIX)
            .bind(new PropertySourcesPropertyValues(propertySources));
    if (!configSupportProperties.isEnable()) {
        logger.warn("未启用配置备份功能,可使用{}.enable打开", CloudConfigSupportProperties.CONFIG_PREFIX);
        return;
    }


    if (isCloudConfigLoaded(propertySources)) {
        PropertySource cloudConfigSource = getLoadedCloudPropertySource(propertySources);
        logger.info("成功获取ConfigService配置资源");
        //备份
        Map<String, Object> backupPropertyMap = makeBackupPropertyMap(cloudConfigSource);
        doBackup(backupPropertyMap, configSupportProperties.getFile());

    } else {
        logger.error("获取ConfigService配置资源失败");

        Properties backupProperty = loadBackupProperty(configSupportProperties.getFile());
        if (backupProperty != null) {
            HashMap backupSourceMap = new HashMap<>(backupProperty);

            PropertySource backupSource = new MapPropertySource("backupSource", backupSourceMap);
            propertySources.addFirst(backupSource);
            logger.warn("使用备份的配置启动:{}", configSupportProperties.getFile());
        }
    }
}
项目:java-restify    文件:RestifyApiClientProperties.java   
public RestifyApiClient client(RestifyableType type) {
    RestifyApiClient restifyApiClient = new RestifyApiClient();

    RelaxedDataBinder dataBinder = new RelaxedDataBinder(restifyApiClient, "restify." + type.name());

    ConfigurableEnvironment configurableEnvironment = (ConfigurableEnvironment) environment;
    dataBinder.bind(new PropertySourcesPropertyValues(configurableEnvironment.getPropertySources()));

    return restifyApiClient;
}