org.apache.tinkerpop.gremlin.util.config.YamlConfiguration.load()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中org.apache.tinkerpop.gremlin.util.config.YamlConfiguration.load()方法的一些代码示例,展示了YamlConfiguration.load()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlConfiguration.load()方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.util.config.YamlConfiguration
类名称:YamlConfiguration
方法名:load

YamlConfiguration.load介绍

暂无

代码示例

代码示例来源:origin: apache/tinkerpop

private static Configuration getConfiguration(final File configurationFile) {
    if (!configurationFile.isFile())
      throw new IllegalArgumentException(String.format("The location configuration must resolve to a file and [%s] does not", configurationFile));

    try {
      final String fileName = configurationFile.getName();
      final String fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1);

      switch (fileExtension) {
        case "yml":
        case "yaml":
          final YamlConfiguration config = new YamlConfiguration();
          config.load(configurationFile);
          return config;
        case "xml":
          return new XMLConfiguration(configurationFile);
        default:
          return new PropertiesConfiguration(configurationFile);
      }
    } catch (final ConfigurationException e) {
      throw new IllegalArgumentException(String.format("Could not load configuration at: %s", configurationFile), e);
    }
  }
}

代码示例来源:origin: hugegraph/hugegraph

public static void main(String[] args)
          throws ConfigurationException, InterruptedException {
  E.checkArgument(args.length == 1,
          "Init store only accept one config file.");
  E.checkArgument(args[0].endsWith(".yaml"),
          "Init store only accept yaml config file.");
  String confFile = args[0];
  RegisterUtil.registerBackends();
  YamlConfiguration config = new YamlConfiguration();
  config.load(confFile);
  List<ConfigurationNode> nodes = config.getRootNode()
                     .getChildren(GRAPHS);
  E.checkArgument(nodes.size() == 1,
          "Must contain one '%s' in config file '%s'",
          GRAPHS, confFile);
  List<ConfigurationNode> graphNames = nodes.get(0).getChildren();
  E.checkArgument(!graphNames.isEmpty(),
          "Must contain at least one graph");
  for (ConfigurationNode graphName : graphNames) {
    String configPath = graphName.getValue().toString();
    initGraph(configPath);
  }
  HugeGraph.shutdown(30L);
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

private static Configuration getConfiguration(final File configurationFile) {
    if (!configurationFile.isFile())
      throw new IllegalArgumentException(String.format("The location configuration must resolve to a file and [%s] does not", configurationFile));

    try {
      final String fileName = configurationFile.getName();
      final String fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1);

      switch (fileExtension) {
        case "yml":
        case "yaml":
          final YamlConfiguration config = new YamlConfiguration();
          config.load(configurationFile);
          return config;
        case "xml":
          return new XMLConfiguration(configurationFile);
        default:
          return new PropertiesConfiguration(configurationFile);
      }
    } catch (final ConfigurationException e) {
      throw new IllegalArgumentException(String.format("Could not load configuration at: %s", configurationFile), e);
    }
  }
}

相关文章