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:net.sf.maltcms.chromaui.project.spi.descriptors.CachingChromatogram1D.java

@Override
public void configure(final Configuration cfg) {
    this.scan_acquisition_time_var = cfg.getString("var.scan_acquisition_time", "scan_acquisition_time");
}

From source file:net.sf.jclal.evaluation.method.RealScenario.java

@Override
protected void setDataConfiguration(Configuration configuration) {
    // Set multiLabel flag
    boolean multi = configuration.getBoolean("multi-label", false);
    setMultiLabel(multi);//from www .  j  ava  2 s  .co  m

    // Set multiInstance flag
    boolean multiInstance = configuration.getBoolean("multi-instance", false);
    setMultiInstance(multiInstance);

    // Set the xml file, it is used in the case of a multi-label
    // dataset
    String xml = configuration.getString("file-xml", "");
    setXmlPath(xml);

    // the multi-label elements are verified
    if (multi && xml.isEmpty()) {
        throw new ConfigurationRuntimeException(
                "\nThe multi-label flag is " + "enabled and the xml path is empty. "
                        + "<multi-label>true</multi-label>" + " <file-xml></file-xml>");
    }

    // Set file labeled
    String fileLabeled = configuration.getString("file-labeled", "");
    setFileLabeledDataset(fileLabeled);

    // Set file unlabeled
    String fileUnlabeled = configuration.getString("file-unlabeled", "");
    setFileUnlabeledDataset(fileUnlabeled);

    if (fileLabeled.isEmpty() || fileUnlabeled.isEmpty()) {
        throw new ConfigurationRuntimeException("\n <file-labeled> and <file-unlabeled> tags must be defined.");
    }

    // Set file test
    String fileTest = configuration.getString("file-test", "");

    if (fileTest.isEmpty()) {
        /*
         * Logger.getLogger(RealScenario.class.getName()).log(Level.INFO,
         * "The param <file-test> is empty, the active learning algorithm require this property "
         * +
         * "for evaluating the constructed model, but in real scenario is not really necessary. In this case, "
         * + "we assign the <file-unlabeled> as <file-test>.");
         */
        fileTest = fileUnlabeled;
    }

    setFileTestDataset(fileTest);

    // Set class attribute
    int classAttributeT = configuration.getInt("class-attribute", -1);

    setClassAttribute(classAttributeT);
}

From source file:eu.socialsensor.main.BenchmarkConfiguration.java

