当前位置: 首页>>代码示例>>Java>>正文


Java Yaml.load方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml.load方法的典型用法代码示例。如果您正苦于以下问题:Java Yaml.load方法的具体用法?Java Yaml.load怎么用?Java Yaml.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml的用法示例。


在下文中一共展示了Yaml.load方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readConfiguration

import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; //导入方法依赖的package包/类
private void readConfiguration() throws SnoopEEConfigurationException {

        Map<String, Object> snoopConfig = Collections.EMPTY_MAP;
        try {
            Yaml yaml = new Yaml();
            Map<String, Object> props = (Map<String, Object>) yaml.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("/snoopee.yml"));
            snoopConfig = (Map<String, Object>) props.get("snoopee");

        } catch (YAMLException e) {
            LOGGER.config(() -> "No configuration file. Using env properties.");
        }

        applicationConfig.setServiceName(SnoopEEExtensionHelper.getServiceName());
        final String host = readProperty("host", snoopConfig);
        final String port = readProperty("port", snoopConfig);
        applicationConfig.setServiceHome(host + ":" + port + "/");
        applicationConfig.setServiceRoot(readProperty("serviceRoot", snoopConfig));

        LOGGER.config(() -> "application config: " + applicationConfig.toJSON());

        serviceUrl = "ws://" + readProperty("snoopeeService", snoopConfig);
    }
 
开发者ID:ivargrimstad,项目名称:snoopee,代码行数:23,代码来源:SnoopEERegistrationClient.java

示例2: init

import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; //导入方法依赖的package包/类
/**
 * Initializes the producer with the SnoopEE configuration properties.
 */
@PostConstruct
private void init() {

    try {
        Yaml yaml = new Yaml();
        Map<String, Object> props = (Map<String, Object>) yaml.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("/snoopee.yml"));

        snoopeeConfig = (Map<String, Object>) props.get("snoopee");

        if (!SnoopEEExtensionHelper.isSnoopEnabled()) {
            SnoopEEExtensionHelper.setServiceName(readProperty("serviceName", snoopeeConfig));
        }

    } catch (YAMLException e) {
        LOGGER.config(() -> "No configuration file. Using env properties.");
    }
}
 
开发者ID:ivargrimstad,项目名称:snoopee,代码行数:21,代码来源:SnoopEEProducer.java

示例3: readConfiguration

import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; //导入方法依赖的package包/类
private void readConfiguration() throws SnoopEEConfigurationException {

        Map<String, Object> snoopConfig = Collections.EMPTY_MAP;
        try {
            Yaml yaml = new Yaml();
            Map<String, Object> props = (Map<String, Object>) yaml.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("/snoopee.yml"));

            snoopConfig = (Map<String, Object>) props.get("snoopee");

        } catch (YAMLException e) {
            LOGGER.config(() -> "No configuration file. Using env properties.");
        }

        applicationConfig.setServiceName(SnoopEEExtensionHelper.getServiceName());
        final String host = readProperty("host", snoopConfig);
        final String port = readProperty("port", snoopConfig);
        applicationConfig.setServiceHome(host + ":" + port + "/");
        applicationConfig.setServiceRoot(readProperty("serviceRoot", snoopConfig));

        LOGGER.config(() -> "application config: " + applicationConfig.toJSON());

        serviceUrl = "http://" + readProperty("snoopeeService", snoopConfig);
    }
 
开发者ID:ivargrimstad,项目名称:snoopee,代码行数:24,代码来源:SnoopEERegistrationClient.java

示例4: readConfiguration

import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; //导入方法依赖的package包/类
private void readConfiguration() throws SnoopConfigurationException {

        Map<String, Object> snoopConfig = Collections.EMPTY_MAP;
        try {
            Yaml yaml = new Yaml();
            Map<String, Object> props = (Map<String, Object>) yaml.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("/snoop.yml"));

            snoopConfig = (Map<String, Object>) props.get("snoop");

        } catch (YAMLException e) {
            LOGGER.config(() -> "No configuration file. Using env properties.");
        }

        applicationConfig.setServiceName(SnoopExtensionHelper.getServiceName());
        final String host = readProperty("host", snoopConfig);
        final String port = readProperty("port", snoopConfig);
        applicationConfig.setServiceHome(host + ":" + port + "/");
        applicationConfig.setServiceRoot(readProperty("serviceRoot", snoopConfig));

        LOGGER.config(() -> "application config: " + applicationConfig.toJSON());

        serviceUrl = "ws://" + readProperty("snoopService", snoopConfig);
    }
 
