List of usage examples for org.apache.commons.configuration Configuration getProperty
Object getProperty(String key);
From source file:com.w20e.socrates.process.RunnerFactoryImpl.java
/** * Create a context for the given id.// w w w.ja v a 2s . c om * * @param url * runner config id * @throws UnsupportedMediumException * in case the medium isn't supported. */ public RunnerContextImpl createContext(final URI url, final Map<String, String> options) throws UnsupportedMediumException { try { Configuration cfg = ConfigurationResource.getInstance().getConfiguration(url.toURL()); if (cfg == null) { return null; } URI modelId = new URI((String) cfg.getProperty("model.id")); LOGGER.fine("Creating model for " + modelId); Model model = ModelResource.getInstance().getModel(modelId, cfg); LOGGER.finer("Done. Now creating instance"); Instance inst = ModelResource.getInstance().createInstance(modelId, cfg); RenderConfig rCfg = ModelResource.getInstance().getRenderConfig(modelId, cfg); LOGGER.finer("Created. Let's create a new context"); RunnerContextImpl ctx = new RunnerContextImpl(null, getFormatter(url, cfg, options), createStateManager(cfg, rCfg, model, inst), model, inst, rCfg); // Allow arbitrary properties to be set on the context. String key; for (final Iterator<?> i = cfg.getKeys(); i.hasNext();) { key = (String) i.next(); if (key.startsWith("context")) { ctx.setProperty(key, cfg.getProperty(key)); } } return ctx; } catch (Exception e) { LOGGER.log(Level.SEVERE, "Couldn't create context", e); throw new UnsupportedMediumException(e.getMessage()); } }
From source file:com.linkedin.pinot.server.starter.helix.HelixInstanceDataManagerConfig.java
public HelixInstanceDataManagerConfig(Configuration serverConfig) throws ConfigurationException { _instanceDataManagerConfiguration = serverConfig; Iterator keysIterator = serverConfig.getKeys(); while (keysIterator.hasNext()) { String key = (String) keysIterator.next(); LOGGER.info("InstanceDataManagerConfig, key: {} , value: {}", key, serverConfig.getProperty(key)); }//ww w.j av a2s. c o m checkRequiredKeys(); }
From source file:it.geosolutions.opensdi2.configurations.OSDIConfigurationConverterTest.java
@Test public void propertiesOSDIconf2ValuesPositiveTest() { OSDIConfigConverter builder = new PropertiesConfigurationConverter(); OSDIConfigurationKVP conf = new OSDIConfigurationKVP("scopeIDtest", "instanceIDtest"); conf.addNew("key1", "value1"); conf.addNew("key2", "value2"); conf.addNew("key3", "value3"); Configuration confSet = (Configuration) builder.buildConfig(conf); assertTrue(confSet instanceof PropertiesConfiguration); int count = 0; Iterator<String> iter = ((PropertiesConfiguration) confSet).getKeys(); while (iter.hasNext()) { iter.next();// w ww.j av a2 s . co m count++; } assertEquals(3, count); assertEquals("value1", confSet.getProperty("key1")); assertEquals("value2", confSet.getProperty("key2")); assertEquals("value3", confSet.getProperty("key3")); }
From source file:com.kixeye.chassis.bootstrap.configuration.LoggerConfigurationWriter.java
@Override public void write(Configuration configuration, Filter filter) { if (!logger.isDebugEnabled()) { return;/*w w w . j ava 2 s . c o m*/ } StringBuilder sb = new StringBuilder(); sb.append("Configuring service with configuration properties:"); Iterator<String> keys = configuration.getKeys(); while (keys.hasNext()) { String key = keys.next(); sb.append("\n ").append(key).append("=").append(configuration.getProperty(key)); } logger.debug(sb.toString()); }
From source file:com.w20e.socrates.process.RunnerFactoryImpl.java
/** * Create a runner instance, or null if the runner cannot be created. The * runner holds a reference to the model, and will be initialized with a * workflow definition./*from w w w .j a v a 2s . c o m*/ * * @param id * questionnaire id * @param l * a <code>Locale</code> value * @param medium * a <code>String</code> value * @return a <code>Runner</code> value * @exception UnsupportedMediumException * if an error occurs */ @Override public Runner createRunner(final URI url) throws UnsupportedMediumException { if (!this.runners.containsKey(url)) { LOGGER.fine("Creating new runner for id " + url.toString()); try { Configuration cfg = ConfigurationResource.getInstance().getConfiguration(url.toURL()); if (cfg == null) { return null; } this.runners.put(url, new RunnerImpl(new URL((String) cfg.getProperty("runner.url")))); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Couldn't create runner", e); throw new UnsupportedMediumException(e.getMessage()); } } return this.runners.get(url); }
From source file:grakn.core.graql.analytics.MedianVertexProgram.java
@Override public void loadState(final Graph graph, final Configuration configuration) { super.loadState(graph, configuration); configuration.subset(RESOURCE_TYPE).getKeys().forEachRemaining(key -> statisticsResourceLabelIds .add((LabelId) configuration.getProperty(RESOURCE_TYPE + "." + key))); }
From source file:io.servicecomb.springboot.starter.configuration.CseEndpoint.java
private void append(Map<String, Object> map, Configuration config) { if (config instanceof ConfigurableEnvironmentConfiguration) { return;// w ww .j a va 2s .c o m } if (config instanceof SystemConfiguration) { return; } if (config instanceof EnvironmentConfiguration) { return; } for (Iterator<String> iter = config.getKeys(); iter.hasNext();) { String key = iter.next(); map.put(key, config.getProperty(key)); } }
From source file:com.netflix.config.ConcurrentMapConfiguration.java
/** * Create an instance by copying the properties from an existing Configuration. * Future changes to the Configuration passed in will not be reflected in this * object.//from www . j a v a2 s.c om * * @param config Configuration to be copied */ public ConcurrentMapConfiguration(Configuration config) { this(); for (Iterator i = config.getKeys(); i.hasNext();) { String name = (String) i.next(); Object value = config.getProperty(name); map.put(name, value); } }
From source file:ai.grakn.graql.internal.analytics.CommonOLAP.java
/** * Load <code>persistentProperties</code> and any hard coded fields from an apache config object for use by the * spark executor./*from w w w . j a va2 s.c o m*/ * * @param graph the tinker graph * @param configuration the apache config object containing the values */ public void loadState(final Graph graph, final Configuration configuration) { // load selected types configuration.subset(PREFIX_SELECTED_TYPE_KEY).getKeys().forEachRemaining( key -> selectedTypes.add(TypeId.of(configuration.getInt(PREFIX_SELECTED_TYPE_KEY + "." + key)))); // load user specified properties configuration.subset(PREFIX_PERSISTENT_PROPERTIES).getKeys().forEachRemaining(key -> persistentProperties .put(key, configuration.getProperty(PREFIX_PERSISTENT_PROPERTIES + "." + key))); }
From source file:com.netflix.config.ConcurrentMapConfiguration.java
/** * Copy properties of a configuration into this configuration. This method simply * iterates the keys of the configuration to be copied and call {@link #setProperty(String, Object)} * for non-null key/value.// ww w. j av a2s . c o m */ @Override public void copy(Configuration c) { if (c != null) { for (Iterator it = c.getKeys(); it.hasNext();) { String key = (String) it.next(); Object value = c.getProperty(key); if (key != null && value != null) { setProperty(key, value); } } } }