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


Java Configurations类代码示例

本文整理汇总了Java中org.apache.commons.configuration2.builder.fluent.Configurations的典型用法代码示例。如果您正苦于以下问题:Java Configurations类的具体用法?Java Configurations怎么用?Java Configurations使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Configurations类属于org.apache.commons.configuration2.builder.fluent包,在下文中一共展示了Configurations类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: FileBasedSecStoreConfig

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
FileBasedSecStoreConfig(File userFile, File roleFile) throws Exception {
   Configurations configs = new Configurations();
   userBuilder = configs.propertiesBuilder(userFile);
   roleBuilder = configs.propertiesBuilder(roleFile);
   userConfig = userBuilder.getConfiguration();
   roleConfig = roleBuilder.getConfiguration();

   String roleHeader = roleConfig.getLayout().getHeaderComment();
   String userHeader = userConfig.getLayout().getHeaderComment();

   if (userHeader == null) {
      if (userConfig.isEmpty()) {
         //clean and reset header
         userConfig.clear();
         userConfig.setHeader(LICENSE_HEADER);
      }
   }

   if (roleHeader == null) {
      if (roleConfig.isEmpty()) {
         //clean and reset header
         roleConfig.clear();
         roleConfig.setHeader(LICENSE_HEADER);
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:FileBasedSecStoreConfig.java

示例2: init

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
public static void init() throws ConfigurationException {
	configManager = new Configurations();
	builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			.configure(configManager.getParameters().fileBased().setFile(App.appFileUtil.getHotkeysFile()));
	config = builder.getConfiguration();
	loadHotkeys();
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:8,代码来源:HotkeyController.java

示例3: init

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
public static void init(String worldLocation) throws ConfigurationException {
	log.debug("World Location for properties: " + worldLocation);
	configManager = new Configurations();
	if(worldLocation == null){
		builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			.configure(configManager.getParameters().fileBased().setFileName(defaultWorldPropertiesLocation));
	}else
	{
		builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
				.configure(configManager.getParameters().fileBased().setFileName(worldLocation));
	}
	config = builder.getConfiguration();		
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:14,代码来源:WorldConfig.java

示例4: init

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
public static void init() throws ConfigurationException {
	configManager = new Configurations();
	builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			.configure(configManager.getParameters().fileBased().setFile(App.appFileUtil.getAppPropFile()));
	
	config = builder.getConfiguration();		
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:8,代码来源:AppConfig.java

示例5: firstInit

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
public static void firstInit() throws Exception{
	configManager = new Configurations();
	
	builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
			.configure(configManager.getParameters().fileBased().setFileName("src/main/resources/app.properties"));
	
	config = builder.getConfiguration();
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:9,代码来源:AppConfig.java

示例6: get

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
@Override
public Configuration get() {
  Configurations configs = new Configurations();
  try {
    return configs.properties(new File(getPropertyFilePath()));
  } catch (ConfigurationException e) {
    log.error(" error on build configuration", e);
    throw new IllegalStateException(e);
  }
}
 
开发者ID:email2liyang,项目名称:grpc-mate,代码行数:11,代码来源:ConfigurationProvider.java

示例7: Config

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
/**
 * Read config file and store in {@code Config}.
 *
 * @param configFile the config file.
 * @throws ConfigurationException - if an error occurred when loading the configuration
 * @throws BiremeException - wrap and throw Exception which cannot be handled
 */
public Config(String configFile) throws ConfigurationException, BiremeException {
  Configurations configs = new Configurations();
  config = configs.properties(new File(configFile));

  basicConfig();
  connectionConfig("target");
  dataSourceConfig();

  logConfig();
}
 
开发者ID:HashDataInc,项目名称:bireme,代码行数:18,代码来源:Config.java

示例8: fetchTableMap

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
private HashMap<String, String> fetchTableMap(String dataSource)
    throws ConfigurationException, BiremeException {
  Configurations configs = new Configurations();
  Configuration tableConfig = null;

  tableConfig = configs.properties(new File(DEFAULT_TABLEMAP_DIR + dataSource + ".properties"));

  String originTable, mappedTable;
  HashMap<String, String> localTableMap = new HashMap<String, String>();
  Iterator<String> tables = tableConfig.getKeys();

  while (tables.hasNext()) {
    originTable = tables.next();
    mappedTable = tableConfig.getString(originTable);

    if (originTable.split("\\.").length != 2 || mappedTable.split("\\.").length != 2) {
      String message = "Wrong format: " + originTable + ", " + mappedTable;
      logger.fatal(message);
      throw new BiremeException(message);
    }

    localTableMap.put(dataSource + "." + originTable, mappedTable);

    if (!tableMap.values().contains(mappedTable)) {
      loadersCount++;
    }
    tableMap.put(dataSource + "." + originTable, mappedTable);
  }

  return localTableMap;
}
 
开发者ID:HashDataInc,项目名称:bireme,代码行数:32,代码来源:Config.java

示例9: testCreateConfiguration

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
@Test
public void testCreateConfiguration() throws Exception {

    Configuration conf = target.createConfiguration();

    for (Object name : Collections.list(System.getProperties().propertyNames())) {

        // All system properties must exist.
        assertTrue(conf.containsKey(name.toString()), "Missing system : " + name);

    }

    Configuration v = new Configurations().properties(getResource(ConfigurationType.VERSION.getPath()));
    Configuration s = new Configurations().properties(getResource(ConfigurationType.SITE.getPath()));

    // 1st should be version.
    assertEquals(VERSION.fetch(conf), v.getString(VERSION.getKey()));
    assertNotEquals(VERSION.fetch(conf), s.getString(VERSION.getKey()));
    assertEquals(s.getString(VERSION.getKey()), "test");

    // 2nd should be system. (Should not be overridden.)
    String system = "java.version";
    assertEquals(conf.getString(system), System.getProperty(system));
    assertNotEquals(conf.getString(system), s.getString(system));
    assertEquals(s.getString(system), "test");

    // 3rd should be site.
    assertEquals(SITE.fetch(conf), s.getString(SITE.getKey()));
    assertEquals(s.getString(SITE.getKey()), "test");

    // Last should be default.
    assertEquals(HTTP_URL.fetch(conf), HTTP_URL.getDefaultValue());

}
 
开发者ID:after-the-sunrise,项目名称:bitflyer4j,代码行数:35,代码来源:Bitflyer4jFactoryTest.java

示例10: Config

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
private Config() {
	Configuration configuration;
	try {
		Configurations configurations = new Configurations();

		configuration = configurations.properties(new File("configuration.properties"));
	} catch (ConfigurationException ce) {
		ce.printStackTrace();
		configuration = null;
	}
	this.properties = configuration;
	this.initSuccess = configuration != null;
}
 
开发者ID:PDDStudio,项目名称:phrase-java,代码行数:14,代码来源:Config.java

示例11: test

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
@Test(enabled = false)
public void test() throws Exception {

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));

    doCallRealMethod().when(target).request(any(), any(), any(), any());

    Key key = Key.builder().instrument("XBT_QT").timestamp(Instant.now()).build();

    // Tick
    System.out.println("Ask : " + target.getBestAskPrice(key));
    System.out.println("Bid : " + target.getBestBidPrice(key));
    System.out.println("Mid : " + target.getMidPrice(key));
    System.out.println("Ltp : " + target.getLastPrice(key));

    // Book
    System.out.println("ASZ : " + target.getBestAskSize(key));
    System.out.println("BSZ : " + target.getBestBidSize(key));

    // Trade
    System.out.println("TRD : " + target.listTrades(key, null));

    // Account
    System.out.println("IPS : " + target.getInstrumentPosition(key));
    System.out.println("FPS : " + target.getFundingPosition(key));

    // Reference
    System.out.println("COM : " + target.getCommissionRate(key));
    System.out.println("MGN : " + target.isMarginable(key));
    System.out.println("EXP : " + target.getExpiry(key));

    // Order Query
    System.out.println("ORD : " + target.findOrders(key));
    System.out.println("EXC : " + target.listExecutions(key));

}
 
开发者ID:after-the-sunrise,项目名称:cryptotrader,代码行数:38,代码来源:BitmexContextTest.java

示例12: test_Order

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
@Test(enabled = false)
public void test_Order() throws Exception {

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));

    doCallRealMethod().when(target).request(any(), any(), any(), any());

    Key key = Key.builder().instrument("XBJ_QT").timestamp(Instant.now()).build();

    Map<CreateInstruction, String> ids = target.createOrders(
            key, Sets.newHashSet(
                    CreateInstruction.builder()
                            .price(new BigDecimal("1000000"))
                            .size(new BigDecimal("10E-1")).build(),
                    CreateInstruction.builder()
                            .price(new BigDecimal("1000000"))
                            .size(new BigDecimal("0.2E1")).build()
            ));

    System.out.println("NEW : " + ids);

    Thread.sleep(TimeUnit.SECONDS.toMillis(5));

    System.out.println("CND : " + target.cancelOrders(key, ids.values().stream()
            .map(id -> CancelInstruction.builder().id(id).build()).collect(Collectors.toSet())
    ));

}
 
开发者ID:after-the-sunrise,项目名称:cryptotrader,代码行数:30,代码来源:BitmexContextTest.java

示例13: test

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
@Test(enabled = false)
public void test() throws ConfigurationException {

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));
    Key key = Key.builder().site(ID).instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    System.out.println("AP: " + target.getBestAskPrice(key));
    System.out.println("BP: " + target.getBestBidPrice(key));
    System.out.println("AS: " + target.getBestAskSize(key));
    System.out.println("BS: " + target.getBestBidSize(key));
    System.out.println("MP: " + target.getMidPrice(key));
    System.out.println("AD: " + target.getAskPrices(key));
    System.out.println("BD: " + target.getBidPrices(key));

    System.out.println("LP:" + target.getLastPrice(key));
    System.out.println("TD:" + target.listTrades(key, null));

    System.out.println("IC:" + target.getInstrumentCurrency(key));
    System.out.println("FC:" + target.getFundingCurrency(key));
    System.out.println("FP:" + target.findProduct(key, BTC, JPY));

    System.out.println("P1:" + target.getConversionPrice(key, BTC));
    System.out.println("P2:" + target.getConversionPrice(key, JPY));

    System.out.println("IP:" + target.getInstrumentPosition(key));
    System.out.println("FP:" + target.getFundingPosition(key));

}
 
开发者ID:after-the-sunrise,项目名称:cryptotrader,代码行数:30,代码来源:BitbankContextTest.java

示例14: test

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
@Test(enabled = false)
public void test() throws Exception {

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));

    doCallRealMethod().when(target).request(any(), any(), any(), any());
    doCallRealMethod().when(target).scheduleSocket(any(), any());

    Key key = Key.builder().instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    System.out.println("APX : " + target.getBestAskPrice(key));
    System.out.println("ASZ : " + target.getBestAskSize(key));
    System.out.println("BPX : " + target.getBestBidPrice(key));
    System.out.println("BSZ : " + target.getBestBidSize(key));
    System.out.println("MID : " + target.getMidPrice(key));
    System.out.println("LTP : " + target.getLastPrice(key));
    System.out.println("TRD : " + target.listTrades(key, null));

    System.out.println("CYI : " + target.getInstrumentCurrency(key));
    System.out.println("CYF : " + target.getFundingCurrency(key));
    System.out.println("CVB : " + target.getConversionPrice(key, CurrencyType.BTC));
    System.out.println("CVJ : " + target.getConversionPrice(key, CurrencyType.JPY));

    System.out.println("PSI : " + target.getInstrumentPosition(key));
    System.out.println("PSF : " + target.getFundingPosition(key));

    System.out.println("RIU : " + target.roundLotSize(key, new BigDecimal("1.23456"), UP));
    System.out.println("RID : " + target.roundLotSize(key, new BigDecimal("1.23456"), DOWN));
    System.out.println("RTU : " + target.roundTickSize(key, new BigDecimal("1.23456"), UP));
    System.out.println("RTD : " + target.roundTickSize(key, new BigDecimal("1.23456"), DOWN));
    System.out.println("COM : " + target.getCommissionRate(key));

    System.out.println("FDO : " + target.findOrder(key, "some_order_id"));
    System.out.println("LAO : " + target.listActiveOrders(key));
    System.out.println("LSE : " + target.listExecutions(key));

}
 
