Search in sources :

Example 11 with ConfigModel

use of org.jboss.galleon.config.ConfigModel in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method resolveModelOnlyConfig.

private ConfigModelStack resolveModelOnlyConfig(FeaturePackConfig fpConfig, ConfigModelStack modelOnlyStack, ConfigId configId) throws ProvisioningException {
    final FeaturePackRuntimeBuilder fp = layout.getFeaturePack(fpConfig.getLocation().getProducer());
    if (!setFlag(fp, FeaturePackRuntimeBuilder.RESOLVE_MODEL_ONLY_CONFIG)) {
        return modelOnlyStack;
    }
    final FeaturePackRuntimeBuilder prevOrigin = currentOrigin;
    try {
        int pushedCount = 0;
        ConfigModel config = fpConfig.getDefinedConfig(configId);
        if (config != null) {
            if (modelOnlyStack == null) {
                modelOnlyStack = new ConfigModelStack(configId, this);
            }
            modelOnlyStack.pushConfig(config);
            ++pushedCount;
        }
        config = fp.getSpec().getDefinedConfig(configId);
        if (config != null) {
            if (modelOnlyStack == null) {
                modelOnlyStack = new ConfigModelStack(configId, this);
            }
            modelOnlyStack.pushConfig(config);
            ++pushedCount;
        }
        config = fp.getConfig(configId);
        if (config != null) {
            if (modelOnlyStack == null) {
                modelOnlyStack = new ConfigModelStack(configId, this);
            }
            modelOnlyStack.pushConfig(config);
            ++pushedCount;
        }
        boolean extendedStackLevel = false;
        if (fp.getSpec().hasTransitiveDeps()) {
            for (FeaturePackConfig fpDep : fp.getSpec().getTransitiveDeps()) {
                extendedStackLevel |= fpConfigStack.push(fpDep, extendedStackLevel);
            }
        }
        if (fp.getSpec().hasFeaturePackDeps()) {
            for (FeaturePackConfig fpDep : fp.getSpec().getFeaturePackDeps()) {
                extendedStackLevel |= fpConfigStack.push(fpDep, extendedStackLevel);
                if (fpDep.isConfigModelExcluded(configId) || !fpDep.isInheritModelOnlyConfigs() && !fpDep.isConfigModelIncluded(configId)) {
                    continue;
                }
                modelOnlyStack = resolveModelOnlyConfig(fpDep, modelOnlyStack, configId);
            }
        }
        while (pushedCount > 0) {
            setOrigin(fp);
            processConfig(modelOnlyStack, popConfig(modelOnlyStack));
            --pushedCount;
        }
        if (extendedStackLevel) {
            fpConfigStack.popLevel();
        }
    } finally {
        setOrigin(prevOrigin);
    }
    return modelOnlyStack;
}
Also used : ConfigModel(org.jboss.galleon.config.ConfigModel) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 12 with ConfigModel

use of org.jboss.galleon.config.ConfigModel in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method doBuild.

private ProvisioningRuntime doBuild() throws ProvisioningException {
    config = layout.getConfig();
    fpConfigStack = new FpStack(config);
    final String optionalPackages = layout.getOptionValue(ProvisioningOption.OPTIONAL_PACKAGES);
    switch(optionalPackages) {
        case Constants.ALL:
            pkgDepMask = PKG_DEP_MASK_ALL;
            includedPkgDeps = PKG_DEP_ALL;
            break;
        case Constants.PASSIVE_PLUS:
            pkgDepMask = PKG_DEP_MASK_ALL;
            includedPkgDeps = PKG_DEP_PASSIVE_PLUS;
            break;
        case Constants.PASSIVE:
            pkgDepMask = PKG_DEP_MASK_PASSIVE;
            includedPkgDeps = PKG_DEP_PASSIVE;
            break;
        case Constants.NONE:
            pkgDepMask = PKG_DEP_MASK_REQUIRED;
            includedPkgDeps = PKG_DEP_REQUIRED;
            break;
        default:
            throw new ProvisioningDescriptionException(Errors.pluginOptionIllegalValue(ProvisioningOption.OPTIONAL_PACKAGES.getName(), optionalPackages, ProvisioningOption.OPTIONAL_PACKAGES.getValueSet()));
    }
    collectDefaultConfigs();
    List<ConfigModelStack> configStacks = Collections.emptyList();
    if (config.hasDefinedConfigs()) {
        for (ConfigModel config : config.getDefinedConfigs()) {
            if (config.getId().isModelOnly()) {
                continue;
            }
            configStack = configsToBuild.get(config.getId());
            configStacks = pushConfig(configStacks, config);
        }
    }
    final boolean extendedStackLevel = processFpDepConfigs(config);
    for (int i = configStacks.size() - 1; i >= 0; --i) {
        final ConfigModelStack configStack = configStacks.get(i);
        processConfig(configStack, popConfig(configStack));
    }
    if (extendedStackLevel) {
        fpConfigStack.popLevel();
    }
    mergeModelOnlyConfigs();
    return new ProvisioningRuntime(this, messageWriter);
}
Also used : ConfigModel(org.jboss.galleon.config.ConfigModel) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 13 with ConfigModel

use of org.jboss.galleon.config.ConfigModel in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method processFpConfig.