public BenchmarkConfiguration(Configuration appconfig) {
    if (appconfig == null) {
        throw new IllegalArgumentException("appconfig may not be null");
    }//from  www .j  a  v  a 2 s.com

    Configuration eu = appconfig.subset("eu");
    Configuration socialsensor = eu.subset("socialsensor");

    //metrics
    final Configuration metrics = socialsensor.subset(GraphDatabaseConfiguration.METRICS_NS.getName());

    final Configuration graphite = metrics.subset(GRAPHITE);
    this.graphiteHostname = graphite.getString(GRAPHITE_HOSTNAME, null);
    this.graphiteReportingInterval = graphite.getLong(GraphDatabaseConfiguration.GRAPHITE_INTERVAL.getName(),
            1000 /*default 1sec*/);

    final Configuration csv = metrics.subset(CSV);
    this.csvReportingInterval = metrics.getLong(CSV_INTERVAL, 1000 /*ms*/);
    this.csvDir = csv.containsKey(CSV_DIR)
            ? new File(csv.getString(CSV_DIR, System.getProperty("user.dir") /*default*/))
            : null;

    Configuration dynamodb = socialsensor.subset("dynamodb");
    this.dynamodbWorkerThreads = dynamodb.getInt("workers", 25);
    Configuration credentials = dynamodb.subset(CREDENTIALS);
    this.dynamodbPrecreateTables = dynamodb.getBoolean("precreate-tables", Boolean.FALSE);
    this.dynamodbTps = Math.max(1, dynamodb.getLong(TPS, 750 /*default*/));
    this.dynamodbConsistentRead = dynamodb.containsKey(CONSISTENT_READ) ? dynamodb.getBoolean(CONSISTENT_READ)
            : false;
    this.dynamodbDataModel = dynamodb.containsKey("data-model")
            ? BackendDataModel.valueOf(dynamodb.getString("data-model"))
            : null;
    this.dynamodbCredentialsFqClassName = credentials.containsKey(CLASS_NAME)
            ? credentials.getString(CLASS_NAME)
            : null;
    this.dynamodbCredentialsCtorArguments = credentials.containsKey(CONSTRUCTOR_ARGS)
            ? credentials.getString(CONSTRUCTOR_ARGS)
            : null;
    this.dynamodbEndpoint = dynamodb.containsKey(ENDPOINT) ? dynamodb.getString(ENDPOINT) : null;
    this.dynamodbTablePrefix = dynamodb.containsKey(TABLE_PREFIX) ? dynamodb.getString(TABLE_PREFIX)
            : Constants.DYNAMODB_TABLE_PREFIX.getDefaultValue();

    Configuration orient = socialsensor.subset("orient");
    orientLightweightEdges = orient.containsKey(LIGHTWEIGHT_EDGES) ? orient.getBoolean(LIGHTWEIGHT_EDGES)
            : null;

    Configuration sparksee = socialsensor.subset("sparksee");
    sparkseeLicenseKey = sparksee.containsKey(LICENSE_KEY) ? sparksee.getString(LICENSE_KEY) : null;

    Configuration titan = socialsensor.subset(TITAN); //TODO(amcp) move dynamodb ns into titan
    bufferSize = titan.getInt(BUFFER_SIZE, GraphDatabaseConfiguration.BUFFER_SIZE.getDefaultValue());
    blocksize = titan.getInt(IDS_BLOCKSIZE, GraphDatabaseConfiguration.IDS_BLOCK_SIZE.getDefaultValue());
    pageSize = titan.getInt(PAGE_SIZE, GraphDatabaseConfiguration.PAGE_SIZE.getDefaultValue());

    // database storage directory
    if (!socialsensor.containsKey(DATABASE_STORAGE_DIRECTORY)) {
        throw new IllegalArgumentException("configuration must specify database-storage-directory");
    }
    dbStorageDirectory = new File(socialsensor.getString(DATABASE_STORAGE_DIRECTORY));
    dataset = validateReadableFile(socialsensor.getString(DATASET), DATASET);

    // load the dataset
    DatasetFactory.getInstance().getDataset(dataset);

    if (!socialsensor.containsKey(PERMUTE_BENCHMARKS)) {
        throw new IllegalArgumentException("configuration must set permute-benchmarks to true or false");
    }
    permuteBenchmarks = socialsensor.getBoolean(PERMUTE_BENCHMARKS);

    List<?> benchmarkList = socialsensor.getList("benchmarks");
    benchmarkTypes = new ArrayList<BenchmarkType>();
    for (Object str : benchmarkList) {
        benchmarkTypes.add(BenchmarkType.valueOf(str.toString()));
    }

    selectedDatabases = new TreeSet<GraphDatabaseType>();
    for (Object database : socialsensor.getList("databases")) {
        if (!GraphDatabaseType.STRING_REP_MAP.keySet().contains(database.toString())) {
            throw new IllegalArgumentException(
                    String.format("selected database %s not supported", database.toString()));
        }
        selectedDatabases.add(GraphDatabaseType.STRING_REP_MAP.get(database));
    }
    scenarios = permuteBenchmarks ? Ints.checkedCast(CombinatoricsUtils.factorial(selectedDatabases.size()))
            : 1;

    resultsPath = new File(System.getProperty("user.dir"), socialsensor.getString("results-path"));
    if (!resultsPath.exists() && !resultsPath.mkdirs()) {
        throw new IllegalArgumentException("unable to create results directory");
    }
    if (!resultsPath.canWrite()) {
        throw new IllegalArgumentException("unable to write to results directory");
    }

    randomNodes = socialsensor.getInteger(RANDOM_NODES, new Integer(100));

    if (this.benchmarkTypes.contains(BenchmarkType.CLUSTERING)) {
        if (!socialsensor.containsKey(NODES_COUNT)) {
            throw new IllegalArgumentException("the CW benchmark requires nodes-count integer in config");
        }
        nodesCount = socialsensor.getInt(NODES_COUNT);

        if (!socialsensor.containsKey(RANDOMIZE_CLUSTERING)) {
            throw new IllegalArgumentException("the CW benchmark requires randomize-clustering bool in config");
        }
        randomizedClustering = socialsensor.getBoolean(RANDOMIZE_CLUSTERING);

        if (!socialsensor.containsKey(ACTUAL_COMMUNITIES)) {
            throw new IllegalArgumentException("the CW benchmark requires a file with actual communities");
        }
        actualCommunities = validateReadableFile(socialsensor.getString(ACTUAL_COMMUNITIES),
                ACTUAL_COMMUNITIES);

        final boolean notGenerating = socialsensor.containsKey(CACHE_VALUES);
        if (notGenerating) {
            List<?> objects = socialsensor.getList(CACHE_VALUES);
            cacheValues = new ArrayList<Integer>(objects.size());
            cacheValuesCount = null;
            cacheIncrementFactor = null;
            for (Object o : objects) {
                cacheValues.add(Integer.valueOf(o.toString()));
            }
        } else if (socialsensor.containsKey(CACHE_VALUES_COUNT)
                && socialsensor.containsKey(CACHE_INCREMENT_FACTOR)) {
            cacheValues = null;
            // generate the cache values with parameters
            if (!socialsensor.containsKey(CACHE_VALUES_COUNT)) {
                throw new IllegalArgumentException(
                        "the CW benchmark requires cache-values-count int in config when cache-values not specified");
            }
            cacheValuesCount = socialsensor.getInt(CACHE_VALUES_COUNT);

            if (!socialsensor.containsKey(CACHE_INCREMENT_FACTOR)) {
                throw new IllegalArgumentException(
                        "the CW benchmark requires cache-increment-factor int in config when cache-values not specified");
            }
            cacheIncrementFactor = socialsensor.getDouble(CACHE_INCREMENT_FACTOR);
        } else {
            throw new IllegalArgumentException(
                    "when doing CW benchmark, must provide cache-values or parameters to generate them");
        }
    } else {
        randomizedClustering = null;
        nodesCount = null;
        cacheValuesCount = null;
        cacheIncrementFactor = null;
        cacheValues = null;
        actualCommunities = null;
    }
}

