Example usage for org.apache.commons.configuration Configuration getString

List of usage examples for org.apache.commons.configuration Configuration getString

Introduction

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

Prototype

String getString(String key, String defaultValue);

Source Link

Document

Get a string associated with the given configuration key.

Usage

From source file:edu.berkeley.sparrow.examples.BBackend.java

public static void main(String[] args) throws IOException, TException {
    ipAddress = InetAddress.getLocalHost().toString();
    OptionParser parser = new OptionParser();
    parser.accepts("c", "configuration file").withRequiredArg().ofType(String.class);
    parser.accepts("help", "print help statement");
    OptionSet options = parser.parse(args);

    if (options.has("help")) {
        parser.printHelpOn(System.out);
        System.exit(-1);// w w w.  java  2 s . c  o m
    }

    // Logger configuration: log to the console
    BasicConfigurator.configure();

    Configuration conf = new PropertiesConfiguration();

    if (options.has("c")) {
        String configFile = (String) options.valueOf("c");
        try {
            conf = new PropertiesConfiguration(configFile);
        } catch (ConfigurationException e) {
        }
    }
    // Start backend server
    LOG.setLevel(Level.toLevel(conf.getString(LOG_LEVEL, DEFAULT_LOG_LEVEL)));
    LOG.debug("debug logging on");
    int listenPort = conf.getInt(LISTEN_PORT, DEFAULT_LISTEN_PORT);
    int nodeMonitorPort = conf.getInt(NODE_MONITOR_PORT, NodeMonitorThrift.DEFAULT_NM_THRIFT_PORT);
    batchingDelay = conf.getLong(BATCHING_DELAY, DEFAULT_BATCHING_DELAY);
    String nodeMonitorHost = conf.getString(NODE_MONITOR_HOST, DEFAULT_NODE_MONITOR_HOST);
    int workerThread = conf.getInt(WORKER_THREADS, DEFAULT_WORKER_THREADS);
    appClientAdress = InetAddress.getByName(conf.getString(APP_CLIENT_IP));
    appClientPortNumber = conf.getInt(APP_CLIENT_PORT_NUMBER, DEFAULT_APP_CLIENT_PORT_NUMBER);
    executor = Executors.newFixedThreadPool(workerThread);
    // Starting logging of results
    resultLog = new SynchronizedWrite("ResultsBackend.txt");
    Thread resultLogTh = new Thread(resultLog);
    resultLogTh.start();

    BBackend protoBackend = new BBackend();
    BackendService.Processor<BackendService.Iface> processor = new BackendService.Processor<BackendService.Iface>(
            protoBackend);

    TServers.launchSingleThreadThriftServer(listenPort, processor);
    protoBackend.initialize(listenPort, nodeMonitorHost, nodeMonitorPort);

}

From source file:edu.berkeley.sparrow.examples.SimpleBackend.java

public static void main(String[] args) throws IOException, TException {
    OptionParser parser = new OptionParser();
    parser.accepts("c", "configuration file").withRequiredArg().ofType(String.class);
    parser.accepts("help", "print help statement");
    OptionSet options = parser.parse(args);

    if (options.has("help")) {
        parser.printHelpOn(System.out);
        System.exit(-1);/*w w  w .  j a  v a2  s  .  c  o m*/
    }

    // Logger configuration: log to the console
    BasicConfigurator.configure();
    LOG.setLevel(Level.DEBUG);
    LOG.debug("debug logging on");

    Configuration conf = new PropertiesConfiguration();

    if (options.has("c")) {
        String configFile = (String) options.valueOf("c");
        try {
            conf = new PropertiesConfiguration(configFile);
        } catch (ConfigurationException e) {
        }
    }
    // Start backend server
    SimpleBackend protoBackend = new SimpleBackend();
    BackendService.Processor<BackendService.Iface> processor = new BackendService.Processor<BackendService.Iface>(
            protoBackend);

    int listenPort = conf.getInt(LISTEN_PORT, DEFAULT_LISTEN_PORT);
    int nodeMonitorPort = conf.getInt(NODE_MONITOR_PORT, NodeMonitorThrift.DEFAULT_NM_THRIFT_PORT);
    String nodeMonitorHost = conf.getString(NODE_MONITOR_HOST, DEFAULT_NODE_MONITOR_HOST);
    TServers.launchSingleThreadThriftServer(listenPort, processor);
    protoBackend.initialize(listenPort, nodeMonitorHost, nodeMonitorPort);
}

