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, List defaultValue);

Source Link

Document

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

Usage

From source file:com.tulskiy.musique.system.configuration.PlaylistConfiguration.java

public static List<String> getTabBounds(List<String> def) {
    Configuration config = Application.getInstance().getConfiguration();
    return (List<String>) config.getList(getTabBoundKey(), def);
}

From source file:com.github.nethad.clustermeister.provisioning.dependencymanager.DependencyConfigurationUtil.java

static void processMavenRepositories(Configuration configuration, MavenRepositorySystem repositorySystem) {

    List<Object> repoList = configuration.getList(MAVEN_REPOSITORIES, Collections.EMPTY_LIST);
    Map<String, Map<String, String>> repoSpecification = ConfigurationUtil.reduceObjectList(repoList,
            "Maven repositories must be specified as a list of objects.");
    for (Map.Entry<String, Map<String, String>> entry : repoSpecification.entrySet()) {
        String repoId = entry.getKey();
        Map<String, String> repoValues = entry.getValue();
        try {/*from   w  ww  .  ja  va 2s . c  o m*/
            String layout = ConfigurationUtil.getCheckedConfigValue(MAVEN_REPO_LAYOUT, repoValues,
                    "maven repository", repoId);
            String url = ConfigurationUtil.getCheckedConfigValue(MAVEN_REPO_URL, repoValues, "maven repository",
                    repoId);
            RemoteRepository repo = repositorySystem.createRemoteRepository(repoId, layout, url);
            logger.info("Adding repository for dependency resolution: {}.", repo);
            repositorySystem.addRepository(repo);
        } catch (Exception ex) {
            logger.warn("Could not process repository specification {}.", repoId, ex);
        }
    }
}

From source file:com.github.anba.test262.BaseTest262.java

protected static List<Object[]> collectTestCases(Configuration configuration) throws IOException {
    // base directory to search for test javascript files
    String testpath = configuration.getString("");

    // set of test-case id to exclude from testing
    List<?> values = configuration.getList("exclude", emptyList());

    // if 'true' only the excluded test cases are used, otherwise they're
    // omitted/*from w  ww. j a va2s  . co  m*/
    boolean only_excluded = configuration.getBoolean("only_excluded", false);

    // optional exclusion pattern
    String excludeRE = configuration.getString("exclude_re", "");
    Pattern exclude = Pattern.compile(excludeRE);

    return Resources.collectTestCases(testpath, values, only_excluded, exclude);
}

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

/**
 * Creates a new Rhino environment/*from   w  ww  . jav  a  2  s.c  o m*/
 */