From source file:fr.mby.utils.spring.beans.factory.BasicProxywiredManager.java

/**
 * Read the wiring configuration.// ww w  .j  ava  2s.  c o m
 * 
 * @param identifier
 * @return
 */
protected LinkedHashSet<String> readWiringConfiguration(final IProxywiredIdentifier identifier) {
    LinkedHashSet<String> beanNames = null;
    if (this.configuration != null) {
        final Configuration elementConfig = identifier.getConfigurationSubset(this.configuration);
        final String wiredBeansConfig = elementConfig.getString(IProxywiredManager.WIRED_BEANS_CONFIG_KEY,
                null);
        beanNames = this.buildWiredBeanSetFromConfig(wiredBeansConfig);
    }

    return beanNames;
}

From source file:edu.kit.dama.mdm.content.util.ElasticsearchTransitionTypeHandler.java

@Override
public boolean configure(Configuration pConfig) throws ConfigurationException {
    elasticHost = DataManagerSettings.getSingleton()
            .getStringProperty(DataManagerSettings.ELASTIC_SEARCH_DEFAULT_HOST_ID, "localhost");
    elasticPort = DataManagerSettings.getSingleton()
            .getIntProperty(DataManagerSettings.ELASTIC_SEARCH_DEFAULT_PORT_ID, 9300);
    elasticCluster = DataManagerSettings.getSingleton()
            .getStringProperty(DataManagerSettings.ELASTIC_SEARCH_DEFAULT_CLUSTER_ID, "KITDataManager");
    elasticIndex = pConfig.getString("index", "customtransitions").toLowerCase();
    return true;/*w  w  w  .ja  va 2s  . c om*/
}

From source file:com.caricah.iotracah.datastore.ignitecache.IgniteDatastore.java

/**
 * <code>configure</code> allows the base system to configure itself by getting
 * all the settings it requires and storing them internally. The plugin is only expected to
 * pick the settings it has registered on the configuration file for its particular use.
 *
 * @param configuration/*ww w .j  a  v a  2s . c  o  m*/
 * @throws UnRetriableException
 */
@Override
public void configure(Configuration configuration) throws UnRetriableException {

    try {

        String driver = configuration.getString(CONFIG_IGNITECACHE_PERSITENCE_DRIVER_NAME,
                CONFIG_IGNITECACHE_PERSITENCE_DRIVER_NAME_VALUE_DEFAULT);
        String url = configuration.getString(CONFIG_IGNITECACHE_PERSITENCE_DB_URL,
                CONFIG_IGNITECACHE_PERSITENCE_DB_URL_VALUE_DEFAULT);
        String username = configuration.getString(CONFIG_IGNITECACHE_PERSITENCE_DB_USERNAME,
                CONFIG_IGNITECACHE_PERSITENCE_DB_USERNAME_VALUE_DEFAULT);
        String password = configuration.getString(CONFIG_IGNITECACHE_PERSITENCE_DB_PASSWORD,
                CONFIG_IGNITECACHE_PERSITENCE_DB_PASSWORD_VALUE_DEFAULT);

        IotDataSource.getInstance().setupDatasource(driver, url, username, password);

        boolean persistanceIsEnabled = configuration.getBoolean(CONFIG_IGNITECACHE_PERSITENCE_ENABLED,
                CONFIG_IGNITECACHE_PERSITENCE_ENABLED_VALUE_DEFAULT);
        setPersistanceEnabled(persistanceIsEnabled);

        partitionHandler.configure(configuration);

        subscriptionFilterHandler.configure(configuration);

        subscriptionHandler.configure(configuration);

        messageHandler.configure(configuration);

        retainedMessageHandler.configure(configuration);

        accountHandler.configure(configuration);

        roleHandler.configure(configuration);

        clientHandler.configure(configuration);

    } catch (NamingException e) {
        throw new UnRetriableException(e);
    }
}

