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

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

Introduction

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

Prototype

List getList(String key);

Source Link

Document

Get a List of strings associated with the given configuration key.

Usage

From source file:com.evolveum.midpoint.provisioning.ucf.impl.ConnectorFactoryIcfImpl.java

/**
 * Initialize the ICF implementation. Look for all connector bundles, get
 * basic information about them and keep that in memory.
 *//*  www .  ja va 2s. c  om*/
@PostConstruct
public void initialize() {

    // OLD
    // bundleURLs = listBundleJars();
    bundleURLs = new HashSet<URL>();

    Configuration config = midpointConfiguration.getConfiguration("midpoint.icf");

    // Is classpath scan enabled
    if (config.getBoolean("scanClasspath")) {
        // Scan class path
        bundleURLs.addAll(scanClassPathForBundles());
    }

    // Scan all provided directories
    @SuppressWarnings("unchecked")
    List<String> dirs = config.getList("scanDirectory");
    for (String dir : dirs) {
        bundleURLs.addAll(scanDirectory(dir));
    }

    for (URL u : bundleURLs) {
        LOGGER.debug("ICF bundle URL : {}", u);
    }

    connectorInfoManagerFactory = ConnectorInfoManagerFactory.getInstance();

}

From source file:com.evolveum.midpoint.provisioning.ucf.impl.connid.ConnectorFactoryConnIdImpl.java

/**
 * Initialize the ICF implementation. Look for all connector bundles, get
 * basic information about them and keep that in memory.
 *///  w  ww  . j a  v a 2s  .c o m
@PostConstruct
public void initialize() {

    // OLD
    // bundleURIs = listBundleJars();
    bundleURIs = new HashSet<>();

    Configuration config = midpointConfiguration.getConfiguration("midpoint.icf");

    // Is classpath scan enabled
    if (config.getBoolean("scanClasspath")) {
        // Scan class path
        bundleURIs.addAll(scanClassPathForBundles());
    }

    // Scan all provided directories
    @SuppressWarnings("unchecked")
    List<String> dirs = config.getList("scanDirectory");
    for (String dir : dirs) {
        bundleURIs.addAll(scanDirectory(dir));
    }

    for (URI u : bundleURIs) {
        LOGGER.debug("ICF bundle URI : {}", u);
    }

    connectorInfoManagerFactory = ConnectorInfoManagerFactory.getInstance();

}

From source file:dk.dma.ais.abnormal.analyzer.analysis.FreeFlowAnalysis.java

@Inject
public FreeFlowAnalysis(Configuration configuration, AppStatisticsService statisticsService,
        EventEmittingTracker trackingService, EventRepository eventRepository) {
    super(eventRepository, trackingService, null);
    this.statisticsService = statisticsService;

    this.xL = configuration.getInt(CONFKEY_ANALYSIS_FREEFLOW_XL, 8);
    this.xB = configuration.getInt(CONFKEY_ANALYSIS_FREEFLOW_XB, 8);
    this.dCog = configuration.getFloat(CONFKEY_ANALYSIS_FREEFLOW_DCOG, 15f);
    this.minReportingIntervalMillis = configuration
            .getInt(CONFKEY_ANALYSIS_FREEFLOW_MIN_REPORTING_PERIOD_MINUTES, 60) * 60 * 1000;

    String csvFileNameTmp = configuration.getString(CONFKEY_ANALYSIS_FREEFLOW_CSVFILE, null);
    if (csvFileNameTmp == null || isBlank(csvFileNameTmp)) {
        this.csvFileName = null;
        LOG.warn("Writing of free flow events to CSV file is disabled");
    } else {/* www  . java 2  s  .  c o m*/
        this.csvFileName = csvFileNameTmp.trim();
        LOG.info("Free flow events are appended to CSV file: " + this.csvFileName);
    }

    List<Object> bboxConfig = configuration.getList(CONFKEY_ANALYSIS_FREEFLOW_BBOX);
    if (bboxConfig != null) {
        final double n = Double.valueOf(bboxConfig.get(0).toString());
        final double e = Double.valueOf(bboxConfig.get(1).toString());
        final double s = Double.valueOf(bboxConfig.get(2).toString());
        final double w = Double.valueOf(bboxConfig.get(3).toString());
        this.areaToBeAnalysed = BoundingBox.create(Position.create(n, e), Position.create(s, w),
                CoordinateSystem.CARTESIAN);
    }

    setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_FREEFLOW_PREDICTIONTIME_MAX, -1));
    setAnalysisPeriodMillis(configuration.getInt(CONFKEY_ANALYSIS_FREEFLOW_RUN_PERIOD, 30000) * 1000);

    LOG.info(this.getClass().getSimpleName() + " created (" + this + ").");
}