开发者ID:ivargrimstad,项目名称:snoop,代码行数:24,代码来源:SnoopRegistrationClient.java

示例5: readProperties

import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; //导入方法依赖的package包/类
private void readProperties() {
   Yaml yaml = new Yaml();
   Map<String, Object> props = (Map<String, Object>) yaml.load(this.getClass().getResourceAsStream("/application.yml"));

   Map<String, String> snoopConfig = (Map<String, String>) props.get("snoop");

   applicationName = snoopConfig.get("applicationName");
   applicationHome = snoopConfig.get("applicationHome");

   LOGGER.config(() -> "application name: " + applicationName);
   
   Map<String, Object> eurekaProps = (Map<String, Object>) props.get("eureka");
   Map<String, Object> eurekaClientProps = (Map<String, Object>) eurekaProps.get("client");
   Map<String, String> eurekaServiceProps = (Map<String, String>) eurekaClientProps.get("serviceUrl");

   serviceUrl = eurekaServiceProps.get("deafaultZone") != null ? snoopConfig.get("defaultZone") : DEFAULT_SERVICE_URI;
}
 
开发者ID:ivargrimstad,项目名称:snoop,代码行数:18,代码来源:EurekaClient.java

示例6: init

import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; //导入方法依赖的package包/类
/**
 * Initializes the producer with the Snoop configuration properties.
 */
@PostConstruct
private void init() {

    try {
        Yaml yaml = new Yaml();
        Map<String, Object> props = (Map<String, Object>) yaml.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("/snoop.yml"));

        snoopConfig = (Map<String, Object>) props.get("snoop");

    } catch (YAMLException e) {
        LOGGER.config(() -> "No configuration file. Using env properties.");
    }
}
 
开发者ID:ivargrimstad,项目名称:snoop,代码行数:17,代码来源:SnoopProducer.java

示例7: modifyCassandraYaml

import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static void modifyCassandraYaml(
    @NotNull final Marker taskIdMarker,
    @NotNull final String version,
    @NotNull final CassandraServerConfig cassandraServerConfig
) throws IOException {
    LOGGER.info(taskIdMarker, "Building cassandra.yaml");

    final File cassandraYaml = new File("apache-cassandra-" + version + "/conf/cassandra.yaml");

    final Yaml yaml = new Yaml();
    final Map<String, Object> yamlMap;
    LOGGER.info(taskIdMarker, "Reading cassandra.yaml");
    try (BufferedReader br = new BufferedReader(new FileReader(cassandraYaml))) {
        yamlMap = (Map<String, Object>) yaml.load(br);
    }
    LOGGER.info(taskIdMarker, "Modifying cassandra.yaml");
    for (final TaskConfig.Entry entry : cassandraServerConfig.getCassandraYamlConfig().getVariablesList()) {
        switch (entry.getName()) {
            case "seeds":
                final List<Map<String, Object>> seedProviderList = (List<Map<String, Object>>) yamlMap.get("seed_provider");
                final Map<String, Object> seedProviderMap = seedProviderList.get(0);
                final List<Map<String, Object>> parameters = (List<Map<String, Object>>) seedProviderMap.get("parameters");
                final Map<String, Object> parametersMap = parameters.get(0);
                parametersMap.put("seeds", entry.getStringValue());
                break;
            default:
                if (entry.hasStringValue()) {
                    yamlMap.put(entry.getName(), entry.getStringValue());
                } else if (entry.hasLongValue()) {
                    yamlMap.put(entry.getName(), entry.getLongValue());
                } else if (!entry.getStringValuesList().isEmpty()) {
                    yamlMap.put(entry.getName(), entry.getStringValuesList());
                }
        }
    }
    if (LOGGER.isDebugEnabled()) {
        final StringWriter sw = new StringWriter();
        yaml.dump(yamlMap, sw);
        LOGGER.debug("cassandra.yaml result: {}", sw);
    }
    LOGGER.info(taskIdMarker, "Writing cassandra.yaml");
    try (BufferedWriter bw = new BufferedWriter(new FileWriter(cassandraYaml))) {
        yaml.dump(yamlMap, bw);
    }
}
 
开发者ID:mesosphere,项目名称:cassandra-mesos-deprecated,代码行数:47,代码来源:ProdObjectFactory.java


注:本文中的com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。