From source file:com.evolveum.midpoint.task.quartzimpl.TaskManagerConfiguration.java

void setJdbcJobStoreInformation(MidpointConfiguration masterConfig, SqlRepositoryConfiguration sqlConfig,
        String defaultJdbcUrlPrefix) {

    Configuration c = masterConfig.getConfiguration(TASK_MANAGER_CONFIG_SECTION);

    jdbcDriver = c.getString(JDBC_DRIVER_CONFIG_ENTRY,
            sqlConfig != null ? sqlConfig.getDriverClassName() : null);

    String explicitJdbcUrl = c.getString(JDBC_URL_CONFIG_ENTRY, null);
    if (explicitJdbcUrl == null) {
        if (sqlConfig.isEmbedded()) {
            jdbcUrl = defaultJdbcUrlPrefix + "-quartz;MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE";
        } else {/*from w w w . j a  v a 2s  .co m*/
            jdbcUrl = sqlConfig.getJdbcUrl();
        }
    } else {
        jdbcUrl = explicitJdbcUrl;
    }
    dataSource = c.getString(DATA_SOURCE_CONFIG_ENTRY, null);
    if (dataSource == null && explicitJdbcUrl == null && sqlConfig != null) {
        dataSource = sqlConfig.getDataSource(); // we want to use quartz-specific JDBC if there is one (i.e. we do not want to inherit data source from repo in such a case)
    }

    if (dataSource != null) {
        LOGGER.info("Quartz database is at {} (a data source)", dataSource);
    } else {
        LOGGER.info("Quartz database is at {} (a JDBC URL)", jdbcUrl);
    }

    jdbcUser = c.getString(JDBC_USER_CONFIG_ENTRY, sqlConfig != null ? sqlConfig.getJdbcUsername() : null);
    jdbcPassword = c.getString(JDBC_PASSWORD_CONFIG_ENTRY,
            sqlConfig != null ? sqlConfig.getJdbcPassword() : null);

    hibernateDialect = sqlConfig != null ? sqlConfig.getHibernateDialect() : "";

    String defaultSqlSchemaFile = schemas.get(hibernateDialect);
    String defaultDriverDelegate = delegates.get(hibernateDialect);

    sqlSchemaFile = c.getString(SQL_SCHEMA_FILE_CONFIG_ENTRY, defaultSqlSchemaFile);
    jdbcDriverDelegateClass = c.getString(JDBC_DRIVER_DELEGATE_CLASS_CONFIG_ENTRY, defaultDriverDelegate);

    createQuartzTables = c.getBoolean(CREATE_QUARTZ_TABLES_CONFIG_ENTRY, CREATE_QUARTZ_TABLES_DEFAULT);
}

From source file:com.caricah.iotracah.core.init.DatastoresInitializer.java

/**
 * <code>configure</code> allows the initializer to configure its self
 * Depending on the implementation conditional operation can be allowed
 * So as to make the system instance more specialized.
 * <p>/*from  w  ww  . j  a v  a 2  s.c  o  m*/
 * For example: via the configurations the implementation may decide to
 * shutdown backend services and it just works as a server application to receive
 * and route requests to the workers which are in turn connected to the backend/datastore servers...
 *
 * @param configuration
 * @throws UnRetriableException
 */
@Override
public void configure(Configuration configuration) throws UnRetriableException {

    boolean configDatastoreEnabled = configuration.getBoolean(CORE_CONFIG_ENGINE_DATASTORE_IS_ENABLED,
            CORE_CONFIG_ENGINE_DATASTORE_IS_ENABLED_DEFAULT_VALUE);

    log.debug(" configure : The datastore function is configured to be enabled [{}]", configDatastoreEnabled);

    setDatastoreEngineEnabled(configDatastoreEnabled);

    String configDatastoreClassName = configuration.getString(CORE_CONFIG_ENGINE_DATASTORE_CLASS_NAME,
            CORE_CONFIG_ENGINE_DATASTORE_CLASS_NAME_DEFAULT_VALUE);

    log.debug(" configure : The datastore class to be loaded by the system is {}", configDatastoreClassName);

    setDatastoreClassName(configDatastoreClassName);

    super.configure(configuration);

    securityHandler.configure(configuration);

}