From source file:com.appeligo.channelfeed.CapturePreviews.java

@Override
protected void openSources(Configuration provider) {

    XMLConfiguration config = getConfig();

    String frameSize = config.getString("videoParams[@frameSize]");
    int frameRate = config.getInt("videoParams[@frameRate]", -1);
    int audioSyncSamplesPerSecond = config.getInt("videoParams[@audioSyncSamplesPerSecond]", -1);
    int audioSamplingFrequency = config.getInt("videoParams[@audioSamplingFrequency]", -1);
    int audioBitRate = config.getInt("videoParams[@audioBitRate]", -1);
    int audioChannels = config.getInt("videoParams[@audioChannels]", -1);
    String outputFormat = config.getString("videoParams[@outputFormat]");

    log.info("frameSize=" + frameSize + ", frameRate=" + frameRate + ", audioSyncSamplesPerSecond="
            + audioSyncSamplesPerSecond + ", audioSamplingFrequency=" + audioSamplingFrequency
            + ", audioBitRate=" + audioBitRate + ", audioChannels=" + audioChannels + ", outputFormat="
            + outputFormat);//  ww  w .j a v  a2 s .co m

    int clipLengthSeconds = config.getInt("previewRules[@clipLengthSeconds]", -1);
    int delaySeconds = config.getInt("previewRules[@delaySeconds]", -1);
    // This delaySeconds could be set directly on the TVCapturer, but we want the PreviewThread to be aware
    int earliestClipSeconds = config.getInt("previewRules[@earliestClipSeconds]", -1);
    int latestClipSeconds = config.getInt("previewRules[@latestClipSeconds]", -1);
    int latestClipPercentOfDuration = config.getInt("previewRules[@latestClipPercentOfDuration]", -1);
    int maxClips = config.getInt("previewRules[@maxClips]", -1);
    int minSecondsBetweenClips = config.getInt("previewRules[@minSecondsBetweenClips]", -1);

    log.info("clipLengthSeconds=" + clipLengthSeconds + ", delaySeconds=" + delaySeconds
            + ", earliestClipSeconds=" + earliestClipSeconds + ", latestClipSeconds=" + latestClipSeconds
            + ", latestClipPercentOfDuration=" + latestClipPercentOfDuration + ", maxClips=" + maxClips
            + ", minSecondsBetweenClips=" + minSecondsBetweenClips);

    int tunerCount = provider.getList("tuners.tuner[@deviceNumber]").size();

    for (int j = 0; j < tunerCount; j++) {

        String deviceNumber = provider.getString("tuners.tuner(" + j + ")[@deviceNumber]");
        log.info("deviceNumber=" + deviceNumber);

        try {

            VideoDevice videoDevice = new VideoDevice(Integer.parseInt(deviceNumber), getFrequencyStandard());

            TVCapturer tvCapturer = new TVCapturer(videoDevice);

            if (frameSize != null && (frameSize.trim().length() > 0)) {
                tvCapturer.setFrameSize(frameSize);
            }
            if (frameRate >= 0) {
                tvCapturer.setFrameRate(frameRate);
            }
            if (audioSyncSamplesPerSecond >= 0) {
                tvCapturer.setAudioSyncSamplesPerSecond(audioSyncSamplesPerSecond);
            }
            if (audioSamplingFrequency >= 0) {
                tvCapturer.setAudioSamplingFrequency(audioSamplingFrequency);
            }
            if (audioBitRate >= 0) {
                tvCapturer.setAudioBitRate(audioBitRate);
            }
            if (audioChannels >= 0) {
                tvCapturer.setAudioChannels(audioChannels);
            }
            if (outputFormat != null && outputFormat.trim().length() > 0) {
                tvCapturer.setOutputFormat(outputFormat);
            }

            PreviewThread previewThread = new PreviewThread("Preview thread for device #" + deviceNumber);
            previewThread.setPreviewDocumentRoot(getPreviewDocumentRoot());
            previewThread.setTVCapturer(tvCapturer);
            previewThread.setEpgService(getEpgService());
            previewThread.setLineupID(getLineupID());

            if (clipLengthSeconds >= 0) {
                previewThread.setClipLengthSeconds(clipLengthSeconds);
            }
            if (delaySeconds >= 0) {
                previewThread.setDelaySeconds(delaySeconds);
            }
            if (earliestClipSeconds >= 0) {
                previewThread.setEarliestClipSeconds(earliestClipSeconds);
            }
            if (latestClipSeconds >= 0) {
                previewThread.setLatestClipSeconds(latestClipSeconds);
            }
            if (latestClipPercentOfDuration >= 0) {
                previewThread.setLatestClipPercentOfDuration(latestClipPercentOfDuration);
            }
            if (maxClips >= 0) {
                previewThread.setMaxClips(maxClips);
            }
            if (minSecondsBetweenClips >= 0) {
                previewThread.setMinSecondsBetweenClips(minSecondsBetweenClips);
            }

            Configuration tuner = provider.subset("tuners.tuner(" + j + ")");
            int stationCount = tuner.getList("stations.station[@channel]").size();
            for (int k = 0; k < stationCount; k++) {

                String channel = tuner.getString("stations.station(" + k + ")[@channel]");
                String callsign = tuner.getString("stations.station(" + k + ")[@callsign]");

                log.info("channel=" + channel + ", callsign=" + callsign);

                previewThread.addStation(callsign, channel);
            }

            previewThread.start();
        } catch (MalformedURLException e1) {
            log.error("Exception on a channel", e1);
        } catch (NumberFormatException e1) {
            log.error("Exception on a channel", e1);
        } catch (IOException e1) {
            log.error("Exception on a channel", e1);
        }
    }
}

