Examples of HierarchicalINIConfiguration


Examples of org.apache.commons.configuration.HierarchicalINIConfiguration

  public static void populateConfiguration () throws IOException, ConfigurationException{
    Logger.info("Load initial configuration...");
    InputStream is;
    if (Play.application().isProd()) is  =Play.application().resourceAsStream(CONFIGURATION_FILE_NAME);
    else is = new FileInputStream(Play.application().getFile("conf/"+CONFIGURATION_FILE_NAME));
    HierarchicalINIConfiguration c = new HierarchicalINIConfiguration();
    c.setEncoding("UTF-8");
    c.load(is);
    CharSequence doubleDot = "..";
    CharSequence dot = ".";

    Set<String> sections= c.getSections();
    for (String section: sections){
      Class en = PropertiesConfigurationHelper.CONFIGURATION_SECTIONS.get(section);
      if (en==null){
        Logger.warn(section  + " is not a valid configuration section, it will be skipped!");
        continue;
      }
      SubnodeConfiguration subConf=c.getSection(section);
      Iterator<String> it = subConf.getKeys();
      while (it.hasNext()){
        String key = (it.next());
        Object value =subConf.getString(key);
        key=key.replace(doubleDot, dot);//bug on the Apache library: if the key contain a dot, it will be doubled!
View Full Code Here

Examples of org.apache.commons.configuration.HierarchicalINIConfiguration

    @Test
    public void testGetConfiguration() {
        try {
            final Config config = new Config();
            HierarchicalINIConfiguration configuration = config
                    .getConfiguration();
            assertEquals("localhost", configuration.getString("lucene.host"));
            assertEquals(5985, configuration.getInt("lucene.port"));
        } catch (ConfigurationException ce) {
            fail("ConfigurationException shouldn't have been thrown."
                    + ce.getMessage());
        }
    }
View Full Code Here

Examples of org.apache.commons.configuration.HierarchicalINIConfiguration

    private static final String DEFAULT_DIR = "indexes";

    private final HierarchicalINIConfiguration configuration;

    public Config() throws ConfigurationException {
        this.configuration = new HierarchicalINIConfiguration(Config.class
                .getClassLoader().getResource(CONFIG_FILE));
        this.configuration
                .setReloadingStrategy(new FileChangedReloadingStrategy());
    }
View Full Code Here

Examples of org.apache.commons.configuration.HierarchicalINIConfiguration

    private Browscap() {
        Stopwatch timer = new Stopwatch();

        timer.start();
        HierarchicalINIConfiguration browscapIni = loadIniFile();

        if (null != browscapIni) {
            loadBrowscap(browscapIni);
        }
View Full Code Here

Examples of org.apache.commons.configuration.HierarchicalINIConfiguration

        this.browscapsByLength = ImmutableList.copyOf(Ordering.from(new DescendingStringLengthComparator()).sortedCopy(
                browscap.keySet()));
    }

    private HierarchicalINIConfiguration loadIniFile() {
        HierarchicalINIConfiguration browscapIni = null;

        try {
            browscapIni = new HierarchicalINIConfiguration(Thread.currentThread().getContextClassLoader()
                    .getResource("browscap.ini"));
        } catch (ConfigurationException e) {
            throw new RuntimeException("Could not load INI file", e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.