List of usage examples for org.apache.commons.configuration Configuration containsKey
boolean containsKey(String key);
From source file:com.bigdata.blueprints.BigdataGraphConfiguration.java
protected BigdataGraph configure(final GraphConfigurationContext context) throws Exception { final Configuration config = context.getProperties(); if (!config.containsKey(Options.TYPE)) { throw new GraphConfigurationException("missing required parameter: " + Options.TYPE); }/*from w w w. j av a 2 s .c o m*/ final String type = config.getString(Options.TYPE).toLowerCase(); if (Options.TYPE_EMBEDDED.equals(type)) { if (config.containsKey(Options.FILE)) { final String journal = config.getString(Options.FILE); return BigdataGraphFactory.open(journal, true); } else { return BigdataGraphFactory.create(); } } else if (Options.TYPE_REMOTE.equals(type)) { if (config.containsKey(Options.SPARQL_ENDPOINT_URL)) { final String sparqlEndpointURL = config.getString(Options.SPARQL_ENDPOINT_URL); return BigdataGraphFactory.connect(sparqlEndpointURL); } if (!config.containsKey(Options.HOST)) { throw new GraphConfigurationException("missing required parameter: " + Options.HOST); } if (!config.containsKey(Options.PORT)) { throw new GraphConfigurationException("missing required parameter: " + Options.PORT); } final String host = config.getString(Options.HOST); final int port = config.getInt(Options.PORT); return BigdataGraphFactory.connect(host, port); } else { throw new GraphConfigurationException("unrecognized value for " + Options.TYPE + ": " + type); } }
From source file:es.udc.gii.common.eaf.algorithm.parallel.topology.Topology.java
/** Configures the topology. */ @Override//from w ww .ja va2s . c o m public void configure(Configuration conf) { if (!isInitialized()) { if (conf.containsKey("Races")) { this.races = conf.getInt("Races"); } else if (!MPI.Initialized()) { throw new ConfigurationException("Topology: " + "Parallel environment not initialized!"); } else { this.races = MPI.COMM_WORLD.Size(); ConfWarning w = new ConfWarning(this.getClass().getSimpleName() + ".Races", this.races); w.warn(); } doConfigure(conf); initialize(); } }
From source file:com.yahoo.bard.webservice.config.ConfigurationGraph.java
/** * Take a configuration and if it is a valid module, load it into the moduleConfigurations map and load it's * dependency moduleDependencies.// w w w.j a v a 2s . c o m * * @param configuration A configuration which may be a module * @param configName The resource name for that configuration * @param nameValidator A function which throws exceptions on module names which are not valid. */ @SuppressWarnings("unchecked") private void addVertex(Configuration configuration, String configName, Consumer<String> nameValidator) { if (!configuration.containsKey(MODULE_NAME_KEY)) { // This may be the result of another library using one of our configuration names LOG.warn(MODULE_NAME_MISSING.logFormat(configName)); return; } String moduleName = configuration.getString(MODULE_NAME_KEY); nameValidator.accept(moduleName); LOG.debug(MODULE_FOUND_MESSAGE.logFormat(moduleName, configName)); if (moduleConfigurations.containsKey(moduleName)) { LOG.error(MODULE_NAME_DUPLICATION.format(configName, moduleName)); throw new SystemConfigException(MODULE_NAME_DUPLICATION.format(configName, moduleName)); } moduleConfigurations.put(moduleName, configuration); List<String> dependencies = new ArrayList<>( configuration.getList(DEPENDENT_MODULE_KEY, Collections.<String>emptyList())); // later dependencies have higher precedence. Store moduleDependencies in precedence order descending Collections.reverse(dependencies); moduleDependencies.put(moduleName, dependencies); }
From source file:es.udc.gii.common.eaf.algorithm.operator.replace.mmga.ParetoFrontReplaceOperator.java
@Override public void configure(Configuration conf) { /* Default values */ int maxPFS = 100; int hypDiv = 25; if (conf.containsKey("MaximumParetoFrontSize")) { maxPFS = conf.getInt("MaximumParetoFrontSize"); } else {/*from w w w. j a v a 2s.c om*/ (new ConfWarning("ParetoFrontReplaceOperator.MaximumPareto" + "FrontSize", maxPFS)).warn(); } if (conf.containsKey("HypercubeDivisions")) { hypDiv = conf.getInt("HypercubeDivisions"); } else { (new ConfWarning("ParetoFrontReplaceOperator.HypercubeDivisions", hypDiv)).warn(); } setMaximumParetoFrontSize(maxPFS); setHypercubeDivisions(hypDiv); }
From source file:com.github.rnewson.couchdb.lucene.LuceneServlet.java
private Couch getCouch(final HttpServletRequest req) throws IOException { final String sectionName = new PathParts(req).getKey(); final Configuration section = ini.getSection(sectionName); if (!section.containsKey("url")) { throw new FileNotFoundException(sectionName + " is missing or has no url parameter."); }/*from w w w . ja v a2 s . c o m*/ return new Couch(client, section.getString("url")); }
From source file:com.linkedin.pinot.core.data.manager.config.FileBasedInstanceDataManagerConfig.java
public FileBasedInstanceDataManagerConfig(Configuration serverConfig) throws ConfigurationException { _instanceDataManagerConfiguration = serverConfig; checkRequiredKeys();/*from w ww. j a v a 2 s .c o m*/ for (String tableName : getTableNames()) { Configuration tableConfig = _instanceDataManagerConfiguration.subset(tableName); tableConfig.addProperty(KEY_OF_TABLE_NAME, tableName); if (!tableConfig.containsKey(KEY_OF_TABLE_DATA_DIRECTORY)) { tableConfig.addProperty(KEY_OF_TABLE_DATA_DIRECTORY, getInstanceDataDir() + "/" + tableName + "/index/node" + getInstanceId()); } _tableDataManagerConfigMap.put(tableName, new TableDataManagerConfig(tableConfig)); } }
From source file:es.udc.gii.common.eaf.algorithm.operator.reproduction.mutation.de.mutationStrategy.CurrentToRandomMutationStrategy.java
@Override public void configure(Configuration conf) { ConfWarning w = null;//from www . j a v a2s . c o m try { super.configure(conf); if (conf.containsKey("K.Class")) { this.K_plugin = (Parameter) Class.forName(conf.getString("K.Class")).newInstance(); this.K_plugin.configure(conf.subset("K")); } else { w = new ConfWarning(this.getClass().getSimpleName() + ".K", this.K_plugin.getClass().getSimpleName()); w.warn(); } if (w != null) { w.warn(); } } catch (Exception ex) { throw new ConfigurationException(this.getClass(), ex); } }
From source file:es.udc.gii.common.eaf.algorithm.operator.reproduction.mutation.de.mutationStrategy.CurrentToPBestMutationStrategy.java
@Override public void configure(Configuration conf) { ConfWarning w = null;/*from ww w .j a v a 2 s . com*/ super.configure(conf); if (conf.containsKey("p")) { this.p = conf.getDouble("p"); } else { w = new ConfWarning(this.getClass().getSimpleName() + ".p", this.p); } if (conf.containsKey("archive")) { this.archive = conf.getBoolean("archive"); } else { w = new ConfWarning(this.getClass().getSimpleName() + ".archive", Boolean.toString(this.archive)); } if (w != null) { w.warn(); } }
From source file:es.udc.gii.common.eaf.algorithm.operator.reproduction.ColonizationOperator.java
@Override public void configure(Configuration conf) { ConfWarning w;/*from ww w . j a va2 s .c o m*/ try { if (conf.containsKey("Rho.Class")) { this.rho = (Parameter) Class.forName(conf.getString("Rho.Class")).newInstance(); this.rho.configure(conf.subset("Rho")); } else { w = new ConfWarning("Rho", this.rho.toString()); w.warn(); } if (conf.containsKey("Lambda.Class")) { this.lambdaGenerator = (Parameter) Class.forName(conf.getString("Lambda.Class")).newInstance(); this.lambdaGenerator.configure(conf.subset("Lambda")); } else { w = new ConfWarning("Lambda", this.lambdaGenerator.toString()); w.warn(); } if (conf.containsKey("Tau.Class")) { this.tau = (Parameter) Class.forName(conf.getString("Tau.Class")).newInstance(); this.tau.configure(conf.subset("Tau")); } else { w = new ConfWarning("Tau", this.tau.toString()); w.warn(); } if (conf.containsKey("Chooser.Class")) { this.chooser = (IndividualChooser) Class.forName(conf.getString("Chooser.Class")).newInstance(); this.chooser.configure(conf.subset("Chooser")); } else { w = new ConfWarning("Chooser", this.chooser.toString()); w.warn(); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.feedzai.fos.api.config.FosConfig.java
/** * Creates a new instance of the {@link FosConfig} class. * * @param configuration The base configuration to use. *///from www .j a v a 2s. co m public FosConfig(Configuration configuration) { checkNotNull(configuration, "Configuration cannot be null."); checkArgument(configuration.containsKey(FACTORY_NAME), "The configuration parameter " + FACTORY_NAME + " should be defined."); this.config = configuration; this.embeddedRegistry = configuration.getBoolean(EMBEDDED_REGISTRY, false); this.registryPort = configuration.getInt(REGISTRY_PORT, Registry.REGISTRY_PORT); this.factoryName = configuration.getString(FACTORY_NAME); this.headerLocation = configuration.getString(HEADER_LOCATION, "models"); this.threadPoolSize = configuration.getInt(THREADPOOL_SIZE, 20); this.scoringPort = configuration.getInt(SCORING_PORT, DEFAULT_SCORING_PORT); }