From source file:net.sf.zekr.common.config.ApplicationConfig.java

@SuppressWarnings("unchecked")
private void initSearchInfo() {
    try {// w  ww.j a  v a 2  s  . c  om
        logger.info("Load search info...");

        File usi = new File(ApplicationPath.USER_SEARCH_INFO);
        if (!usi.exists()) {
            logger.info("User search info does not exist at " + ApplicationPath.USER_SEARCH_INFO);
            logger.info(
                    "Will make user search info with default values at " + ApplicationPath.MAIN_SEARCH_INFO);
            String searchInfoFile = ApplicationPath.MAIN_SEARCH_INFO;
            try {
                logger.info("Save user search info file to " + ApplicationPath.USER_CONFIG);
                FileUtils.copyFile(new File(searchInfoFile), usi);

                logger.debug("Load " + searchInfoFile);
                FileInputStream fis = new FileInputStream(searchInfoFile);
                searchProps = ConfigUtils.loadConfig(fis, "UTF-8");
            } catch (Exception e) {
                logger.error("Error loading search info file " + searchInfoFile);
                logger.implicitLog(e);
            }
        } else {
            String searchInfoFile = ApplicationPath.USER_SEARCH_INFO;
            try {
                String ver = null;
                boolean error = false;
                try {
                    FileInputStream fis = new FileInputStream(searchInfoFile);
                    searchProps = ConfigUtils.loadConfig(fis, "UTF-8", ApplicationPath.CONFIG_DIR);
                    ver = searchProps.getString("search.version");
                } catch (Exception e) {
                    logger.error(String.format(
                            "Error loading user search info file %s."
                                    + " Will replace it with original search info file %s.",
                            searchInfoFile, ApplicationPath.MAIN_SEARCH_INFO), e);
                    error = true;
                }
                if (!GlobalConfig.ZEKR_VERSION.equals(ver) || error) {
                    searchInfoFile = ApplicationPath.USER_CONFIG;
                    searchProps = ConfigUtils.loadConfig(new FileInputStream(searchInfoFile), "UTF-8");
                    String newName = String.format("%s_%s", res.getString("config.searchInfo.file"),
                            String.format(ver == null ? "old" : ver));
                    logger.info(String.format(
                            "Migrate search info from version %s to %s. Will rename old file to %s.", ver,
                            GlobalConfig.ZEKR_VERSION, newName));
                    FileUtils.copyFile(usi, new File(usi.getParent(), newName));
                    FileUtils.copyFile(new File(ApplicationPath.MAIN_SEARCH_INFO), usi);
                }
            } catch (Exception e) {
                logger.error("Error loading search info file " + searchInfoFile);
                logger.implicitLog(e);
            }
        }

        searchInfo = new SearchInfo();
        Configuration stopWordConf = searchProps.subset("search.stopword");
        List<String> defaultStopWord = searchProps.getList("search.stopword");
        Configuration replacePatternConf = searchProps.subset("search.pattern.replace");
        List<String> defaultReplacePattern = searchProps.getList("search.pattern.replace");
        Configuration punctuationConf = searchProps.subset("search.pattern.punct");
        String defaultPunctuation = searchProps.getString("search.pattern.punct");
        Configuration diacriticsConf = searchProps.subset("search.pattern.diacr");
        String defaultDiacritics = searchProps.getString("search.pattern.diacr");
        Configuration letterConf = searchProps.subset("search.pattern.letter");

        searchInfo.setDefaultStopWord(defaultStopWord);
        for (Iterator<String> iterator = stopWordConf.getKeys(); iterator.hasNext();) {
            String langCode = iterator.next();
            if (langCode.length() <= 0) {
                continue;
            }
            logger.debug("\tAdd stop words for: " + langCode);
            searchInfo.addStopWord(langCode, stopWordConf.getList(langCode));
        }

        searchInfo.setDefaultReplacePattern(defaultReplacePattern);
        for (Iterator<String> iterator = replacePatternConf.getKeys(); iterator.hasNext();) {
            String langCode = iterator.next();
            if (langCode.length() <= 0) {
                continue;
            }
            logger.debug("\tAdd replace patterns for: " + langCode);
            searchInfo.addReplacePattern(langCode, replacePatternConf.getList(langCode));
        }

        if (defaultPunctuation != null) {
            searchInfo.setDefaultPunctuation(Pattern.compile(defaultPunctuation));
        }
        for (Iterator<String> iterator = punctuationConf.getKeys(); iterator.hasNext();) {
            String langCode = iterator.next();
            if (langCode.length() <= 0) {
                continue;
            }
            logger.debug("\tAdd punctuation pattern for: " + langCode);
            searchInfo.setPunctuation(langCode, Pattern.compile(punctuationConf.getString(langCode)));
        }

        if (defaultDiacritics != null) {
            searchInfo.setDefaultDiacritic(Pattern.compile(defaultDiacritics));
        }
        for (Iterator<String> iterator = diacriticsConf.getKeys(); iterator.hasNext();) {
            String langCode = iterator.next();
            if (langCode.length() <= 0) {
                continue;
            }
            logger.debug("\tAdd diacritics pattern for: " + langCode);
            searchInfo.setDiacritic(langCode, Pattern.compile(diacriticsConf.getString(langCode)));
        }

        for (Iterator<String> iterator = letterConf.getKeys(); iterator.hasNext();) {
            String langCode = iterator.next();
            if (langCode.length() <= 0) {
                continue;
            }
            logger.debug("\tAdd letters range pattern for: " + langCode);
            searchInfo.setLetter(langCode, Pattern.compile(letterConf.getString(langCode)));
        }
    } catch (Exception ex) {
        logger.error("Search info not initialized correctly because of the next error."
                + " Zekr, however, will be launched.");
        logger.implicitLog(ex);
    }
}

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

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

    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:dk.dbc.opensearch.datadock.DatadockMain.java

