org.apache.commons.configuration2.builder.fluent.Parameters.properties()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(13.1k)|赞(0)|评价(0)|浏览(129)

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

Parameters.properties介绍

[英]Creates a new instance of a parameters object for properties configurations.
[中]为属性配置创建参数对象的新实例。

代码示例

代码示例来源:origin: goldmansachs/obevo

public static DbDataComparisonConfig createFromProperties(String path) {
  try {
    URL url = DbDataComparisonConfigFactory.class.getClassLoader().getResource(path);
    if (url == null) {
      url = new File(path).toURI().toURL();
    }
    if (url == null) {
      throw new IllegalArgumentException("Could not find resource or file at path: " + path);
    }
    return createFromProperties(new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class).configure(new Parameters().properties()
        .setURL(url)
        .setListDelimiterHandler(new LegacyListDelimiterHandler(','))
    ).getConfiguration());
  } catch (ConfigurationException e) {
    throw new RuntimeException(e);
  } catch (MalformedURLException e) {
    throw new IllegalArgumentException("Could not find resource or file at path: " + path, e);
  }
}

代码示例来源:origin: com.goldmansachs.obevo/obevo-db

public static DbDataComparisonConfig createFromProperties(String path) {
  try {
    URL url = DbDataComparisonConfigFactory.class.getClassLoader().getResource(path);
    if (url == null) {
      url = new File(path).toURI().toURL();
    }
    if (url == null) {
      throw new IllegalArgumentException("Could not find resource or file at path: " + path);
    }
    return createFromProperties(new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class).configure(new Parameters().properties()
        .setURL(url)
        .setListDelimiterHandler(new LegacyListDelimiterHandler(','))
    ).getConfiguration());
  } catch (ConfigurationException e) {
    throw new RuntimeException(e);
  } catch (MalformedURLException e) {
    throw new IllegalArgumentException("Could not find resource or file at path: " + path, e);
  }
}

代码示例来源:origin: ga4gh/dockstore

/**
 * The singleton map os not entirely awesome, but this allows our legacy code to
 * benefit from live reloads for configuration while the application is running
 *
 * @param configFile the path to the config file which should be loaded
 * @return configuration file
 */
public static INIConfiguration parseConfig(String configFile) {
  if (!MAP.containsKey(configFile)) {
    ReloadingFileBasedConfigurationBuilder<INIConfiguration> builder = new ReloadingFileBasedConfigurationBuilder<>(
        INIConfiguration.class).configure(new Parameters().properties().setFileName(configFile));
    PeriodicReloadingTrigger trigger = new PeriodicReloadingTrigger(builder.getReloadingController(), null, 1, TimeUnit.MINUTES);
    trigger.start();
    MAP.put(configFile, builder);
  }
  try {
    return MAP.get(configFile).getConfiguration();
  } catch (ConfigurationException ex) {
    throw new RuntimeException("Could not read " + configFile);
  }
}

代码示例来源:origin: com.qaprosoft/zafira-client

config.addConfiguration(new SystemConfiguration());
config.addConfiguration(new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
               .configure(new Parameters().properties().setFileName(ZAFIRA_PROPERTIES)).getConfiguration());

代码示例来源:origin: qaprosoft/zafira

config.addConfiguration(new SystemConfiguration());
config.addConfiguration(new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
               .configure(new Parameters().properties().setFileName(ZAFIRA_PROPERTIES)).getConfiguration());

代码示例来源:origin: org.xwiki.platform/xwiki-platform-configuration-default

this.logger.info("loading {} from default location {}", XWIKI_PROPERTIES_FILE, file.getCanonicalPath());
return new FileBasedConfigurationBuilder<PropertiesConfiguration>(PropertiesConfiguration.class)
  .configure(new Parameters().properties()
    .setListDelimiterHandler(new DefaultListDelimiterHandler(',')).setFile(file))
  .getConfiguration();
FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
  new FileBasedConfigurationBuilder<PropertiesConfiguration>(PropertiesConfiguration.class)
    .configure(new Parameters().properties()
      .setListDelimiterHandler(new DefaultListDelimiterHandler(',')).setURL(xwikiPropertiesUrl));
return builder.getConfiguration();

代码示例来源:origin: com.cerner.beadledom/beadledom-configuration

private static FileBasedConfiguration createPropertiesConfiguration(Reader reader)
  throws ConfigurationException, IOException {
 if (reader == null) {
  throw new NullPointerException("reader: null");
 }
 FileBasedConfigurationBuilder<FileBasedConfiguration> builder =
   new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
     .configure(new Parameters()
       .properties()
       .setListDelimiterHandler(new DefaultListDelimiterHandler(',')));
 FileBasedConfiguration config = builder.getConfiguration();
 config.read(reader);
 return config;
}

