Search in sources :

Example 1 with ProvisioningDiffProvider

use of org.jboss.galleon.diff.ProvisioningDiffProvider in project galleon by wildfly.

the class ProvisioningManager method persistChanges.

/**
 * Merge user changes recognized by the provisioning plug-ins (such as
 * changes to the configuration files) into the provisioning configuration
 * file describing the state of the installation).
 *
 * @return true if some changes have been persisted, false otherwise.
 * @throws ProvisioningException  in case the merge fails
 */
public boolean persistChanges() throws ProvisioningException {
    final ProvisioningDiffProvider diffProvider = getDiffMergedConfig();
    if (diffProvider == null) {
        return false;
    }
    final ProvisioningConfig mergedConfig = diffProvider.getMergedConfig();
    if (mergedConfig.equals(getProvisioningConfig())) {
        return false;
    }
    try (ProvisioningLayout<FeaturePackRuntimeBuilder> layout = getLayoutFactory().newConfigLayout(mergedConfig, ProvisioningRuntimeBuilder.FP_RT_FACTORY, false)) {
        doProvision(layout, diffProvider.getFsDiff(), false);
    }
    return true;
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FeaturePackRuntimeBuilder(org.jboss.galleon.runtime.FeaturePackRuntimeBuilder) ProvisioningDiffProvider(org.jboss.galleon.diff.ProvisioningDiffProvider)

Example 2 with ProvisioningDiffProvider

use of org.jboss.galleon.diff.ProvisioningDiffProvider in project galleon by wildfly.

the class ProvisioningManager method getDiffMergedConfig.

private ProvisioningDiffProvider getDiffMergedConfig() throws ProvisioningException {
    final FsDiff diff = getFsDiff();
    if (diff == null || diff.isEmpty()) {
        return null;
    }
    try (ProvisioningLayout<FeaturePackRuntimeBuilder> layout = layoutFactory.newConfigLayout(getProvisioningConfig(), ProvisioningRuntimeBuilder.FP_RT_FACTORY, false)) {
        final ProvisioningDiffProvider diffProvider = ProvisioningDiffProvider.newInstance(layout, getProvisionedState(), diff, log);
        layout.visitPlugins(new FeaturePackPluginVisitor<StateDiffPlugin>() {

            @Override
            public void visitPlugin(StateDiffPlugin plugin) throws ProvisioningException {
                plugin.diff(diffProvider);
            }
        }, StateDiffPlugin.class);
        return diffProvider;
    }
}
Also used : FeaturePackRuntimeBuilder(org.jboss.galleon.runtime.FeaturePackRuntimeBuilder) ProvisioningDiffProvider(org.jboss.galleon.diff.ProvisioningDiffProvider) FsDiff(org.jboss.galleon.diff.FsDiff) StateDiffPlugin(org.jboss.galleon.plugin.StateDiffPlugin)

Aggregations

ProvisioningDiffProvider (org.jboss.galleon.diff.ProvisioningDiffProvider)2 FeaturePackRuntimeBuilder (org.jboss.galleon.runtime.FeaturePackRuntimeBuilder)2 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)1 FsDiff (org.jboss.galleon.diff.FsDiff)1 StateDiffPlugin (org.jboss.galleon.plugin.StateDiffPlugin)1