/**
 *
 * /*ww  w  .ja  va2  s  .c  o  m*/
 * @param args
 * @throws ConfigurationException
 */
public DatadockMain(String[] args) throws ConfigurationException {
    /** Try obtaining home path of datadock. If property 'datadock.home' is not set,
     * current working directory is assumed to be home.
     */
    String datadockHome = System.getProperty("datadock.home");
    if (datadockHome == null) {
        datadockHome = new File(".").getAbsolutePath();
    } else {
        datadockHome = new File(datadockHome).getAbsolutePath();
    }
    log.info(String.format("Using datadock.home: %s", datadockHome));
    System.out.println(String.format("Using datadock.home: %s", datadockHome));

    Configuration config = null;

    // Try reading properties file from -Dproperties.file
    String localPropFileName = System.getProperty("properties.file");

    // If -Dpropfile is not set try reading from either ../config/datadock.properties or ./config/datadock.properties
    if (localPropFileName != null) {
        config = new PropertiesConfiguration(localPropFileName);
    } else {
        localPropFileName = "../config/" + propFileName;
        if (new File(localPropFileName).exists()) {
            config = new PropertiesConfiguration(localPropFileName);
        }

        localPropFileName = "./config/" + propFileName;
        if (new File(localPropFileName).exists()) {
            config = new PropertiesConfiguration(localPropFileName);
        }
    }

    // Throw new ConfigurationException if properties file could not be located.
    if (config == null) {
        throw new ConfigurationException(
                String.format("Could not load configuration from configuration file: %s; CWD: %s",
                        localPropFileName, new File(".").getAbsoluteFile()));
    }
    log.info(String.format("Using properties file: %s", localPropFileName));

    try {
        String configFile = config.getString("Log4j");
        if (new File(configFile).exists()) {
            Log4jConfiguration.configure(configFile);
        } else {
            if (configFile.startsWith("../")) {
                configFile = configFile.replaceFirst("../", "");
                if (new File(configFile).exists()) {
                    Log4jConfiguration.configure(configFile);
                } else {
                    throw new ConfigurationException(
                            String.format("Could not locate config file at: %s", config.getString("Log4j")));
                }
            } else {
                throw new ConfigurationException(
                        String.format("Could not locate config file at: %s", config.getString("Log4j")));
            }
        }
        log.info(String.format("Using config file: %s", configFile));
    } catch (ConfigurationException ex) {
        String errMsg = String.format("Logger could not be configured, will continue without logging: %s",
                ex.getMessage());
        log.error(errMsg);
        System.out.println(errMsg);
    }

    pollTime = config.getInt("MainPollTime");
    queueSize = config.getInt("QueueSize");
    corePoolSize = config.getInt("CorePoolSize");
    maxPoolSize = config.getInt("MaxPoolSize");
    keepAliveTime = config.getInt("KeepAliveTime");

    log.debug(String.format("Starting Datadock with pollTime = %s", pollTime));
    log.debug(String.format("Starting Datadock with queueSize = %s", queueSize));
    log.debug(String.format("Starting Datadock with corePoolSize = %s", corePoolSize));
    log.debug(String.format("Starting Datadock with maxPoolSize = %s", maxPoolSize));
    log.debug(String.format("Starting Datadock with keepAliveTime = %s", keepAliveTime));

    pluginFlowXmlPath = new File(config.getString("PluginFlowXmlPath"));
    pluginFlowXsdPath = new File(config.getString("PluginFlowXsdPath"));
    if (null == pluginFlowXmlPath || null == pluginFlowXsdPath) {
        throw new ConfigurationException(
                "Failed to initialize configuration values for File objects properly (pluginFlowXmlPath or pluginFlowXsdPath)");
    }
    log.debug(String.format("Starting Datadock with pluginFlowXmlPath = %s", pluginFlowXmlPath));
    log.debug(String.format("Starting Datadock with pluginFlowXsdPath = %s", pluginFlowXsdPath));

    maxToHarvest = config.getInt("MaxToHarvest");

    dataBaseNames = config.getList("OracleDataBaseNames");
    oracleCacheName = config.getString("OracleCacheName");
    oracleUrl = config.getString("OracleUrl");
    oracleUser = config.getString("OracleUserID");
    oraclePassWd = config.getString("OraclePassWd");
    minLimit = config.getString("OracleMinLimit");
    maxLimit = config.getString("OracleMaxLimit");
    initialLimit = config.getString("OracleInitialLimit");
    connectionWaitTimeout = config.getString("OracleConnectionWaitTimeout");

    usePriorityFlag = config.getBoolean("UsePriorityField");

    host = config.getString("Host");
    port = config.getString("Port");
    user = config.getString("User");
    pass = config.getString("PassPhrase");

    javascriptPath = config.getString("ScriptPath");

    fileHarvestLightDir = config.getString("ToHarvest");
    fileHarvestLightSuccessDir = config.getString("HarvestDone");
    fileHarvestLightFailureDir = config.getString("HarvestFailure");
}