代码示例来源:origin: org.opencadc/cadc-web-util

public ApplicationConfiguration(final String filePath) {
  final CombinedConfiguration combinedConfiguration = new CombinedConfiguration(new MergeCombiner());
  // Prefer System properties.
  combinedConfiguration.addConfiguration(new SystemConfiguration());
  final Parameters parameters = new Parameters();
  final FileBasedConfigurationBuilder builder = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class).configure(parameters.properties()
    .setFileName(filePath));
  try {
    combinedConfiguration.addConfiguration((Configuration) builder.getConfiguration());
  } catch (ConfigurationException var5) {
    LOGGER.warn(String.format("No configuration found at %s.\nUsing defaults.", filePath));
  }
  this.configuration = combinedConfiguration;
}

代码示例来源:origin: com.jkoolcloud/tnt4j

int urlIndex = configName.indexOf("://");
PropertiesBuilderParameters params = new Parameters().properties();

代码示例来源:origin: qaprosoft/carina

private AliceRecognition() {
  try {
    CombinedConfiguration config = new CombinedConfiguration(new MergeCombiner());
    config.addConfiguration(new SystemConfiguration());
    config.addConfiguration(new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
        .configure(new Parameters().properties().setFileName(ALICE_PROPERTIES)).getConfiguration());
    this.enabled = config.getBoolean(ALICE_ENABLED, false);
    String url = config.getString(ALICE_SERVICE_URL, null);
    String accessToken = config.getString(ALICE_ACCESS_TOKEN, null);
    String command = config.getString(ALICE_COMMAND, null);
    if (enabled && !StringUtils.isEmpty(url) && !StringUtils.isEmpty(accessToken)) {
      this.client = new AliceClient(url, command);
      this.client.setAuthToken(accessToken);
      this.enabled = this.client.isAvailable();
    }
  } catch (Exception e) {
    LOGGER.error("Unable to initialize Alice: " + e.getMessage(), e);
  }
};

代码示例来源:origin: com.goldmansachs.obevo/obevo-db

public void execute(DbFileMergerArgs args) {
  Configuration config;
  try {
    config = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class)
        .configure(new Parameters().properties()
            .setFile(args.getDbMergeConfigFile())
            .setListDelimiterHandler(new LegacyListDelimiterHandler(','))
        ).getConfiguration();
  } catch (ConfigurationException e) {
    throw new RuntimeException(e);
  }
  RichIterable<DbMergeInfo> dbMergeInfos = DbMergeInfo.parseFromProperties(config);
  RichIterable<TableSyncSide> tableSyncSides = dbMergeInfos.collect(new Function<DbMergeInfo, TableSyncSide>() {
    @Override
    public TableSyncSide valueOf(DbMergeInfo dbMergeInfo) {
      DataSource ds = ds(dbMergeInfo.getDriverClassName(), dbMergeInfo.getUrl(), dbMergeInfo.getUsername(),
          dbMergeInfo.getPassword());
      return new TableSyncSide(ds, PhysicalSchema.parseFromString(dbMergeInfo.getPhysicalSchema()));
    }
  });
  this.syncSchemaTables(DbPlatformConfiguration.getInstance().valueOf(config.getString("dbType")), tableSyncSides, args.getOutputDir());
}

代码示例来源:origin: goldmansachs/obevo

public void execute(DbFileMergerArgs args) {
  Configuration config;
  try {
    config = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class)
        .configure(new Parameters().properties()
            .setFile(args.getDbMergeConfigFile())
            .setListDelimiterHandler(new LegacyListDelimiterHandler(','))
        ).getConfiguration();
  } catch (ConfigurationException e) {
    throw new RuntimeException(e);
  }
  RichIterable<DbMergeInfo> dbMergeInfos = DbMergeInfo.parseFromProperties(config);
  RichIterable<TableSyncSide> tableSyncSides = dbMergeInfos.collect(new Function<DbMergeInfo, TableSyncSide>() {
    @Override
    public TableSyncSide valueOf(DbMergeInfo dbMergeInfo) {
      DataSource ds = ds(dbMergeInfo.getDriverClassName(), dbMergeInfo.getUrl(), dbMergeInfo.getUsername(),
          dbMergeInfo.getPassword());
      return new TableSyncSide(ds, PhysicalSchema.parseFromString(dbMergeInfo.getPhysicalSchema()));
    }
  });
  this.syncSchemaTables(DbPlatformConfiguration.getInstance().valueOf(config.getString("dbType")), tableSyncSides, args.getOutputDir());
}

代码示例来源:origin: com.goldmansachs.obevo/obevo-db

