Java 类org.springframework.beans.factory.config.YamlMapFactoryBean 实例源码

项目:mustache-showcase    文件:LayoutMapperTest.java   
@BeforeClass
    public static void setUp() throws Exception {
        layoutMapper = new LayoutMapper();
        YamlMapFactoryBean yamlMapFactoryBean = new YamlMapFactoryBean();
        yamlMapFactoryBean.setResources(new FileSystemResource(LayoutMapperTest.class.getResource("layout.yml").getPath()));
//        String layout = "" +
//                "category:\n" +
//                "  _default_: \"category/_layout\"\n" +
//                "food:\n" +
//                "  detail: \"food/_layout\"\n" +
//                "boo:\n" +
//                "  _default_: \"boo/_layout\"\n" +
//                "  index: \"_boo\"\n" +
//                "  foo:\n" +
//                "    detail: \"boo/_detail\"" +
//                "";
//        yamlMapFactoryBean.setResources(new ByteArrayResource(layout.getBytes("UTF-8")));
        yamlMapFactoryBean.afterPropertiesSet();
        ReflectionTestUtils.setField(layoutMapper, "layout", yamlMapFactoryBean.getObject());
        ReflectionTestUtils.invokeMethod(layoutMapper, "init");
    }
项目:spring-cloud-stream-binder-ibm-mq    文件:IBMMQTestUtils.java   
@SuppressWarnings("unchecked")
public static IBMMQConfigurationProperties getIBMMQProperties() throws Exception {
    YamlMapFactoryBean factoryBean = new YamlMapFactoryBean();
    factoryBean.setResources(new ClassPathResource("application.yml"));

    Map<String, Object> mapObject = factoryBean.getObject();
    Map<String, Object> ibmMQPropertyMap = (Map<String, Object>) mapObject
            .get("ibmmq");

    IBMMQConfigurationProperties configurationProperties = new IBMMQConfigurationProperties();
    configurationProperties.setHost((String) ibmMQPropertyMap.get("host"));
    configurationProperties.setPort((Integer) ibmMQPropertyMap.get("port"));
    configurationProperties
            .setUsername((String) ibmMQPropertyMap.get("username"));
    configurationProperties
            .setPassword((String) ibmMQPropertyMap.get("password"));
    configurationProperties
            .setQueueManager((String) ibmMQPropertyMap.get("queueManager"));
    configurationProperties
            .setChannel((String) ibmMQPropertyMap.get("channel"));

    return configurationProperties;
}
项目:micro-service-netflix    文件:YamlUtils.java   
public static Map<String, Object> convertYamlToMap(String yamlFile) {

    YamlMapFactoryBean yamlMapFactoryBean = new YamlMapFactoryBean();
    yamlMapFactoryBean.setResources(new ClassPathResource(yamlFile));
    yamlMapFactoryBean.setResolutionMethod(ResolutionMethod.FIRST_FOUND);

    return yamlMapFactoryBean.getObject();
}
项目:dcmp    文件:Config.java   
@SuppressWarnings("unchecked")
public Config() {
    YamlMapFactoryBean yamlMapFactoryBean = new YamlMapFactoryBean();
    yamlMapFactoryBean.setResources(new ClassPathResource("config.yml"));

    this.dataMap = (Map<String, Object>) yamlMapFactoryBean.getObject().get("config");
    this.consulMap = (Map<String, Object>) this.dataMap.get("consul");
    this.repoMap = (Map<String, Object>) this.dataMap.get("repo");
}