From source file:org.acmsl.queryj.ConfigurationQueryJCommandImpl.java

/**
 * Retrieves the setting for given key./*  w w  w  .j a v a2 s . co  m*/
 * @param key the key.
 * @return the value for such key.
 * @param configuration the {@link Configuration configuration} settings.
 */
@Nullable
protected List<?> getList(@NotNull final String key, @NotNull final Configuration configuration) {
    return configuration.getList(key);
}

From source file:org.ambraproject.admin.filter.RedirectToAmbraFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    Configuration ambraConfiguration = ConfigurationStore.getInstance().getConfiguration();
    for (Object journal : ambraConfiguration.getList("ambra.virtualJournals.journals")) {
        String url = ambraConfiguration.getString("ambra.virtualJournals." + journal + ".url");
        log.debug("Set up to redirect requests in {} to {}", journal, url);
        journalUrls.put((String) journal, url);
    }//from   www.j  av a2  s. c  o  m
    String defaultJournal = ambraConfiguration.getString("ambra.virtualJournals.default");
    defaultJournalUrl = ambraConfiguration.getString("ambra.virtualJournals." + defaultJournal + ".url");
    log.debug("Will redirect to {} as default journal", defaultJournalUrl);
}

From source file:org.ambraproject.configuration.ConfigurationTest.java

public void testSubsetDefaults1() {
    Configuration conf = this.conf.subset("exptest.local");
    checkExpTest(conf.getList("item"));
}