From source file:io.fluo.core.worker.NotificationFinderFactory.java

public static NotificationFinder newNotificationFinder(Configuration conf) {
    //this config is intentionally not public for now
    String clazz = conf.getString(FluoConfiguration.FLUO_PREFIX + ".worker.finder",
            HashNotificationFinder.class.getName());
    try {//from  www .j av a 2s. c om
        return Class.forName(clazz).asSubclass(NotificationFinder.class).newInstance();
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        throw new RuntimeException(e);
    }

}

From source file:net.pms.configuration.ConfigurationUtil.java

/**
 * Return the <code>String</code> value for a given, possibly-blank
 * (i.e. empty or all whitespace) configuration key.
 * The value is returned with leading and trailing whitespace removed in both cases.
 * @param configuration The configuration to look up the key in.
 * @param key The key to look up.//w  w w . j  av  a 2  s. c o  m
 * @param def The default value to return when no valid key value can be found.
 * @return The value configured for the key.
 */

// package-private
static String getPossiblyBlankConfigurationString(Configuration configuration, String key, String def) {
    String value = configuration.getString(key, def);

    if (value != null) {
        return value.trim();
    } else {
        return value;
    }
}

From source file:com.salesmanager.core.util.LanguageUtil.java

public static String getDefaultLanguage() {

    Configuration conf = PropertiesUtil.getConfiguration();
    String defaultLang = conf.getString("core.system.defaultlanguage", "en");
    return defaultLang;

}

From source file:cz.cas.lib.proarc.common.export.cejsh.CejshConfig.java

public static CejshConfig from(Configuration conf) {
    CejshConfig cc = new CejshConfig();
    cc.setCejshXslUrl(conf.getString(PROP_MODS_XSL_URL, null));
    //        cc.setJournalUrl(conf.getString(PROP_JOURNALS_URL, null));
    try {//www.  java2s.c om
        boolean debug = conf.getBoolean(PROP_DEBUG, Boolean.FALSE);
        cc.setLogLevel(debug ? Level.INFO : Level.FINE);
    } catch (ConversionException ex) {
        LOG.log(Level.SEVERE, PROP_DEBUG, ex);
    }
    return cc;
}

From source file:com.github.anba.test262.environment.Environments.java

/**
 * Returns the default environment provider
 *//*from   w ww . j a  va2 s.  c  o  m*/
public static <T extends GlobalObject> EnvironmentProvider<T> get(Configuration configuration) {
    String library = configuration.getString("test.provider", "rhino");
    switch (library) {
    case "rhino":
        return rhino(configuration);
    default:
        throw new IllegalArgumentException(library);
    }
}

From source file:com.github.nethad.clustermeister.provisioning.torque.TorqueConfiguration.java

private static String checkString(Configuration configuration, String configOption, String defaultValue,
        String logMessage) {//from w w w  .j a  v a  2s.c  om
    String value = configuration.getString(configOption, "");
    if (value.isEmpty()) {
        logger.warn(loggerMessage(logMessage, configOption, defaultValue));
        return defaultValue;
    }
    return value;
}

From source file:com.manydesigns.portofino.logic.SecurityLogic.java

public static String getAdministratorsGroup(Configuration conf) {
    return conf.getString(GROUP_ADMINISTRATORS, GROUP_ADMINISTRATORS_DEFAULT);
}

From source file:com.manydesigns.portofino.logic.SecurityLogic.java

public static String getAllGroup(Configuration conf) {
    return conf.getString(GROUP_ALL, GROUP_ALL_DEFAULT);
}