List of usage examples for org.apache.commons.configuration Configuration getString
String getString(String key);
From source file:com.boozallen.cognition.ingest.storm.topology.ConfigurableIngestTopology.java
String getTopologyName(Configuration topologyConf) { String topologyName = topologyConf.getString(TOPOLOGY_NAME); Validate.notBlank(topologyName, "Missing topology name"); return topologyName; }
From source file:com.parallax.server.blocklyprop.rest.RestProfile.java
@Inject public void setConfiguration(Configuration configuration) { this.configuration = configuration; cloudSessionLocalUserService = new CloudSessionLocalUserService( configuration.getString("cloudsession.server"), configuration.getString("cloudsession.baseurl")); cloudSessionUserService = new CloudSessionUserService(configuration.getString("cloudsession.baseurl")); }
From source file:cz.cas.lib.proarc.common.config.AppConfigurationTest.java
@Test public void testOverrideProperty() throws Exception { // init proarc.cfg Properties props = new Properties(); final String expPropValue = "overriddenValue"; props.put(TEST_DEFAULT_PROPERTY_NAME, expPropValue); createConfigFile(props, proarcCfg);/*from w w w . ja va2 s . c o m*/ AppConfiguration pconfig = factory.create(new HashMap<String, String>() { { put(AppConfiguration.PROPERTY_APP_HOME, confHome.toString()); } }); Configuration config = pconfig.getConfiguration(); assertEquals(expPropValue, config.getString(TEST_DEFAULT_PROPERTY_NAME)); }
From source file:com.evolveum.midpoint.init.ConfigurableProtectorFactory.java
public void init() { Configuration config = configuration.getConfiguration(PROTECTOR_CONFIGURATION); protectorConfig = new ProtectorConfiguration(config); //Extract file if not exists if (config.getString("midpoint.home") == null) { return;//www.j a va 2 s . co m } File ks = new File(protectorConfig.getKeyStorePath()); if (ks.exists()) { return; } //todo improve FileOutputStream fos = null; try { KeyStore keystore = KeyStore.getInstance("jceks"); char[] password = "changeit".toCharArray(); keystore.load(null, password); KeyGenerator keyGen = KeyGenerator.getInstance("AES"); keyGen.init(128); SecretKey secretKey = keyGen.generateKey(); keystore.setKeyEntry("default", secretKey, "midpoint".toCharArray(), null); fos = new FileOutputStream(protectorConfig.getKeyStorePath()); keystore.store(fos, password); fos.close(); } catch (Exception ex) { throw new SystemException("Couldn't generate keystore, reason: " + ex.getMessage(), ex); } finally { IOUtils.closeQuietly(fos); } }
From source file:com.microrisc.simply.init.SimpleInitObjectsFactory.java
/** * Creates protocol layer./*from ww w. ja va 2 s .c o m*/ * @param networkLayerService network layer service to use * @param msgConvertor message convertor to use * @param configuration source configuration * @return protocol layer * @throws java.lang.Exception if an error has occured during creating of * protocol layer */ protected ProtocolLayer createProtocolLayer(NetworkLayerService networkLayerService, MessageConvertor msgConvertor, Configuration configuration) throws Exception { String protoClassName = configuration.getString("protocolLayer.class"); Class protoClass = Class.forName(protoClassName); java.lang.reflect.Constructor constructor = protoClass.getConstructor(NetworkLayerService.class, MessageConvertor.class); return (ProtocolLayer) constructor.newInstance(networkLayerService, msgConvertor); }
From source file:com.microrisc.simply.init.SimpleInitObjectsFactory.java
/** * Create protocol mapping.//from ww w. j a v a2 s. co m * @param configuration input configuration * @return protocol mapping * @throws java.lang.Exception if an error has occured during creating of * protocol mapping */ protected ProtocolMapping createProtocolMapping(Configuration configuration) throws Exception { String factoryClassName = configuration.getString("protocolLayer.protocolMapping.factory.class"); Class factoryClass = Class.forName(factoryClassName); java.lang.reflect.Constructor constructor = factoryClass.getConstructor(); ProtocolMappingFactory protoFactory = (ProtocolMappingFactory) constructor.newInstance(); return protoFactory.createProtocolMapping(); }
From source file:com.microrisc.simply.init.SimpleInitObjectsFactory.java
/** * Creates network layer./*from w ww . j a va2s . c o m*/ * @param connectionStorage connection storage to use * @param configuration input configuration * @return network layer * @throws java.lang.Exception if an error has occured during creating of * network layer */ protected NetworkLayer createNetworkLayer(NetworkConnectionStorage connectionStorage, Configuration configuration) throws Exception { String factoryClassName = configuration.getString("networkLayer.factory.class"); Class factoryClass = Class.forName(factoryClassName); java.lang.reflect.Constructor constructor = factoryClass.getConstructor(); AbstractNetworkLayerFactory factory = (AbstractNetworkLayerFactory) constructor.newInstance(); return factory.getNetworkLayer(connectionStorage, configuration); }
From source file:edu.kit.dama.mdm.audit.impl.AuditManager.java
/** * Creates an instance of the configured authenticator defined in a * subsection of pConfig named 'authenticators'. The root node of the * section also contains the implementation class. Depending on the * implementation, there might be further child nodes containing specific * configuration values for the adapter implementation. * * @param <T> Adapter class implementing IConfigurableAdapter. * @param pConfig The configuration used to obtain the Authenticator. * * @return An instance of the created Authenticator implementation. * * @throws ConfigurationException if anything goes wrong (e.g. if the * provided adapter class was not found, instantiation or configuration * failed...)//www .j a va2s . c o m */ private <T extends IConfigurableAdapter> T createAuditAdapterInstance(Configuration pConfig) throws ConfigurationException { try { String adapterClass = pConfig.getString("[@class]"); //check adapter class if (adapterClass == null || adapterClass.length() < 1) { throw new ConfigurationException( "No valid handler class attribute found for adapter 'AuditAdapter'"); } LOGGER.debug("Creating adapter instance for 'AuditAdapter'"); LOGGER.debug(" * Adapter class: '{}'", adapterClass); //create and configure instance Class clazz = Class.forName(adapterClass); Object inst = clazz.getConstructor().newInstance(); ((T) inst).configure(pConfig); return (T) inst; } catch (ClassNotFoundException cnfe) { throw new ConfigurationException("Failed to locate adapter class for adapter 'AuditAdapter'", cnfe); } catch (InstantiationException | IllegalAccessException | InvocationTargetException ie) { throw new ConfigurationException( "Failed to instantiate and configure adapter for adapter 'AuditAdapter'", ie); } catch (NoSuchMethodException nsme) { throw new ConfigurationException("Invalid adapter class for adapter 'AuditAdapter'", nsme); } catch (ClassCastException cce) { throw new ConfigurationException( "Adapter instance for adapter 'AuditAdapter' does not implement IConfigurableAdapter interface", cce); } }
From source file:edu.lternet.pasta.portal.statistics.GrowthStats.java
public GrowthStats() { Configuration options = ConfigurationListener.getOptions(); String dbDriver = options.getString("db.Driver"); String dbUrl = options.getString("db.pkg.URL"); String dbUser = options.getString("db.User"); String dbPassword = options.getString("db.Password"); this.databaseClient = new DatabaseClient(dbDriver, dbUrl, dbUser, dbPassword); }
From source file:com.parallax.server.blocklyprop.security.oauth.GoogleAuthenticator.java
@Inject public void setConfiguration(Configuration configuration) { if (configuration.getBoolean("oauth.google.enabled", false)) { ServiceBuilder serviceBuilder = new ServiceBuilder(); serviceBuilder.apiKey(configuration.getString("oauth.google.key")); serviceBuilder.apiSecret(configuration.getString("oauth.google.secret")); serviceBuilder.callback(configuration.getString("oauth.google.callback")); service = serviceBuilder.scope("https://www.googleapis.com/auth/userinfo.email") .build(GoogleApi20.instance()); active = true;/*from ww w . j av a 2 s . c o m*/ } }