Java Code Examples for com.typesafe.config.ConfigFactory#parseURL()

The following examples show how to use com.typesafe.config.ConfigFactory#parseURL() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DrillSqlLineApplication.java    From Bats with Apache License 2.0 6 votes vote down vote up
private Config loadConfig(String configName) {
  Set<URL> urls = ClassPathScanner.forResource(configName, false);
  if (urls.size() != 1) {
    if (logger.isDebugEnabled()) {
      urls.forEach(
          u -> logger.debug("Found duplicating [{}]: [{}].", configName, u.getPath())
      );
    }
    return ConfigFactory.empty();
  }

  URL url = urls.iterator().next();
  try {
    logger.debug("Parsing [{}] for the url: [{}].", configName, url.getPath());
    return ConfigFactory.parseURL(url);
  } catch (Exception e) {
    logger.warn("Was unable to parse [{}].", url.getPath(), e);
    return ConfigFactory.empty();
  }
}
 
Example 2
Source File: SqlLineApplication.java    From Lealone-Plugins with Apache License 2.0 5 votes vote down vote up
private Config loadConfig(String configName) {
    URL url = SqlLineApplication.class.getClassLoader().getResource(configName);
    if (url == null)
        return ConfigFactory.empty();
    try {
        if (logger.isDebugEnabled())
            logger.debug("Parsing [{}] for the url: [{}].", configName, url.getPath());
        return ConfigFactory.parseURL(url);
    } catch (Exception e) {
        logger.warn("Was unable to parse [{}].", url.getPath(), e);
        return ConfigFactory.empty();
    }
}
 
Example 3
Source File: IntegrationBasicSuite.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
protected Config getClusterConfig() {
  URL url = Resources.getResource("BasicCluster.conf");
  Config config = ConfigFactory.parseURL(url);

  Map<String, String> configMap = new HashMap<>();
  String zkConnectionString = this.testingZKServer.getConnectString();
  configMap.put(GobblinClusterConfigurationKeys.ZK_CONNECTION_STRING_KEY, zkConnectionString);
  configMap.put(GobblinTaskRunner.CLUSTER_APP_WORK_DIR, this.workPath.toString());
  Config overrideConfig = ConfigFactory.parseMap(configMap);

  return overrideConfig.withFallback(config);
}
 
Example 4
Source File: IntegrationBasicSuite.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
public Config getManagerConfig() {
  // manager config initialization
  URL url = Resources.getResource("BasicManager.conf");
  Config managerConfig = ConfigFactory.parseURL(url);
  managerConfig = managerConfig.withFallback(getClusterConfig());
  return managerConfig.resolve();
}
 
Example 5
Source File: IntegrationBasicSuite.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
protected Collection<Config> getWorkerConfigs() {
  // worker config initialization
  URL url = Resources.getResource("BasicWorker.conf");
  Config workerConfig = ConfigFactory.parseURL(url);
  workerConfig = workerConfig.withFallback(getClusterConfig());
  return Lists.newArrayList(workerConfig.resolve());
}
 
Example 6
Source File: IntegrationDedicatedTaskDriverClusterSuite.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
@Override
protected Collection<Config> getTaskDriverConfigs() {
  // task driver config initialization
  URL url = Resources.getResource("BasicTaskDriver.conf");
  Config taskDriverConfig = ConfigFactory.parseURL(url);
  taskDriverConfig = taskDriverConfig.withFallback(getClusterConfig());
  Config taskDriver1 = addInstanceName(taskDriverConfig, "TaskDriver1");
  return ImmutableList.of(taskDriver1);
}
 
Example 7
Source File: StreamsConfigurator.java    From streams with Apache License 2.0 5 votes vote down vote up
public static Config resolveConfig(String configUrl) throws MalformedURLException {
  URL url = new URL(configUrl);
  Config urlConfig = ConfigFactory.parseURL(url);
  urlConfig.resolve();
  config = urlConfig;
  return config;
}