private void processFpConfig(FeaturePackConfig fpConfig) throws ProvisioningException {
    thisOrigin = layout.getFeaturePack(fpConfig.getLocation().getProducer());
    final FeaturePackRuntimeBuilder parentFp = setOrigin(thisOrigin);
    try {
        List<ConfigModelStack> fpConfigStacks = Collections.emptyList();
        List<ConfigModelStack> specConfigStacks = Collections.emptyList();
        for (Map.Entry<ConfigId, ConfigModelStack> entry : configsToBuild.entrySet()) {
            final ConfigId configId = entry.getKey();
            configStack = entry.getValue();
            final ConfigModel config = fpConfig.getDefinedConfig(configId);
            if (config != null && !fpConfigStack.isFilteredOut(thisOrigin.producer, configId, true)) {
                fpConfigStacks = pushConfig(fpConfigStacks, config);
            }
            if (fpConfig.isTransitive()) {
                continue;
            }
            if (fpConfigStack.isIncludedInTransitiveDeps(thisOrigin.producer, configId) || !fpConfigStack.isFilteredOutFromDeps(thisOrigin.producer, configId, false) && (thisOrigin.getSpec().hasDefinedConfig(configId) || configStack.size() > 1 || thisOrigin.getConfig(configId) != null)) {
                specConfigStacks = pushFpConfig(specConfigStacks, configId);
            }
        }
        configStack = null;
        boolean extendedStackLevel = false;
        if (!fpConfig.isTransitive()) {
            extendedStackLevel = processFpDepConfigs(currentOrigin.getSpec());
            if (currentOrigin.getSpec().hasDefaultPackages()) {
                for (String packageName : currentOrigin.getSpec().getDefaultPackageNames()) {
                    if (fpConfigStack.isPackageFilteredOut(currentOrigin.producer, packageName)) {
                        continue;
                    }
                    resolvePackage(packageName, null, PackageDependencySpec.REQUIRED);
                }
            }
        }
        if (!specConfigStacks.isEmpty()) {
            for (int i = specConfigStacks.size() - 1; i >= 0; --i) {
                final ConfigModelStack configStack = specConfigStacks.get(i);
                processConfig(configStack, popConfig(configStack));
            }
        }
        if (fpConfig.hasIncludedPackages()) {
            for (String pkgName : fpConfig.getIncludedPackages()) {
                if (fpConfigStack.isPackageFilteredOut(currentOrigin.producer, pkgName)) {
                    continue;
                }
                resolvePackage(pkgName, null, PackageDependencySpec.REQUIRED);
            }
        }
        if (!fpConfigStacks.isEmpty()) {
            for (int i = fpConfigStacks.size() - 1; i >= 0; --i) {
                final ConfigModelStack configStack = fpConfigStacks.get(i);
                processConfig(configStack, popConfig(configStack));
            }
        }
        if (extendedStackLevel) {
            fpConfigStack.popLevel();
        }
    } finally {
        this.thisOrigin = parentFp;
        setOrigin(parentFp);
    }
}
Also used : ConfigModel(org.jboss.galleon.config.ConfigModel) ConfigId(org.jboss.galleon.config.ConfigId) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 14 with ConfigModel

use of org.jboss.galleon.config.ConfigModel in project galleon by wildfly.

the class ProvisioningRuntimeBuilder method pushFpConfig.

private List<ConfigModelStack> pushFpConfig(List<ConfigModelStack> configStacks, ConfigId configId) throws ProvisioningException {
    ConfigModel config = currentOrigin.getConfig(configId);
    if (config != null) {
        configStacks = pushConfig(configStacks, config);
    }
    config = currentOrigin.getSpec().getDefinedConfig(configId);
    if (config != null) {
        configStacks = pushConfig(configStacks, config);
    }
    return configStacks;
}
Also used : ConfigModel(org.jboss.galleon.config.ConfigModel)

Example 15 with ConfigModel

use of org.jboss.galleon.config.ConfigModel in project galleon by wildfly.

the class ProvisioningDiffProvider method updateConfig.

public void updateConfig(ProvisionedFeatureDiffCallback featureDiffCallback, ProvisionedConfig updatedConfig, String... relativePaths) throws ProvisioningException {
    final ConfigId configId = new ConfigId(updatedConfig.getModel(), updatedConfig.getName());
    configPlugins = CollectionUtils.put(configPlugins, configId, featureDiffCallback);
    if (featureDiff == null) {
        featureDiff = new FeatureDiff(log);
    }
    featureDiff.init(getRequiredProvisionedConfig(provisionedState.getConfigs(), updatedConfig.getModel(), updatedConfig.getName()));
    featureDiff.diff(featureDiffCallback, updatedConfig);
    final ConfigModel mergedConfig = featureDiff.getMergedConfig(layout);
    if (mergedConfig == null) {
        log.verbose("%s has not changed", updatedConfig.getName());
    } else {
        updatedConfigs.put(configId, mergedConfig);
    }
    featureDiff.reset();
    suppressPaths(relativePaths);
}
Also used : ConfigModel(org.jboss.galleon.config.ConfigModel) ConfigId(org.jboss.galleon.config.ConfigId)

Aggregations

ConfigModel (org.jboss.galleon.config.ConfigModel)18 ConfigId (org.jboss.galleon.config.ConfigId)12 IOException (java.io.IOException)4 Path (java.nio.file.Path)4 Map (java.util.Map)4 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)4 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)4 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)3 ProvisioningException (org.jboss.galleon.ProvisioningException)3 BufferedReader (java.io.BufferedReader)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)2 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)2 Test (org.junit.Test)2 FileVisitResult (java.nio.file.FileVisitResult)1 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1