Search in sources :

Example 1 with YamlPropertiesFactoryBean

use of org.springframework.beans.factory.config.YamlPropertiesFactoryBean in project cas by apereo.

the class CasCoreBootstrapStandaloneConfiguration method loadYamlProperties.

private Map loadYamlProperties(final Resource... resource) {
    final YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
    factory.setResolutionMethod(YamlProcessor.ResolutionMethod.OVERRIDE);
    factory.setResources(resource);
    factory.setSingleton(true);
    factory.afterPropertiesSet();
    return factory.getObject();
}
Also used : YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean)

Example 2 with YamlPropertiesFactoryBean

use of org.springframework.beans.factory.config.YamlPropertiesFactoryBean in project cas by apereo.

the class DefaultCasConfigurationPropertiesSourceLocator method loadYamlProperties.

private static Map loadYamlProperties(final Resource... resource) {
    final YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
    factory.setResolutionMethod(YamlProcessor.ResolutionMethod.OVERRIDE);
    factory.setResources(resource);
    factory.setSingleton(true);
    factory.afterPropertiesSet();
    return factory.getObject();
}
Also used : YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean)

Example 3 with YamlPropertiesFactoryBean

use of org.springframework.beans.factory.config.YamlPropertiesFactoryBean in project cas by apereo.

the class AddPropertiesToConfigurationCommand method loadYamlPropertiesFromConfigurationFile.

private Properties loadYamlPropertiesFromConfigurationFile(final File filePath) {
    final YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
    factory.setResolutionMethod(YamlProcessor.ResolutionMethod.OVERRIDE);
    factory.setResources(new FileSystemResource(filePath));
    factory.setSingleton(true);
    factory.afterPropertiesSet();
    return factory.getObject();
}
Also used : YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean) FileSystemResource(org.springframework.core.io.FileSystemResource)

Example 4 with YamlPropertiesFactoryBean

use of org.springframework.beans.factory.config.YamlPropertiesFactoryBean in project gravitee-management-rest-api by gravitee-io.

the class PropertiesConfiguration method graviteeProperties.

@Bean(name = "graviteeProperties")
public static Properties graviteeProperties() throws IOException {
    LOGGER.info("Loading Gravitee Management configuration.");
    YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
    String yamlConfiguration = System.getProperty(GRAVITEE_CONFIGURATION);
    Resource yamlResource = new FileSystemResource(yamlConfiguration);
    LOGGER.info("\tGravitee Management configuration loaded from {}", yamlResource.getURL().getPath());
    yaml.setResources(yamlResource);
    Properties properties = yaml.getObject();
    LOGGER.info("Loading Gravitee Management configuration. DONE");
    return properties;
}
Also used : FileSystemResource(org.springframework.core.io.FileSystemResource) Resource(org.springframework.core.io.Resource) YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean) FileSystemResource(org.springframework.core.io.FileSystemResource) Properties(java.util.Properties) YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 5 with YamlPropertiesFactoryBean

use of org.springframework.beans.factory.config.YamlPropertiesFactoryBean in project alien4cloud by alien4cloud.

the class AlienYamlPropertiesFactoryBeanFactory method get.

/**
 * Get a singleton instance of {@link YamlPropertiesFactoryBean}.
 *
 * @param resourceLoader The loader to use to find the yaml file.
 * @return an instance of the {@link YamlPropertiesFactoryBean}.
 */
public static YamlPropertiesFactoryBean get(ResourceLoader resourceLoader) {
    if (INSTANCE == null) {
        for (String searchLocation : SEARCH_LOCATIONS) {
            Resource resource = resourceLoader.getResource(searchLocation + ALIEN_CONFIGURATION_YAML);
            if (resource != null && resource.exists()) {
                log.info("Loading Alien 4 Cloud configuration from {}", resource.getDescription());
                INSTANCE = new YamlPropertiesFactoryBean();
                INSTANCE.setResources(new Resource[] { resource });
                return INSTANCE;
            }
        }
    }
    return INSTANCE;
}
Also used : Resource(org.springframework.core.io.Resource) YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean)

Aggregations

YamlPropertiesFactoryBean (org.springframework.beans.factory.config.YamlPropertiesFactoryBean)17 Properties (java.util.Properties)6 Bean (org.springframework.context.annotation.Bean)5 ByteArrayResource (org.springframework.core.io.ByteArrayResource)5 Resource (org.springframework.core.io.Resource)4 PropertySourcesPlaceholderConfigurer (org.springframework.context.support.PropertySourcesPlaceholderConfigurer)3 FileSystemResource (org.springframework.core.io.FileSystemResource)3 Map (java.util.Map)2 ClassPathResource (org.springframework.core.io.ClassPathResource)2 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 HashMap (java.util.HashMap)1 lombok.val (lombok.val)1 OperationException (org.apache.servicecomb.config.kie.client.exception.OperationException)1 ValueType (org.apache.servicecomb.config.kie.client.model.ValueType)1 Environment (org.springframework.cloud.config.environment.Environment)1 PropertySource (org.springframework.cloud.config.environment.PropertySource)1 EncodedResource (org.springframework.core.io.support.EncodedResource)1