public static <T extends GlobalObject> EnvironmentProvider<T> rhino(final Configuration configuration) {
    final int version = configuration.getInt("rhino.version", Context.VERSION_DEFAULT);
    final String compiler = configuration.getString("rhino.compiler.default");
    List<?> enabledFeatures = configuration.getList("rhino.features.enabled", emptyList());
    List<?> disabledFeatures = configuration.getList("rhino.features.disabled", emptyList());
    final Set<Integer> enabled = intoCollection(filterMap(enabledFeatures, notEmptyString, toInteger),
            new HashSet<Integer>());
    final Set<Integer> disabled = intoCollection(filterMap(disabledFeatures, notEmptyString, toInteger),
            new HashSet<Integer>());

    /**
     * Initializes the global {@link ContextFactory} according to the
     * supplied configuration
     * 
     * @see ContextFactory#initGlobal(ContextFactory)
     */
    final ContextFactory factory = new ContextFactory() {
        @Override
        protected boolean hasFeature(Context cx, int featureIndex) {
            if (enabled.contains(featureIndex)) {
                return true;
            } else if (disabled.contains(featureIndex)) {
                return false;
            }
            return super.hasFeature(cx, featureIndex);
        }

        @Override
        protected Context makeContext() {
            Context context = super.makeContext();
            context.setLanguageVersion(version);
            return context;
        }
    };

    EnvironmentProvider<RhinoGlobalObject> provider = new EnvironmentProvider<RhinoGlobalObject>() {
        @Override
        public RhinoEnv<RhinoGlobalObject> environment(final String testsuite, final String sourceName,
                final Test262Info info) {
            Configuration c = configuration.subset(testsuite);
            final boolean strictSupported = c.getBoolean("strict", false);
            final String encoding = c.getString("encoding", "UTF-8");
            final String libpath = c.getString("lib_path");

            final Context cx = factory.enterContext();
            final AtomicReference<RhinoGlobalObject> $global = new AtomicReference<>();

            final RhinoEnv<RhinoGlobalObject> environment = new RhinoEnv<RhinoGlobalObject>() {
                @Override
                public RhinoGlobalObject global() {
                    return $global.get();
                }

                @Override
                protected String getEvaluator() {
                    return compiler;
                }

                @Override
                protected String getCharsetName() {
                    return encoding;
                }

                @Override
                public void exit() {
                    Context.exit();
                }
            };

            @SuppressWarnings({ "serial" })
            final RhinoGlobalObject global = new RhinoGlobalObject() {
                {
                    cx.initStandardObjects(this, false);
                }

                @Override
                protected boolean isStrictSupported() {
                    return strictSupported;
                }

                @Override
                protected String getDescription() {
                    return info.getDescription();
                }

                @Override
                protected void failure(String message) {
                    failWith(message, sourceName);
                }

                @Override
                protected void include(Path path) throws IOException {
                    // resolve the input file against the library path
                    Path file = Paths.get(libpath).resolve(path);
                    InputStream source = Files.newInputStream(file);
                    environment.eval(file.getFileName().toString(), source);
                }
            };

            $global.set(global);

            return environment;
        }
    };

    @SuppressWarnings("unchecked")
    EnvironmentProvider<T> p = (EnvironmentProvider<T>) provider;

    return p;
}

From source file:com.github.nethad.clustermeister.provisioning.dependencymanager.DependencyConfigurationUtil.java

/**
 * Resolves preload dependencies from a {@link Configuration} and resolves 
 * them using {@link MavenRepositorySystem}.
 * /*from ww  w .j av  a 2s . c o m*/
 * @param configuration The configuration specifying preload dependencies.
 * @return All resolved dependencies as files.
 */
public static Collection<File> getConfiguredDependencies(Configuration configuration) {
    if (repositorySystem == null) {
        repositorySystem = new MavenRepositorySystem();
    }

    List<File> artifactsToPreload = new LinkedList<File>();

    addDefaultGlobalExclusions();

    List<Object> excludePatterns = configuration.getList(PRELOAD_EXCLUDES, Collections.EMPTY_LIST);
    for (Object excludePattern : excludePatterns) {
        String excludePatternString = excludePattern.toString();
        if (excludePattern != null && !excludePatternString.isEmpty()) {
            logger.info("Excluding {} from dependency resolution.", excludePattern);
            repositorySystem.addGlobalExclusion(excludePatternString);
        }
    }

    processMavenRepositories(configuration, repositorySystem);

    List<Object> artifacts = configuration.getList(PRELOAD_ARTIFACTS, Collections.EMPTY_LIST);
    for (Object artifactSpecification : artifacts) {
        logger.info("Resolving artifact {}.", artifactSpecification);
        try {
            List<File> dependencies = repositorySystem.resolveDependencies(artifactSpecification.toString());
            addToListIfUnique(dependencies, artifactsToPreload);
            logger.debug("{} resolved to {}.", artifactSpecification, dependencies);
        } catch (DependencyResolutionException ex) {
            logger.warn("Could not resolve artifact {}.", artifactSpecification, ex);
        }
    }

    List<Object> poms = configuration.getList(PRELOAD_POMS, Collections.EMPTY_LIST);
    for (Object pomPath : poms) {
        logger.info("Resolving artifacts from POM file: {}.", pomPath);
        try {
            List<File> dependencies = repositorySystem.resolveDependenciesFromPom(new File(pomPath.toString()));
            addToListIfUnique(dependencies, artifactsToPreload);
            logger.debug("{} resolved to {}.", pomPath, dependencies);
        } catch (DependencyResolutionException ex) {
            logger.warn("Could not resolve artifacts from {}.", pomPath, ex);
        }
    }

    repositorySystem = null;

    return artifactsToPreload;
}