From source file:com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration.java

public SqlRepositoryConfiguration(Configuration configuration) {
    setDatabase(configuration.getString(PROPERTY_DATABASE, database));

    computeDefaultDatabaseParameters();// w w w .jav a  2 s  .  co  m

    setAsServer(configuration.getBoolean(PROPERTY_AS_SERVER, embedded));
    setBaseDir(configuration.getString(PROPERTY_BASE_DIR, baseDir));
    setDriverClassName(configuration.getString(PROPERTY_DRIVER_CLASS_NAME, driverClassName));
    setEmbedded(configuration.getBoolean(PROPERTY_EMBEDDED, embedded));
    setHibernateDialect(configuration.getString(PROPERTY_HIBERNATE_DIALECT, hibernateDialect));
    setHibernateHbm2ddl(configuration.getString(PROPERTY_HIBERNATE_HBM2DDL, hibernateHbm2ddl));
    setJdbcPassword(configuration.getString(PROPERTY_JDBC_PASSWORD, jdbcPassword));
    setJdbcUrl(configuration.getString(PROPERTY_JDBC_URL, jdbcUrl));
    setJdbcUsername(configuration.getString(PROPERTY_JDBC_USERNAME, jdbcUsername));
    setPort(configuration.getInt(PROPERTY_PORT, port));
    setTcpSSL(configuration.getBoolean(PROPERTY_TCP_SSL, tcpSSL));
    setFileName(configuration.getString(PROPERTY_FILE_NAME, fileName));
    setDropIfExists(configuration.getBoolean(PROPERTY_DROP_IF_EXISTS, dropIfExists));
    setDataSource(configuration.getString(PROPERTY_DATASOURCE, null));
    setMinPoolSize(configuration.getInt(PROPERTY_MIN_POOL_SIZE, minPoolSize));
    setMaxPoolSize(configuration.getInt(PROPERTY_MAX_POOL_SIZE, maxPoolSize));
    setUseZip(configuration.getBoolean(PROPERTY_USE_ZIP, useZip));

    computeDefaultConcurrencyParameters();

    setTransactionIsolation(
            configuration.getString(PROPERTY_TRANSACTION_ISOLATION, transactionIsolation.value()));
    setLockForUpdateViaHibernate(
            configuration.getBoolean(PROPERTY_LOCK_FOR_UPDATE_VIA_HIBERNATE, lockForUpdateViaHibernate));
    setLockForUpdateViaSql(configuration.getBoolean(PROPERTY_LOCK_FOR_UPDATE_VIA_SQL, lockForUpdateViaSql));
    setUseReadOnlyTransactions(
            configuration.getBoolean(PROPERTY_USE_READ_ONLY_TRANSACTIONS, useReadOnlyTransactions));
    setPerformanceStatisticsFile(
            configuration.getString(PROPERTY_PERFORMANCE_STATISTICS_FILE, performanceStatisticsFile));
    setPerformanceStatisticsLevel(
            configuration.getInt(PROPERTY_PERFORMANCE_STATISTICS_LEVEL, performanceStatisticsLevel));

    computeDefaultIterativeSearchParameters();

    setIterativeSearchByPaging(
            configuration.getBoolean(PROPERTY_ITERATIVE_SEARCH_BY_PAGING, iterativeSearchByPaging));
    setIterativeSearchByPagingBatchSize(configuration.getInt(PROPERTY_ITERATIVE_SEARCH_BY_PAGING_BATCH_SIZE,
            iterativeSearchByPagingBatchSize));

    setIgnoreOrgClosure(configuration.getBoolean(PROPERTY_IGNORE_ORG_CLOSURE, false));
    setOrgClosureStartupAction(configuration.getString(PROPERTY_ORG_CLOSURE_STARTUP_ACTION,
            OrgClosureManager.StartupAction.REBUILD_IF_NEEDED.toString()));
    setSkipOrgClosureStructureCheck(configuration.getBoolean(PROPERTY_SKIP_ORG_CLOSURE_STRUCTURE_CHECK, false));
    setStopOnOrgClosureStartupFailure(
            configuration.getBoolean(PROPERTY_STOP_ON_ORG_CLOSURE_STARTUP_FAILURE, true));
}