List of usage examples for org.apache.commons.configuration XMLConfiguration XMLConfiguration
public XMLConfiguration(URL url) throws ConfigurationException
XMLConfiguration
. From source file:com.boozallen.cognition.ingest.storm.bolt.starter.LineRegexReplaceInRegionBoltTest.java
@Test public void testConfigureRegexRegions() throws Exception { XMLConfiguration conf = new XMLConfiguration(getResource(this.getClass(), "regexRegions.xml")); bolt.configureRegexRegions(conf);//from w w w .j a v a 2 s . c o m assertThat(bolt.groupSearchReplaceList.size(), is(2)); Triple<Pattern, String, String> entry0 = bolt.groupSearchReplaceList.get(0); Triple<Pattern, String, String> entry1 = bolt.groupSearchReplaceList.get(1); assertNotNull(entry0.getLeft()); assertThat(entry0.getMiddle(), is("regex0")); assertThat(entry0.getRight(), is("replacement0")); assertNotNull(entry1.getLeft()); assertThat(entry1.getMiddle(), is("regex1")); assertThat(entry1.getRight(), is("replacement1")); }
From source file:com.vaushell.shaarlijavaapi.ShaarliClientTest.java
/** * Initialize the test./*from ww w .j a v a2 s .c o m*/ * * @throws ConfigurationException */ @BeforeClass public void setUp() throws ConfigurationException { // My config String conf = System.getProperty("conf"); if (conf == null) { conf = "conf-local/configuration.xml"; } final XMLConfiguration config = new XMLConfiguration(conf); // New format final ShaarliTemplates templates = new ShaarliTemplates(); final List<HierarchicalConfiguration> cTemplates = config.configurationsAt("shaarli.templates.template"); if (cTemplates != null) { for (final HierarchicalConfiguration cTemplate : cTemplates) { templates.add(cTemplate.getString("[@key]"), cTemplate.getString("[@csspath]"), cTemplate.getString("[@attribut]"), cTemplate.getString("[@regex]")); } } clientUnauth = new ShaarliClient(templates, config.getString("shaarli.endpoint")); clientAuth = new ShaarliClient(templates, config.getString("shaarli.endpoint")); clientAuth.login(config.getString("shaarli.login"), config.getString("shaarli.password")); }
From source file:com.xemantic.tadedon.configuration.Configurations.java
public static XMLConfiguration newXmlConfiguration(File confFile) { checkArgument(confFile.exists(), "confFile %s does not exist", confFile); try {/* w w w . j ava 2 s . c om*/ return new XMLConfiguration(confFile); } catch (ConfigurationException e) { throw new RuntimeException("Cannot create configuration", e); } }
From source file:com.gamma.dam.conf.db.DBConfigReader.java
/** * Instantiates a new DB config reader.//from ww w. j ava 2 s . c o m */ private DBConfigReader() { String basePath = ResourceProperties.instance().getValue(ResourceProperties.DATABASE_CONF); String home = System.getProperty("DAM_HOME"); if (home != null) { basePath = home + File.separator + basePath; } try { XMLConfiguration xml = new XMLConfiguration(basePath); ReloadingStrategy strategy = new FileChangedReloadingStrategy(); xml.setReloadingStrategy(strategy); Node node = xml.getRoot(); if (node.hasChildren()) { for (ConfigurationNode n : node.getChildren()) { DBConfig db = new DBConfig(); String name = null; if (n.getAttributeCount() > 0) { for (ConfigurationNode attr : n.getAttributes()) { switch (attr.getName()) { case "id": break; case "name": name = (String) attr.getValue(); break; default: break; } } } db.parse(n); dbs.put(name, db); } } } catch (ConfigurationException e) { throw new DAMConfigurationException(e); } }
From source file:com.oprisnik.semdroid.config.XmlConfig.java
public XmlConfig(File file) throws BadConfigException, FileNotFoundException { try {//from ww w. j a v a 2s.com if (!file.exists()) { throw new FileNotFoundException("File not found " + file); } mConfiguration = new XMLConfiguration(file); // we could also use the XPath engine // for example for tables/table[@name='users']/fields/name // mConfiguration.setExpressionEngine(new XPathExpressionEngine()); mFile = file; } catch (ConfigurationException e) { throw new BadConfigException(e.getMessage()); } }
From source file:com.vaushell.superpipes.tools.scribe.linkedin.LinkedInClientTest.java
/** * Initialize the test./* w w w . j av a 2 s .com*/ * * @throws Exception */ @BeforeClass public void setUp() throws Exception { // My config String conf = System.getProperty("conf"); if (conf == null) { conf = "conf-local/test/configuration.xml"; } String datas = System.getProperty("datas"); if (datas == null) { datas = "conf-local/test/datas"; } final XMLConfiguration config = new XMLConfiguration(conf); final Path pDatas = Paths.get(datas); dispatcher.init(config, pDatas, new VC_FileFactory(pDatas)); // Test if parameters are set final ConfigProperties properties = dispatcher.getCommon("linkedin"); // Create tokens & login client.login(properties.getConfigString("key"), properties.getConfigString("secret"), dispatcher.getDatas().resolve("test-tokens/linkedin.token"), dispatcher.getVCodeFactory().create("[" + getClass().getName() + "] ")); }
From source file:m.c.m.proxyma.context.ProxymaContext.java
/** * Default constructor for this Class/*from w w w .ja v a 2 s .c om*/ * * @param contextName the name of the context to create * @param contextBaseURI Base URI of the context * @param configurationFile proxyma configuration file to load * @param logsDirectoryPath directory where to write all the logs */ public ProxymaContext(String contextName, String contextBaseURI, String configurationFile, String logsDirectoryPath) { // Initialize private attributes try { this.contextName = contextName; this.proxymaContextBasePath = contextBaseURI; this.logsDirectoryPath = logsDirectoryPath; proxyFoldersByURLEncodedName = new ConcurrentHashMap<String, ProxyFolderBean>(); proxyFoldersByDestinationHost = new ConcurrentHashMap<String, LinkedList<ProxyFolderBean>>(); config = new XMLConfiguration(configurationFile); config.setExpressionEngine(new XPathExpressionEngine()); if (this.log == null) { //create a unique logger for the whole context String name = ProxymaTags.DEFAULT_LOGGER_PREFIX + "." + contextName; this.log = Logger.getLogger(name); String logFile = logsDirectoryPath + "proxyma-" + contextName + ".log"; String level = getSingleValueParameter(ProxymaTags.GLOBAL_LOGLEVEL); int maxSize = Integer.parseInt(getSingleValueParameter(ProxymaTags.GLOBAL_LOGFILE_MAXSIZE)); int retention = Integer.parseInt(getSingleValueParameter(ProxymaTags.GLOBAL_LOGFILES_RETENTION)); ProxymaLoggersUtil.initializeContextLogger(this.log, logFile, level, maxSize, retention); } this.defaultEncoding = getSingleValueParameter(ProxymaTags.GLOBAL_DEFAULT_ENCODING); this.proxymaVersion = "Proxyma-NG (Rel. " + getSingleValueParameter(ProxymaTags.CONFIG_FILE_VERSION) + ")"; } catch (Exception ex) { Logger.getLogger("").log(Level.SEVERE, null, ex); } }
From source file:com.vaushell.superpipes.transforms.bitly.T_ShortenExpandTest.java
/** * Initialize the test.//from w w w. j ava 2 s . co m * * @throws Exception */ @BeforeClass public void setUp() throws Exception { // My config String conf = System.getProperty("conf"); if (conf == null) { conf = "conf-local/test/configuration.xml"; } String datas = System.getProperty("datas"); if (datas == null) { datas = "conf-local/test/datas"; } final XMLConfiguration config = new XMLConfiguration(conf); final Path pDatas = Paths.get(datas); dispatcher.init(config, pDatas, new VC_FileFactory(pDatas)); // Test if parameters are set. final ConfigProperties properties = dispatcher.getCommon("bitly"); assertTrue("Parameter 'username' should exist", properties.containsKey("username")); assertTrue("Parameter 'apikey' should exist", properties.containsKey("apikey")); }
From source file:com.yahoo.flowetl.services.factory.ServiceFactory.java
/** * Parses the config file and returns a configuration object for it. It * attempts to look at the extension of the file and then create the * corresponding apache commons configuration reader for that file type. * Currently this is supporting a .xml file and a .properties file. * // www. ja va 2 s. c o m * @param configFileName * * @return the configuration * * @throws ConfigurationException */ protected Configuration parseConfigFile(String configFileName) throws ConfigurationException { if (configFileName == null) { return null; } Configuration out = null; String ext = FilenameUtils.getExtension(configFileName); if (StringUtils.equalsIgnoreCase("xml", ext)) { out = new XMLConfiguration(configFileName); } else if (StringUtils.equalsIgnoreCase("properties", ext)) { out = new PropertiesConfiguration(configFileName); } return out; }
From source file:com.vaushell.superpipes.tools.scribe.fb.FacebookClientPageTest.java
/** * Initialize the test.// w ww .j a v a 2 s .c o m * * @throws Exception */ @BeforeClass public void setUp() throws Exception { // My config String conf = System.getProperty("conf"); if (conf == null) { conf = "conf-local/test/configuration.xml"; } String datas = System.getProperty("datas"); if (datas == null) { datas = "conf-local/test/datas"; } final XMLConfiguration config = new XMLConfiguration(conf); final Path pDatas = Paths.get(datas); dispatcher.init(config, pDatas, new VC_FileFactory(pDatas)); // Test if parameters are set final ConfigProperties properties = dispatcher.getCommon("facebookpage"); // Create tokens & login client.loginAsPage(properties.getConfigString("pagename"), properties.getConfigString("key"), properties.getConfigString("secret"), dispatcher.getDatas().resolve("test-tokens/facebookpage.token"), dispatcher.getVCodeFactory().create("[" + getClass().getName() + "] ")); }