From source file:com.github.anba.es6draft.util.Resources.java

/**
 * Filter the initially collected test cases.
 *///  www. j a va2  s .com
private static void filterTests(List<? extends TestInfo> tests, Path basedir, Configuration config)
        throws IOException {
    if (DISABLE_ALL_TESTS) {
        for (TestInfo test : tests) {
            test.setEnabled(false);
        }
    }
    if (config.containsKey("exclude.list")) {
        InputStream exclusionList = Resources.resource(config.getString("exclude.list"), basedir);
        filterTests(tests, exclusionList, config);
    }
    if (config.containsKey("exclude.xml")) {
        Set<String> excludes = readExcludeXMLs(config.getList("exclude.xml", emptyList()), basedir);
        filterTests(tests, excludes);
    }
}

From source file:com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata.java

public IndexLoadingConfigMetadata(Configuration tableDataManagerConfig) {
    List<String> valueOfLoadingInvertedIndexConfig = tableDataManagerConfig
            .getList(KEY_OF_LOADING_INVERTED_INDEX, null);
    if ((valueOfLoadingInvertedIndexConfig != null) && (!valueOfLoadingInvertedIndexConfig.isEmpty())) {
        initLoadingInvertedIndexColumnSet(valueOfLoadingInvertedIndexConfig.toArray(new String[0]));
    }//from   w w  w .  j  av a 2s.c  om

    segmentVersionToLoad = tableDataManagerConfig.getString(KEY_OF_SEGMENT_FORMAT_VERSION,
            DEFAULT_SEGMENT_FORMAT);
    enableDefaultColumns = tableDataManagerConfig.getBoolean(KEY_OF_ENABLE_DEFAULT_COLUMNS, false);
    starTreeVersionToLoad = tableDataManagerConfig.getString(KEY_OF_STAR_TREE_FORMAT_VERSION,
            CommonConstants.Server.DEFAULT_STAR_TREE_FORMAT_VERSION);
}

From source file:cross.io.misc.DefaultConfigurableFileFilter.java

@Override
public void configure(final Configuration cfg) {
    this.fileTypesToKeep = StringTools.toStringList(cfg.getList(this.getClass().getName() + ".fileTypesToKeep",
            Arrays.asList(new Object[] { "png", "jpg", "jpeg", "svg", "txt", "properties", "csv", "tsv" })));
    this.prefixesToMatch = StringTools.toStringList(cfg.getList(this.getClass().getName() + ".prefixesToMatch",
            Arrays.asList(new Object[] { "alignment" })));
    this.suffixesToMatch = StringTools.toStringList(cfg.getList(this.getClass().getName() + ".suffixesToMatch",
            Arrays.asList(new Object[] { "ChromatogramWarp" })));
}

From source file:cz.incad.kramerius.security.impl.http.IsActionAllowedFromRequest.java

boolean matchConfigurationAddress(HttpServletRequest httpReq, Configuration conf) {
    String remoteAddr = httpReq.getRemoteAddr();
    List<String> forwaredEnabled = conf.getList("x_ip_forwared_enabled_for", Arrays.asList(LOCALHOSTS));
    if (!forwaredEnabled.isEmpty()) {
        for (String pattern : forwaredEnabled) {
            if (remoteAddr.matches(pattern))
                return true;
        }//  w w w .  ja  v a 2 s. com
    }
    return false;
}

From source file:com.appeligo.search.actions.account.BaseAccountAction.java

@SuppressWarnings("unchecked")
protected void prepareYearList(Configuration config) {
    List<String> yearList = config.getList("years.year", new ArrayList());
    years = renderAsOgnlList(yearList);/*from   w  ww  .  java  2 s . c  om*/
}