Example usage for org.apache.commons.configuration2 CompositeConfiguration addConfiguration

List of usage examples for org.apache.commons.configuration2 CompositeConfiguration addConfiguration

Introduction

In this page you can find the example usage for org.apache.commons.configuration2 CompositeConfiguration addConfiguration.

Prototype

public void addConfiguration(final Configuration config) 

Source Link

Document

Add a configuration.

Usage

From source file:io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder.java

public Swagger2MarkupConfigBuilder(Configuration configuration) {
    CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
    compositeConfiguration.addConfiguration(new SystemConfiguration());
    compositeConfiguration.addConfiguration(configuration);
    compositeConfiguration.addConfiguration(getDefaultConfiguration());

    Swagger2MarkupProperties swagger2MarkupProperties = new Swagger2MarkupProperties(compositeConfiguration);

    config.markupLanguage = swagger2MarkupProperties.getRequiredMarkupLanguage(MARKUP_LANGUAGE);
    config.swaggerMarkupLanguage = swagger2MarkupProperties.getRequiredMarkupLanguage(SWAGGER_MARKUP_LANGUAGE);
    config.generatedExamplesEnabled = swagger2MarkupProperties.getRequiredBoolean(GENERATED_EXAMPLES_ENABLED);
    config.basePathPrefixEnabled = swagger2MarkupProperties.getRequiredBoolean(BASE_PATH_PREFIX_ENABLED);
    config.separatedDefinitionsEnabled = swagger2MarkupProperties
            .getRequiredBoolean(SEPARATED_DEFINITIONS_ENABLED);
    config.separatedOperationsEnabled = swagger2MarkupProperties
            .getRequiredBoolean(SEPARATED_OPERATIONS_ENABLED);
    config.pathsGroupedBy = swagger2MarkupProperties.getGroupBy(PATHS_GROUPED_BY);
    config.outputLanguage = swagger2MarkupProperties.getLanguage(OUTPUT_LANGUAGE);
    config.inlineSchemaEnabled = swagger2MarkupProperties.getRequiredBoolean(INLINE_SCHEMA_ENABLED);
    config.interDocumentCrossReferencesEnabled = swagger2MarkupProperties
            .getRequiredBoolean(INTER_DOCUMENT_CROSS_REFERENCES_ENABLED);
    config.interDocumentCrossReferencesPrefix = swagger2MarkupProperties
            .getString(INTER_DOCUMENT_CROSS_REFERENCES_PREFIX, null);
    config.flatBodyEnabled = swagger2MarkupProperties.getRequiredBoolean(FLAT_BODY_ENABLED);
    config.pathSecuritySectionEnabled = swagger2MarkupProperties
            .getRequiredBoolean(PATH_SECURITY_SECTION_ENABLED);
    config.anchorPrefix = swagger2MarkupProperties.getString(ANCHOR_PREFIX, null);
    config.overviewDocument = swagger2MarkupProperties.getRequiredString(OVERVIEW_DOCUMENT);
    config.pathsDocument = swagger2MarkupProperties.getRequiredString(PATHS_DOCUMENT);
    config.definitionsDocument = swagger2MarkupProperties.getRequiredString(DEFINITIONS_DOCUMENT);
    config.securityDocument = swagger2MarkupProperties.getRequiredString(SECURITY_DOCUMENT);
    config.separatedOperationsFolder = swagger2MarkupProperties.getRequiredString(SEPARATED_OPERATIONS_FOLDER);
    config.separatedDefinitionsFolder = swagger2MarkupProperties
            .getRequiredString(SEPARATED_DEFINITIONS_FOLDER);
    config.tagOrderBy = swagger2MarkupProperties.getOrderBy(TAG_ORDER_BY);
    config.operationOrderBy = swagger2MarkupProperties.getOrderBy(OPERATION_ORDER_BY);
    config.definitionOrderBy = swagger2MarkupProperties.getOrderBy(DEFINITION_ORDER_BY);
    config.parameterOrderBy = swagger2MarkupProperties.getOrderBy(PARAMETER_ORDER_BY);
    config.propertyOrderBy = swagger2MarkupProperties.getOrderBy(PROPERTY_ORDER_BY);
    config.responseOrderBy = swagger2MarkupProperties.getOrderBy(RESPONSE_ORDER_BY);
    Optional<String> lineSeparator = swagger2MarkupProperties.getString(LINE_SEPARATOR);
    if (lineSeparator.isPresent() && StringUtils.isNoneBlank(lineSeparator.get())) {
        config.lineSeparator = LineSeparator.valueOf(lineSeparator.get());
    }/*from ww  w .j  a  va2  s.  c  o m*/

    config.pageBreakLocations = swagger2MarkupProperties.getPageBreakLocations(PAGE_BREAK_LOCATIONS);

    Optional<Pattern> headerPattern = swagger2MarkupProperties.getHeaderPattern(HEADER_REGEX);

    config.headerPattern = headerPattern.orElse(null);

    Configuration swagger2markupConfiguration = compositeConfiguration.subset(PROPERTIES_PREFIX);
    Configuration extensionsConfiguration = swagger2markupConfiguration.subset(EXTENSION_PREFIX);
    config.extensionsProperties = new Swagger2MarkupProperties(extensionsConfiguration);
}

From source file:org.mitre.mpf.wfm.util.MpfPropertiesConfigurationBuilder.java

private CompositeConfiguration createCompositeConfiguration() {

    if (!customPropFile.exists()) {
        try {//from  w  w w  . ja v a2  s.  c o  m
            PropertiesUtil.createParentDir(customPropFile);
            customPropFile.getFile().createNewFile();
        } catch (IOException e) {
            throw new IllegalStateException("Cannot create " + customPropFile + ".", e);
        }
    }

    CompositeConfiguration compositeConfig = new CompositeConfiguration();

    // add resources in the order they are specified in the application context XML;
    // the first configs that are added to the composite override property values in configs that are added later
    for (Resource resource : propFiles) {
        try {
            if (resource.equals(customPropFile)) {
                mpfCustomPropertiesConfig = createFileBasedConfigurationBuilder(customPropFile)
                        .getConfiguration();
                compositeConfig.addConfiguration(mpfCustomPropertiesConfig);
            } else if (resource.exists()) {
                compositeConfig
                        .addConfiguration(createFileBasedConfigurationBuilder(resource).getConfiguration());
            }
        } catch (ConfigurationException e) {
            throw new IllegalStateException("Cannot create configuration from " + resource + ".", e);
        }
    }

    if (mpfCustomPropertiesConfig == null) {
        throw new IllegalStateException("List of configuration properties files did not contain the "
                + "custom configuration property file: " + propFiles);
    }

    return compositeConfig;
}