Search in sources :

Example 1 with XMLBuilderParameters

use of org.apache.commons.configuration2.builder.fluent.XMLBuilderParameters in project engine by craftercms.

the class ConfigUtils method readXmlConfiguration.

public static XMLConfiguration readXmlConfiguration(Resource resource, char listDelimiter, Map<String, Lookup> prefixLookups) throws ConfigurationException {
    Parameters params = new Parameters();
    FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<>(XMLConfiguration.class);
    try {
        XMLBuilderParameters xmlParams = params.xml().setURL(resource.getURL()).setListDelimiterHandler(new DefaultListDelimiterHandler(listDelimiter));
        if (MapUtils.isNotEmpty(prefixLookups)) {
            xmlParams = xmlParams.setPrefixLookups(prefixLookups);
        }
        builder.configure(xmlParams);
    } catch (IOException e) {
        throw new ConfigurationException("Unable to get URL of resource " + resource, e);
    }
    return builder.getConfiguration();
}
Also used : XMLConfiguration(org.apache.commons.configuration2.XMLConfiguration) DefaultListDelimiterHandler(org.apache.commons.configuration2.convert.DefaultListDelimiterHandler) Parameters(org.apache.commons.configuration2.builder.fluent.Parameters) XMLBuilderParameters(org.apache.commons.configuration2.builder.fluent.XMLBuilderParameters) FileBasedConfigurationBuilder(org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder) XMLBuilderParameters(org.apache.commons.configuration2.builder.fluent.XMLBuilderParameters) ConfigurationException(org.apache.commons.configuration2.ex.ConfigurationException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 XMLConfiguration (org.apache.commons.configuration2.XMLConfiguration)1 FileBasedConfigurationBuilder (org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder)1 Parameters (org.apache.commons.configuration2.builder.fluent.Parameters)1 XMLBuilderParameters (org.apache.commons.configuration2.builder.fluent.XMLBuilderParameters)1 DefaultListDelimiterHandler (org.apache.commons.configuration2.convert.DefaultListDelimiterHandler)1 ConfigurationException (org.apache.commons.configuration2.ex.ConfigurationException)1