List of usage examples for org.apache.commons.configuration PropertiesConfiguration PropertiesConfiguration
public PropertiesConfiguration(URL url) throws ConfigurationException
From source file:com.impetus.kundera.ycsb.YCSBBaseTest.java
/** * @throws ConfigurationException/* ww w . j av a 2s .com*/ * @throws IOException * @throws NumberFormatException */ protected void onRead() throws ConfigurationException, NumberFormatException, IOException { String[] workLoadList = config.getStringArray("workload.file"); PropertiesConfiguration workLoadConfig = new PropertiesConfiguration( workLoadPackage + "/" + workLoadList[0]); workLoadConfig.setProperty("readproportion", "1"); workLoadConfig.setProperty("updateproportion", "0"); workLoadConfig.setProperty("scanproportion", "0"); workLoadConfig.setProperty("insertproportion", "0"); workLoadConfig.save(); config.setProperty("workload.file", workLoadList[0]); config.save(); process(); }
From source file:com.autentia.intra.util.ConfigurationUtil.java
/** * Constructor// w w w. jav a2 s . c om * * @param jndiPathVar JNDI variable in which configuration directory is stored * @param file path to configuration file */ public ConfigurationUtil(String jndiPathVar, String file) throws ConfigurationException, NamingException { Context ctx = new InitialContext(); configDir = (String) ctx.lookup(jndiPathVar); if (!configDir.endsWith("/") && !configDir.endsWith("\\")) { configDir += "/"; } config = new PropertiesConfiguration(configDir + file); }
From source file:net.i2cat.netconf.test.BaseNetconfTest.java
@Test public void testSessionContext() throws Exception { SessionContext sessionContext = new SessionContext(); sessionContext.newConfiguration(new PropertiesConfiguration("test-default.properties")); log.info("LOG FILE: " + sessionContext.getLogFileXML()); log.info("LOG RESPONSE: " + sessionContext.isLogRespXML()); log.info("NUMBER CONFIGS: " + sessionContext.getNumberOfConfigurations()); }
From source file:com.autentia.tnt.test.utils.ConfigurationUtilForTesting.java
/** * Constructor//from www . j a v a 2 s .com * * @param jndiPathVar * JNDI variable in which configuration directory is stored * @param file * path to configuration file */ public ConfigurationUtilForTesting(String jndiPathVar, String file) throws ConfigurationException, NamingException { super(); configDir = System.getProperty("user.dir") + jndiPathVar; if (!configDir.endsWith("/") && !configDir.endsWith("\\")) { configDir += "/"; } config = new PropertiesConfiguration(configDir + file); }
From source file:dk.itst.oiosaml.configuration.SAMLConfiguration.java
public static Configuration getCommonConfiguration() throws IOException { CompositeConfiguration conf = new CompositeConfiguration(); Enumeration<URL> resources = SAMLConfiguration.class.getClassLoader() .getResources("oiosaml-common.properties"); while (resources.hasMoreElements()) { URL u = resources.nextElement(); log.debug("Loading config from " + u); try {/*w ww. j av a2s. c o m*/ conf.addConfiguration(new PropertiesConfiguration(u)); } catch (ConfigurationException e) { log.error("Cannot load the configuration file", e); throw new WrappedException(Layer.DATAACCESS, e); } } return conf; }
From source file:fr.mby.portal.coreimpl.configuration.PropertiesConfigurationManager.java
@Override public PropertiesConfiguration initConfiguration(final String key, final Class<?> valueType, final String tag) throws IllegalArgumentException, ConfigurationException { Assert.hasText(key, "No key provided !"); if (this.configurationByKey.containsKey(key)) { throw new IllegalArgumentException("Configuration element already initialized for key: " + key + " !"); }//from w w w . ja v a2s . c om Assert.notNull(valueType, "No value type provided !"); Assert.hasText(tag, "No tag provided !"); final String propertiesFileName = FilenameUtils.concat(this.configFileDirectory, key + ".properties"); final File propertiesFile = new File(propertiesFileName); final PropertiesConfiguration config = new PropertiesConfiguration(propertiesFile); this.configurationByKey.put(key, config); this.valueTypeByKey.put(key, valueType); this.tagConfigurationKey(key, tag); return config; }
From source file:edu.usc.goffish.gopher.impl.client.DeploymentTool.java
public void setup(String gofsConfig, String managerHost, String coordinatorHost, boolean persist) throws IOException, ConfigurationException { int numberOfProcessors = 0; PropertiesConfiguration gofs = new PropertiesConfiguration(gofsConfig); gofs.load();//from ww w .ja v a 2 s .co m String nameNodeRestAPI = gofs.getString(GoFSFormat.GOFS_NAMENODE_LOCATION_KEY); INameNode nameNode = new RemoteNameNode(URI.create(nameNodeRestAPI)); numberOfProcessors = nameNode.getDataNodes().size(); // generate flow graph. FloeGraphGenerator generator = new FloeGraphGenerator(); OMElement xmlOm = generator.createFloe(numberOfProcessors); xmlOm.build(); try { JAXBContext ctx = JAXBContext.newInstance(FloeGraph.class); Unmarshaller um = ctx.createUnmarshaller(); FloeGraph floe = (FloeGraph) um.unmarshal(xmlOm.getXMLStreamReader()); if (persist) { FileOutputStream fileOutputStream = new FileOutputStream(new File(FLOE_GRAPH_PATH)); ctx.createMarshaller().marshal(floe, fileOutputStream); } DefaultClientConfig config = new DefaultClientConfig(); config.getProperties().put(ClientConfig.FEATURE_DISABLE_XML_SECURITY, true); config.getFeatures().put(ClientConfig.FEATURE_DISABLE_XML_SECURITY, true); Client c = Client.create(config); WebResource r = c .resource("http://" + coordinatorHost + ":" + COORDINATOR_PORT + "/Coordinator/createFloe"); c.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true); ClientResponse response; c.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true); response = r.post(ClientResponse.class, floe); StartFloeInfo startFloeInfo = response.getEntity(StartFloeInfo.class); createClientConfig(startFloeInfo, managerHost, coordinatorHost); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:fr.jetoile.hadoopunit.component.HdfsBootstrap.java
private void loadConfig() throws BootstrapException { HadoopUtils.setHadoopHome();/* w w w . ja v a 2 s . c o m*/ try { configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { throw new BootstrapException("bad config", e); } port = configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY); httpPort = configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_HTTP_PORT_KEY); tempDirectory = configuration.getString(HadoopUnitConfig.HDFS_TEMP_DIR_KEY); numDatanodes = configuration.getInt(HadoopUnitConfig.HDFS_NUM_DATANODES_KEY); enablePermission = configuration.getBoolean(HadoopUnitConfig.HDFS_ENABLE_PERMISSIONS_KEY); format = configuration.getBoolean(HadoopUnitConfig.HDFS_FORMAT_KEY); enableRunningUserAsProxy = configuration .getBoolean(HadoopUnitConfig.HDFS_ENABLE_RUNNING_USER_AS_PROXY_USER); }
From source file:com.nokia.ant.taskdefs.AntConfigurationTask.java
private void importFile(final File file) { try {/*from ww w.j a v a 2 s . c om*/ String filename = file.getName(); Configuration config = null; if (filename.endsWith(".txt")) { config = new PropertiesConfiguration(file); } else if (filename.endsWith(".xml")) { config = new XMLConfiguration(file); } Iterator keysIter = config.getKeys(); while (keysIter.hasNext()) { String key = (String) keysIter.next(); getProject().setProperty(key, config.getString(key)); } } catch (ConfigurationException e) { throw new BuildException("Not able to import the ANT file " + e.getMessage()); } }
From source file:fr.inria.corese.rdftograph.driver.TitanDriver.java
@Override public Graph createDatabase(String dbPathTemp) throws IOException { File f = new File(dbPathTemp); dbPath = f.getAbsolutePath();/*from www . j a v a 2 s .c o m*/ super.createDatabase(dbPath); PropertiesConfiguration configuration = null; File confFile = new File(dbPath + "/conf.properties"); try { configuration = new PropertiesConfiguration(confFile); } catch (ConfigurationException ex) { Logger.getLogger(TitanDriver.class.getName()).log(Level.SEVERE, null, ex); } configuration.setProperty("schema.default", "none"); configuration.setProperty("storage.batch-loading", true); // configuration.setProperty("storage.batch-loading", false); configuration.setProperty("storage.backend", "berkeleyje"); configuration.setProperty("storage.directory", dbPath + "/db"); configuration.setProperty("storage.buffer-size", 50_000); // configuration.setProperty("storage.berkeleyje.cache-percentage", 50); // configuration.setProperty("storage.read-only", true); configuration.setProperty("index.search.backend", "elasticsearch"); configuration.setProperty("index.search.directory", dbPath + "/es"); configuration.setProperty("index.search.elasticsearch.client-only", false); configuration.setProperty("index.search.elasticsearch.local-mode", true); configuration.setProperty("index.search.refresh_interval", 600); configuration.setProperty("ids.block-size", 50_000); configuration.setProperty("cache.db-cache", true); configuration.setProperty("cache.db-cache-size", 250_000_000); configuration.setProperty("cache.db-cache-time", 0); // configuration.setProperty("cache.tx-dirty-size", 100_000); // to make queries faster configuration.setProperty("query.batch", true); configuration.setProperty("query.fast-property", true); configuration.setProperty("query.force-index", false); configuration.setProperty("query.ignore-unknown-index-key", true); try { configuration.save(); } catch (ConfigurationException ex) { Logger.getLogger(TitanDriver.class.getName()).log(Level.SEVERE, null, ex); } g = TitanFactory.open(configuration); TitanManagement mgmt = getTitanGraph().openManagement(); if (!mgmt.containsVertexLabel(RDF_VERTEX_LABEL)) { mgmt.makeVertexLabel(RDF_VERTEX_LABEL).make(); } if (!mgmt.containsEdgeLabel(RDF_EDGE_LABEL)) { mgmt.makeEdgeLabel(RDF_EDGE_LABEL).multiplicity(Multiplicity.MULTI).make(); } mgmt.commit(); makeIfNotExistProperty(EDGE_P); makeIfNotExistProperty(VERTEX_VALUE); makeIfNotExistProperty(VERTEX_LARGE_VALUE); makeIfNotExistProperty(EDGE_G); makeIfNotExistProperty(EDGE_S); makeIfNotExistProperty(EDGE_O); makeIfNotExistProperty(KIND); makeIfNotExistProperty(TYPE); makeIfNotExistProperty(LANG); createIndexes(); return g; }