Example usage for org.apache.commons.configuration HierarchicalINIConfiguration HierarchicalINIConfiguration

List of usage examples for org.apache.commons.configuration HierarchicalINIConfiguration HierarchicalINIConfiguration

Introduction

In this page you can find the example usage for org.apache.commons.configuration HierarchicalINIConfiguration HierarchicalINIConfiguration.

Prototype

public HierarchicalINIConfiguration(URL url) throws ConfigurationException 

Source Link

Document

Create and load the ini configuration from the given url.

Usage

From source file:com.github.rnewson.couchdb.lucene.Main.java

/**
 * Run couchdb-lucene./*from   w  ww.  ja  v a  2s .  co m*/
 */
public static void main(String[] args) throws Exception {
    final HierarchicalINIConfiguration configuration = new HierarchicalINIConfiguration(
            Main.class.getClassLoader().getResource("couchdb-lucene.ini"));
    configuration.setReloadingStrategy(new FileChangedReloadingStrategy());

    final File dir = new File(configuration.getString("lucene.dir", "indexes"));

    if (dir == null) {
        LOG.error("lucene.dir not set.");
        System.exit(1);
    }
    if (!dir.exists() && !dir.mkdir()) {
        LOG.error("Could not create " + dir.getCanonicalPath());
        System.exit(1);
    }
    if (!dir.canRead()) {
        LOG.error(dir + " is not readable.");
        System.exit(1);
    }
    if (!dir.canWrite()) {
        LOG.error(dir + " is not writable.");
        System.exit(1);
    }
    LOG.info("Index output goes to: " + dir.getCanonicalPath());

    final Server server = new Server();
    final SelectChannelConnector connector = new SelectChannelConnector();
    connector.setHost(configuration.getString("lucene.host", "localhost"));
    connector.setPort(configuration.getInt("lucene.port", 5985));

    LOG.info("Accepting connections with " + connector);

    server.setConnectors(new Connector[] { connector });
    server.setStopAtShutdown(true);
    server.setSendServerVersion(false);

    HttpClientFactory.setIni(configuration);
    final HttpClient httpClient = HttpClientFactory.getInstance();

    final LuceneServlet servlet = new LuceneServlet(httpClient, dir, configuration);

    final Context context = new Context(server, "/", Context.NO_SESSIONS | Context.NO_SECURITY);
    context.addServlet(new ServletHolder(servlet), "/*");
    context.addFilter(new FilterHolder(new GzipFilter()), "/*", Handler.DEFAULT);
    context.setErrorHandler(new JSONErrorHandler());
    server.setHandler(context);

    server.start();
    server.join();
}

From source file:io.dockstore.common.Utilities.java

public static HierarchicalINIConfiguration parseConfig(String path) {
    try {/*from w  w  w  .  java 2s  .  co  m*/
        return new HierarchicalINIConfiguration(path);
    } catch (ConfigurationException ex) {
        throw new RuntimeException("Could not read ~/.dockstore/config");
    }
}

From source file:com.tinydream.scribeproxy.utils.Config.java

synchronized private static void init() {
    String path = System.getProperty("appconfig");
    String pathFile = path + File.separator + "application.ini";

    //        System.out.println("pathFile:" + pathFile);
    // init configuration
    config = new CompositeConfiguration();
    _hashConfig = new ConcurrentHashMap<String, String>();
    try {//from  www  .j a  v  a2s  . c  o  m
        config.addConfiguration(new HierarchicalINIConfiguration(pathFile));
    } catch (ConfigurationException ex) {
        logger_.error("Can't load configuration file", ex);
        System.err.println("Bad configuration; unable to start server");
        System.exit(1);
    }
}

From source file:io.dockstore.common.CommonTestUtilities.java

public static HierarchicalINIConfiguration parseConfig(String path) {
    try {//from  ww w. j  a  va2  s.  co  m
        return new HierarchicalINIConfiguration(path);
    } catch (ConfigurationException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:com.hipstogram.storm.context.config.Config.java

public Config(File configFile, File... otherConfigFile) throws ConfigurationException {
    HierarchicalINIConfiguration iniConfig = new HierarchicalINIConfiguration(configFile);
    this.kafkaSection = new KafkaSection(iniConfig.getSection("kafka"));
    this.zookeeperSection = new ZookeeperSection(iniConfig.getSection("zookeeper"));
}

From source file:com.hipstogram.context.config.Config.java

public Config(File configFile, File... otherConfigFile) throws ConfigurationException {
    HierarchicalINIConfiguration iniConfig = new HierarchicalINIConfiguration(configFile);
    this.kafkaSection = new KafkaSection(iniConfig.getSection("kafka"));
    this.serverSection = new ServerSection(iniConfig.getSection("server"));
    this.zookeeperSection = new ZookeeperSection(iniConfig.getSection("zookeeper"));
    this.cassandraSection = new CassandraSection(iniConfig.getSection("cassandra"));
    this.mongoSection = new MongoDBSection(iniConfig.getSection("mongodb"));
}

From source file:com.github.rnewson.couchdb.lucene.Config.java

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

From source file:com.yfiton.api.Notifier.java

public Notifier() {
    try {//w ww  .j a va2 s . co m
        configuration = new HierarchicalINIConfiguration(getConfigurationFilePath().toFile());
    } catch (ConfigurationException | IOException e) {
        log.warn(e.getMessage(), e);
    }
}

From source file:com.bist.elasticsearch.jetty.security.AuthorizationConfigurationLoader.java

public QueryConstraints load(URL url) {
    try {/*from w w w.  j  av  a 2s.co m*/
        LOG.info("Loading AuthorizationMappingFile:" + url.toString());
        HierarchicalINIConfiguration iniConfiguration = new HierarchicalINIConfiguration(url);
        QueryConstraints queryConstraints = new QueryConstraints();

        return loadIni(iniConfiguration, queryConstraints);

    } catch (Exception e) {
        LOG.warn("Error while Reading File" + e.getMessage(), e);
        return null;

    }
}

From source file:iddb.web.security.SecurityConfig.java

private SecurityConfig() {
    try {// w  w w .  j  a v a  2  s.  c o m
        HierarchicalINIConfiguration configFile = new HierarchicalINIConfiguration(
                this.getClass().getClassLoader().getResource("security.properties"));
        for (Object section : configFile.getSections()) {
            SubnodeConfiguration node = configFile.getSection((String) section);
            Map<String, String> map = new LinkedHashMap<String, String>();
            for (@SuppressWarnings("unchecked")
            Iterator<Object> it = node.getKeys(); it.hasNext();) {
                String key = it.next().toString();
                if (log.isTraceEnabled()) {
                    log.trace("Loading '{}' with value '{}' on section '{}'",
                            new String[] { key, node.getString(key), section.toString() });
                }
                map.put(key, node.getString(key));
            }
            config.put(section.toString(), map);
        }
    } catch (ConfigurationException e) {
        log.error(e.getMessage());
    }
}