public void execute(DbFileMergerArgs args) {
  PropertiesConfiguration config;
  RichIterable<DbMergeInfo> dbNameLocationPairs;
  try {
    config = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class)
        .configure(new Parameters().properties()
            .setFile(args.getDbMergeConfigFile())
            .setListDelimiterHandler(new LegacyListDelimiterHandler(','))
        )
        .getConfiguration();
    dbNameLocationPairs = DbMergeInfo.parseFromProperties(config);
  } catch (Exception e) {
    throw new DeployerRuntimeException("Exception reading configs from file " + args.getDbMergeConfigFile(), e);
  }
  DbPlatform dialect = DbPlatformConfiguration.getInstance().valueOf(config.getString("dbType"));
  this.generateDiffs(dialect, dbNameLocationPairs, args.getOutputDir());
}

代码示例来源:origin: com.qaprosoft/zafira-client

ZafiraSingleton() {
  try {
    CombinedConfiguration config = new CombinedConfiguration(new MergeCombiner());
    config.setThrowExceptionOnMissing(false);
    config.addConfiguration(new SystemConfiguration());
    config.addConfiguration(
        new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
            .configure(new Parameters().properties().setFileName(ZAFIRA_PROPERTIES))
            .getConfiguration());
    final boolean enabled = config.getBoolean("zafira_enabled", false);
    final String url = config.getString("zafira_service_url", StringUtils.EMPTY);
    final String token = config.getString("zafira_access_token", StringUtils.EMPTY);
    zc = new ZafiraClient(url);
    if (enabled && zc.isAvailable()) {
      Response<AuthTokenType> auth = zc.refreshToken(token);
      if (auth.getStatus() == 200) {
        zc.setAuthToken(auth.getObject().getType() + " " + auth.getObject().getAccessToken());
        this.running = true;
        this.zc.initAmazonS3Client();
        this.zc.initTenant();
      }
    }
  } catch (Exception e) {
    LOGGER.error(e.getMessage(), e);
  }
}

代码示例来源:origin: qaprosoft/zafira

ZafiraSingleton() {
  try {
    CombinedConfiguration config = new CombinedConfiguration(new MergeCombiner());
    config.setThrowExceptionOnMissing(false);
    config.addConfiguration(new SystemConfiguration());
    config.addConfiguration(
        new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
            .configure(new Parameters().properties().setFileName(ZAFIRA_PROPERTIES))
            .getConfiguration());
    final boolean enabled = config.getBoolean("zafira_enabled", false);
    final String url = config.getString("zafira_service_url", StringUtils.EMPTY);
    final String token = config.getString("zafira_access_token", StringUtils.EMPTY);
    zc = new ZafiraClient(url);
    if (enabled && zc.isAvailable()) {
      Response<AuthTokenType> auth = zc.refreshToken(token);
      if (auth.getStatus() == 200) {
        zc.setAuthToken(auth.getObject().getType() + " " + auth.getObject().getAccessToken());
        this.running = true;
        this.zc.initAmazonS3Client();
        this.zc.initTenant();
      }
    }
  } catch (Exception e) {
    LOGGER.error(e.getMessage(), e);
  }
}

代码示例来源:origin: goldmansachs/obevo

public void execute(DbFileMergerArgs args) {
  PropertiesConfiguration config;
  RichIterable<DbMergeInfo> dbNameLocationPairs;
  try {
    config = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class)
        .configure(new Parameters().properties()
            .setFile(args.getDbMergeConfigFile())
            .setListDelimiterHandler(new LegacyListDelimiterHandler(','))
        )
        .getConfiguration();
    dbNameLocationPairs = DbMergeInfo.parseFromProperties(config);
  } catch (Exception e) {
    throw new DeployerRuntimeException("Exception reading configs from file " + args.getDbMergeConfigFile(), e);
  }
  DbPlatform dialect = DbPlatformConfiguration.getInstance().valueOf(config.getString("dbType"));
  this.generateDiffs(dialect, dbNameLocationPairs, args.getOutputDir());
}

代码示例来源:origin: org.openksavi.sponge/sponge-core

propertiesConfiguration =
    new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class)
        .configure(new Parameters().properties().setLocationStrategy(propertiesLocationStrategy)
            .setFileName(propertiesFileName).setEncoding(Charsets.UTF_8.name()).setThrowExceptionOnMissing(false))
        .getConfiguration();

代码示例来源:origin: com.qaprosoft/zafira-client

config.addConfiguration(new SystemConfiguration());
config.addConfiguration(new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
               .configure(new Parameters().properties().setFileName(ZAFIRA_PROPERTIES)).getConfiguration());

代码示例来源:origin: qaprosoft/zafira

config.addConfiguration(new SystemConfiguration());
config.addConfiguration(new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
               .configure(new Parameters().properties().setFileName(ZAFIRA_PROPERTIES)).getConfiguration());

相关文章