List of usage examples for org.apache.commons.configuration XMLConfiguration XMLConfiguration
public XMLConfiguration(URL url) throws ConfigurationException
XMLConfiguration
. From source file:org.apache.rya.indexing.smarturi.duplication.conf.DuplicateDataConfig.java
/** * Creates a new instance of {@link DuplicateDataConfig}. * @param xmlFilePath the config's XML file path. (not {@code null}) * @throws ConfigurationException/*from ww w.jav a 2 s . c o m*/ */ public DuplicateDataConfig(final String xmlFileLocation) throws ConfigurationException { this(new XMLConfiguration(requireNonNull(xmlFileLocation))); }
From source file:org.apache.stratos.autoscaler.util.ConfUtil.java
private ConfUtil(String configFilePath) { log.info("Loading configuration....."); try {/*from w w w. j a v a 2 s . c o m*/ File confFile; if (configFilePath != null && !configFilePath.isEmpty()) { confFile = new File(configFilePath); } else { confFile = new File(CarbonUtils.getCarbonConfigDirPath(), Constants.AUTOSCALER_CONFIG_FILE_NAME); } config = new XMLConfiguration(confFile); } catch (ConfigurationException e) { log.error("Unable to load autoscaler configuration file", e); config = new XMLConfiguration(); // continue with default values } }
From source file:org.apache.stratos.common.util.ConfUtil.java
private ConfUtil(String configFilePath) { log.info("Loading configuration....."); try {//from w w w .j a v a 2 s.c o m File confFile; if (configFilePath != null && !configFilePath.isEmpty()) { confFile = new File(configFilePath); } else { confFile = new File(CarbonUtils.getCarbonConfigDirPath(), CONFIG_FILE_NAME); } config = new XMLConfiguration(confFile); } catch (ConfigurationException e) { log.error("Unable to load autoscaler configuration file", e); config = new XMLConfiguration(); // continue with default values } }
From source file:org.apache.stratos.metadata.client.config.MetaDataClientConfig.java
private void loadConfig(String configFilePath) { if (StringUtils.isEmpty(configFilePath)) { throw new IllegalArgumentException("Configuration file path can not be null or empty"); }//from w w w . j av a2 s.c om try { config = new XMLConfiguration(new File(configFilePath)); } catch (ConfigurationException e) { String errorMsg = "Unable to load configuration file at " + configFilePath; throw new RuntimeException(errorMsg); } }
From source file:org.apache.stratos.metadata.service.util.ConfUtil.java
private ConfUtil(String configFilePath) { log.debug("Loading configuration....."); try {//from www . j a va 2s .c o m File confFile; if (StringUtils.isNotEmpty(configFilePath)) { confFile = new File(configFilePath); } else { confFile = new File(CarbonUtils.getCarbonConfigDirPath(), Constants.METADATASERVICE_CONFIG_FILE_NAME); } config = new XMLConfiguration(confFile); } catch (ConfigurationException e) { log.error("Unable to load autoscaler configuration file", e); config = new XMLConfiguration(); // continue with default values } }
From source file:org.apache.tamaya.commons.XmlConfigurationFormat.java
@Override public ConfigurationData readConfiguration(String name, InputStream inputStream) { PropertyValue data = PropertyValue.createObject(); data.setMeta("name", name); data.setMeta("format.class", getClass().getName()); try {//ww w . j av a 2s . c o m XMLConfiguration commonXmlConfiguration; File file = new File(name); if (file.exists()) { commonXmlConfiguration = new XMLConfiguration(file); } else { commonXmlConfiguration = new XMLConfiguration(new URL(name)); } Iterator<String> keyIter = commonXmlConfiguration.getKeys(); while (keyIter.hasNext()) { String key = keyIter.next(); ((ObjectValue) data).setValue(key, commonXmlConfiguration.getString(key)); } } catch (Exception e) { throw new ConfigException("Failed to parse xml-file format from " + name, e); } return new ConfigurationData(name, this, data); }
From source file:org.apache.tinkerpop.gremlin.structure.util.GraphFactory.java
private static Configuration getConfiguration(final File configurationFile) { if (!configurationFile.isFile()) throw new IllegalArgumentException(String.format( "The location configuration must resolve to a file and [%s] does not", configurationFile)); try {/*from w w w . j a v a2s. c o m*/ final String fileName = configurationFile.getName(); final String fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1); switch (fileExtension) { case "yml": case "yaml": final YamlConfiguration config = new YamlConfiguration(); config.load(configurationFile); return config; case "xml": return new XMLConfiguration(configurationFile); default: return new PropertiesConfiguration(configurationFile); } } catch (final ConfigurationException e) { throw new IllegalArgumentException( String.format("Could not load configuration at: %s", configurationFile), e); } }
From source file:org.apereo.lap.services.ConfigurationService.java
/** * @param pipelineConfigFile a File for the XML for a pipeline config * @return the pipeline config OR null if the config cannot be loaded *//*w ww . j a va 2s. c o m*/ PipelineConfig processPipelineConfigFile(File pipelineConfigFile) { XMLConfiguration xmlcfg = null; try { xmlcfg = new XMLConfiguration(pipelineConfigFile); } catch (ConfigurationException e) { logger.error("Invalid XML in pipeline config file (" + pipelineConfigFile.getAbsolutePath() + ") (cannot process file): " + e); } PipelineConfig plcfg = PipelineConfig.makeConfigFromXML(this, storage, xmlcfg); if (plcfg.isValid()) { logger.info("Pipeline config (" + plcfg.getType() + ") loaded from: " + pipelineConfigFile.getAbsolutePath()); } else { logger.warn("Invalid pipeline config file (" + pipelineConfigFile.getAbsolutePath() + "): " + plcfg.getInvalidReasons()); plcfg = null; } return plcfg; }
From source file:org.apereo.lap.services.InputHandlerServiceTest.java
@SuppressWarnings("unchecked") @Test//from w w w. j a v a 2 s . c o m public void testLoadInputType() throws Exception { assertNotNull(configuration); assertNotNull(storage); logger.info("Successful Test in intializing the configuration and storage"); /* Testing using XMLConfiguration config */ XMLConfiguration xmlcfg = null; xmlcfg = new XMLConfiguration( configuration.getApplicationHomeDirectory().resolve(Paths.get("pipelines", "sample.xml")).toFile()); List<HierarchicalConfiguration> inputFields = xmlcfg.configurationsAt("inputs.fields.field"); for (HierarchicalConfiguration field : inputFields) { assertNotNull(BaseInputHandlerService.getInputHandler("csv", field, configuration, storage)); logger.info( "Test Successful in loading Inputhandler of field:" + field + " of type 'csv' from sample.xml"); } /* Testing using pipeline config */ PipelineConfig pipelineConfig = configuration.getPipelineConfig("sample"); assertNotNull(pipelineConfig); logger.info("Test Successful in loading 'sample' pipeline using configuration object"); List<BaseInputHandlerService> inputHandlers = pipelineConfig.getInputHandlers(); assertNotNull(inputHandlers); assertTrue(inputHandlers.size() > 0); logger.info("Test Successful in loading 'sample' input handlers using pipeline configuration object"); BaseInputHandlerService inputHandler = inputHandlers.get(0); assertNotNull(inputHandler.getLoadedInputCollections()); assertNotNull(inputHandler.getLoadedInputTypes()); assertNotNull(inputHandler.getType()); logger.info("Test Successful in fetching input types and collections from input handler"); }
From source file:org.betaconceptframework.astroboa.engine.definition.ContentDefinitionConfiguration.java
private void loadConfigurationFiles(CmsRepository associatedRepository, boolean logWarningIfNoXSDFileFound) { //Load BetaConcept Definition files from repository home directory //which exists in RepositoryContextImpl try {/*from w w w. j a v a 2s.c o m*/ File[] schemaFiles = retrieveXmlSchemaFiles(associatedRepository, logWarningIfNoXSDFileFound); //Create a file configuration for each xsd file //This is done in order to track any changes made at runtime to XSD //in order to reload definition definitionFileConfigurations.put(associatedRepository.getId(), new ArrayList<FileConfiguration>()); if (ArrayUtils.isEmpty(schemaFiles) && logWarningIfNoXSDFileFound) { logger.warn("Found no definition schema files for repository " + associatedRepository); } else { for (File defFile : schemaFiles) { try { logger.debug("Loading definition file {} for repository {}", defFile.getAbsolutePath(), associatedRepository.getId()); XMLConfiguration fileConfiguration = new XMLConfiguration(defFile); fileConfiguration.setReloadingStrategy(new FileChangedReloadingStrategy()); definitionFileConfigurations.get(associatedRepository.getId()).add(fileConfiguration); } catch (Exception e) { logger.error("Error loading definition file " + defFile.getAbsolutePath() + " for repository " + associatedRepository.getId() + "Most probably, it is not a valid XML file. All other definitions will be loaded", e); //Load an empty xml configuration XMLConfiguration fileConfiguration = new XMLConfiguration(); definitionFileConfigurations.get(associatedRepository.getId()).add(fileConfiguration); } } } } catch (Throwable e) { throw new CmsException(e); } }