开发者ID:after-the-sunrise,项目名称:cryptotrader,代码行数:39,代码来源:CoincheckContextTest.java

示例15: test_Order

import org.apache.commons.configuration2.builder.fluent.Configurations; //导入依赖的package包/类
@Test(enabled = false)
public void test_Order() throws Exception {

    Path path = Paths.get(System.getProperty("user.home"), ".cryptotrader");
    target.setConfiguration(new Configurations().properties(path.toAbsolutePath().toFile()));

    doCallRealMethod().when(target).request(any(), any(), any(), any());

    Key key = Key.builder().instrument(BTC_JPY.name()).timestamp(Instant.now()).build();

    Map<CreateInstruction, String> creates = target.createOrders(key, Sets.newHashSet(
            CreateInstruction.builder()
                    .price(new BigDecimal("1000001"))
                    .size(new BigDecimal("0.005")).build(),
            CreateInstruction.builder()
                    .price(new BigDecimal("1000002"))
                    .size(new BigDecimal("0.005")).build()
    ));

    creates.forEach((instruction, id) -> System.out.println(instruction + " -> " + id));

    TimeUnit.SECONDS.sleep(10);

    Map<CancelInstruction, String> cancels = target.cancelOrders(key, creates.values().stream()
            .filter(StringUtils::isNotEmpty)
            .map(id -> CancelInstruction.builder().id(id).build())
            .collect(Collectors.toSet())
    );

    cancels.forEach((instruction, id) -> System.out.println(instruction + " -> " + id));

}
 
开发者ID:after-the-sunrise,项目名称:cryptotrader,代码行数:33,代码来源:CoincheckContextTest.java


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