use of org.springframework.beans.factory.config.YamlPropertiesFactoryBean in project alien4cloud by alien4cloud.
the class FullApplicationConfiguration method properties.
@Bean
public static PropertySourcesPlaceholderConfigurer properties(ResourceLoader resourceLoader) {
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
YamlPropertiesFactoryBean yaml = AlienYamlPropertiesFactoryBeanFactory.get(resourceLoader);
propertySourcesPlaceholderConfigurer.setProperties(yaml.getObject());
return propertySourcesPlaceholderConfigurer;
}
use of org.springframework.beans.factory.config.YamlPropertiesFactoryBean in project java-chassis by ServiceComb.
the class ConfigConverter method createFileSource.
private Map<String, Object> createFileSource(Object v) {
YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean();
yamlFactory.setResources(new ByteArrayResource(v.toString().getBytes(Charset.forName("UTF-8"))));
return propertiesToMap(yamlFactory.getObject());
}
use of org.springframework.beans.factory.config.YamlPropertiesFactoryBean in project java-chassis by ServiceComb.
the class KieClient method processValueType.
private Map<String, Object> processValueType(KVDoc kvDoc) {
ValueType valueType;
try {
valueType = ValueType.valueOf(kvDoc.getValueType());
} catch (IllegalArgumentException e) {
throw new OperationException("value type not support");
}
Properties properties = new Properties();
Map<String, Object> kvMap = new HashMap<>();
try {
switch(valueType) {
case yml:
case yaml:
YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean();
yamlFactory.setResources(new ByteArrayResource(kvDoc.getValue().getBytes()));
return toMap(yamlFactory.getObject());
case properties:
properties.load(new StringReader(kvDoc.getValue()));
return toMap(properties);
case text:
case string:
default:
kvMap.put(kvDoc.getKey(), kvDoc.getValue());
return kvMap;
}
} catch (Exception e) {
LOGGER.error("read config failed");
}
return Collections.emptyMap();
}
use of org.springframework.beans.factory.config.YamlPropertiesFactoryBean in project java-chassis by ServiceComb.
the class YamlParser method parse.
@Override
public Map<String, Object> parse(String content, String prefix, boolean addPrefix) {
YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean();
yamlFactory.setResources(new ByteArrayResource(content.getBytes()));
Properties properties = yamlFactory.getObject();
return Parser.propertiesToMap(properties, prefix, addPrefix);
}
use of org.springframework.beans.factory.config.YamlPropertiesFactoryBean in project gravitee-gateway by gravitee-io.
the class PropertiesConfiguration method graviteeProperties.
@Bean(name = "graviteeProperties")
public static Properties graviteeProperties() throws IOException {
LOGGER.info("Loading Gravitee configuration.");
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
String yamlConfiguration = System.getProperty(GRAVITEE_CONFIGURATION);
Resource yamlResource = new FileSystemResource(yamlConfiguration);
LOGGER.info("\tGravitee configuration loaded from {}", yamlResource.getURL().getPath());
yaml.setResources(yamlResource);
Properties properties = yaml.getObject();
LOGGER.info("Loading Gravitee configuration. DONE");
return properties;
}
Aggregations