List of usage examples for org.apache.commons.configuration XMLConfiguration XMLConfiguration
public XMLConfiguration(URL url) throws ConfigurationException
XMLConfiguration
. From source file:com.knowbout.epg.EPGServiceTest.java
public void setUp() throws Exception { XMLConfiguration config = new XMLConfiguration("sample.epg.xml"); HashMap<String, String> hibernateProperties = new HashMap<String, String>(); Configuration database = config.subset("database"); hibernateProperties.put(Environment.DRIVER, database.getString("driver")); hibernateProperties.put(Environment.URL, database.getString("url")); hibernateProperties.put(Environment.USER, database.getString("user")); hibernateProperties.put(Environment.PASS, database.getString("password")); hibernateProperties.put(Environment.DATASOURCE, null); HibernateUtil.setProperties(hibernateProperties); super.setUp(); }
From source file:edu.cornell.med.icb.R.RConfigurationUtils.java
/** * Gets the configuration for the RServe processes. * @return The RConnectionPool configuration. * @throws ConfigurationException if the configuration cannot be built from the url * returned by {@link #getConfigurationURL()} *//*from w w w . j ava 2 s. co m*/ static XMLConfiguration getConfiguration() throws ConfigurationException { return new XMLConfiguration(getConfigurationURL()); }
From source file:com.boozallen.cognition.ingest.storm.bolt.enrich.GeoJsonPointReverseArrayBoltTest.java
@Test public void testConfigure() throws Exception { URL resource = TestResourceUtils.getResource(this.getClass(), "config.xml"); XMLConfiguration conf = new XMLConfiguration(resource); bolt.configure(conf);// www . j a v a 2 s . c o m assertThat(bolt.srcDestFieldMapping.size(), is(2)); }
From source file:com.github.steveash.typedconfig.resolver.type.ConfigurationValueResolverFactoryIntegrationTest.java
@Before public void setUp() throws Exception { xmlConfig = new XMLConfiguration("configIntegration.xml"); proxy = ConfigProxyFactory.getDefault().make(Proxy.class, xmlConfig); }
From source file:com.norconex.jefmon.model.ConfigurationDAO.java
public static JEFMonConfig loadConfig() { if (!CONFIG_FILE.exists()) { LOG.info("JEF Monitor configuration file not " + "found: \"" + CONFIG_FILE + "\". Assuming first time access of the application. "); return null; }//w w w. j ava 2 s .c o m if (!CONFIG_FILE.isFile()) { LOG.info("JEF Monitor configuration path exists but does not " + "appear to be a file: \"" + CONFIG_FILE + "\". This will likely cause startup issues. Make sure " + "the path is clear for the config file to be created."); return null; } JEFMonConfig config = new JEFMonConfig(); LOG.info("Loading JEF Monitor configuration file: " + CONFIG_FILE); try { XMLConfiguration xml = new XMLConfiguration(CONFIG_FILE); ConfigurationUtil.disableDelimiterParsing(xml); config.setInstanceName(xml.getString("instance-name", "[?]")); LOG.debug("Loading remote instances..."); config.setRemoteInstanceUrls(loadRemoteUrls(xml)); LOG.debug("Loading monitored paths..."); config.setMonitoredPaths(loadMonitoredPaths(xml)); LOG.debug("Loading default refresh interval..."); config.setDefaultRefreshInterval(loadDefaultRefreshInterval(xml)); LOG.debug("Loading job actions..."); config.setJobActions(loadJobActions(xml)); LOG.info("JEF Monitor configuration file loaded."); } catch (Exception e) { throw new JEFMonException("Cannot load JEF Monitor configuration.", e); } return config; }
From source file:de.sub.goobi.config.ConfigProjects.java
/** * Constructor./* ww w. j av a2 s . c om*/ * * @param projectTitle * project title * @param configPfad * config path */ public ConfigProjects(String projectTitle, String configPfad) throws IOException { if (!(new File(configPfad)).exists()) { throw new IOException("File not found: " + configPfad); } try { this.config = new XMLConfiguration(configPfad); } catch (ConfigurationException e) { logger.error(e); this.config = new XMLConfiguration(); } this.config.setListDelimiter('&'); this.config.setReloadingStrategy(new FileChangedReloadingStrategy()); int countProjects = this.config.getMaxIndex("project"); for (int i = 0; i <= countProjects; i++) { String title = this.config.getString("project(" + i + ")[@name]"); if (title.equals(projectTitle)) { this.projektTitel = "project(" + i + ")."; break; } } try { this.config.getBoolean(this.projektTitel + "createNewProcess.opac[@use]"); } catch (NoSuchElementException e) { this.projektTitel = "project(0)."; } }
From source file:it.jnrpe.server.XmlJNRPEConfiguration.java
@SuppressWarnings("rawtypes") @Override// ww w. ja v a 2s. c o m public void load(final File confFile) throws ConfigurationException { // Parse an ini file ServerSection serverConf = getServerSection(); CommandsSection commandSection = getCommandSection(); try { XMLConfiguration confParser = new XMLConfiguration(confFile); List<Object> vBindAddresses = confParser.getList("server.bind[@address]"); int iBindListSize = vBindAddresses.size(); for (int i = 0; i < iBindListSize; i++) { String sAddress = confParser.getString("server.bind(" + i + ")[@address]"); String useSSL = confParser.getString("server.bind(" + i + ")[@SSL]"); if (useSSL == null) { useSSL = "false"; } serverConf.addBindAddress(sAddress, "true".equalsIgnoreCase(useSSL)); } String sAcceptParams = confParser.getString("server[@accept-params]", "true"); serverConf.setAcceptParams( "true".equalsIgnoreCase(sAcceptParams) || "yes".equalsIgnoreCase(sAcceptParams)); serverConf.setPluginPath(confParser.getString("server.plugin[@path]", ".")); serverConf.setBackLogSize(confParser.getInt("server[@backlog-size]", ServerSection.DEFAULT_BACKLOG)); // TODO : move this to publicly accessible constants serverConf.setReadTimeout(confParser.getInteger("server[@read-timeout]", 10)); // TODO : move this to publicly accessible constants serverConf.setWriteTimeout(confParser.getInteger("server[@write-timeout]", 60)); List<Object> vAllowedAddresses = confParser.getList("server.allow[@ip]"); if (vAllowedAddresses != null) { for (Object address : vAllowedAddresses) { serverConf.addAllowedAddress((String) address); } } // Get the commands count ( searching for a better way...) // int iCommandsCount = Object obj = confParser.getProperty("commands.command[@name]"); int iCount = 0; if (obj != null) { if (obj instanceof List) { iCount = ((List) obj).size(); } else { iCount = 1; } } // Loop through configured commands for (int i = 0; i < iCount; i++) { String sCommandName = (String) confParser.getProperty("commands.command(" + i + ")[@name]"); String sPluginName = (String) confParser.getProperty("commands.command(" + i + ")[@plugin_name]"); String sWholeCommandLine = (String) confParser.getProperty("commands.command(" + i + ")[@params]"); if (sWholeCommandLine == null) { sWholeCommandLine = ""; } else { sWholeCommandLine += " "; } // Loop through command arguments... Object argsObj = confParser.getProperty("commands.command(" + i + ").arg[@name]"); int iArgsCount = 0; if (argsObj != null) { if (argsObj instanceof List) { iArgsCount = ((List) argsObj).size(); } else { iArgsCount = 1; } } StringBuilder commandLineBuffer = new StringBuilder(sWholeCommandLine); for (int j = 0; j < iArgsCount; j++) { String sArgName = (String) confParser .getProperty("commands.command(" + i + ").arg(" + j + ")[@name]"); Object value = confParser.getProperty("commands.command(" + i + ").arg(" + j + ")[@value]"); String sArgValue = null; if (value instanceof String) { sArgValue = (String) value; } else if (value instanceof Collection) { sArgValue = StringUtils.join((Collection) value, confParser.getListDelimiter()); } if (sArgName.length() > 1) { commandLineBuffer.append("--"); } else { commandLineBuffer.append('-'); } commandLineBuffer.append(sArgName).append(" "); if (sArgValue != null) { boolean bQuote = sArgValue.indexOf(' ') != -1; // FIXME : handle quote escaping... if (bQuote) { commandLineBuffer.append('\"'); } commandLineBuffer.append(sArgValue); if (bQuote) { commandLineBuffer.append("\""); } commandLineBuffer.append(" "); } } sWholeCommandLine = commandLineBuffer.toString(); commandSection.addCommand(sCommandName, sPluginName, sWholeCommandLine); } } catch (org.apache.commons.configuration.ConfigurationException e) { throw new ConfigurationException(e); } }
From source file:edu.emory.library.tast.database.tabscommon.VisibleAttribute.java
private static void loadConfig() { try {//from www. java 2s . c om Document document = new XMLConfiguration("table-attributes.xml").getDocument(); Node mainNode = document.getFirstChild(); if (mainNode != null) { if (mainNode.getNodeType() == Node.ELEMENT_NODE) { NodeList attrs = mainNode.getChildNodes(); for (int j = 0; j < attrs.getLength(); j++) { if (attrs.item(j).getNodeType() == Node.ELEMENT_NODE) { VisibleAttribute attr = VisibleAttribute.fromXML(attrs.item(j)); visibleAttributes.put(attr.getName(), attr); } } } } } catch (ConfigurationException e) { e.printStackTrace(); } }
From source file:com.github.steveash.typedconfig.NestedConfig3IntegrationTest.java
@Before public void setUp() throws Exception { proxy = ConfigProxyFactory.getDefault().make(Proxy.class, new XMLConfiguration("nestedConfig3.xml")); }
From source file:com.github.steveash.typedconfig.NestedConfig3ReloadIntegrationTest.java
@Before public void setUp() throws Exception { xmlConfig = new XMLConfiguration("nestedConfig3.xml"); proxy = ConfigProxyFactory.getDefault().make(Proxy.class, xmlConfig); }