Search in sources :

Example 1 with FeaturePackRuntimeBuilder

use of org.jboss.galleon.runtime.FeaturePackRuntimeBuilder in project galleon by wildfly.

the class ProvisioningManager method install.

public void install(FeaturePackConfig fpConfig, Map<String, String> options) throws ProvisioningException {
    ProvisioningConfig config = getProvisioningConfig();
    if (config == null) {
        config = ProvisioningConfig.builder().build();
    }
    try (ProvisioningLayout<FeaturePackRuntimeBuilder> layout = getLayoutFactory().newConfigLayout(config, ProvisioningRuntimeBuilder.FP_RT_FACTORY, false)) {
        final UniverseSpec configuredUniverse = getConfiguredUniverse(fpConfig.getLocation());
        layout.install(configuredUniverse == null ? fpConfig : FeaturePackConfig.builder(fpConfig.getLocation().replaceUniverse(configuredUniverse)).init(fpConfig).build(), options);
        doProvision(layout, getFsDiff(), false);
    }
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FeaturePackRuntimeBuilder(org.jboss.galleon.runtime.FeaturePackRuntimeBuilder) UniverseSpec(org.jboss.galleon.universe.UniverseSpec)

Example 2 with FeaturePackRuntimeBuilder

use of org.jboss.galleon.runtime.FeaturePackRuntimeBuilder in project galleon by wildfly.

the class ProvisioningManager method apply.

/**
 * Apply provisioning plan to the currently provisioned installation
 *
 * @param plan  provisioning plan
 * @param options  provisioning plugin options
 * @throws ProvisioningException  in case of a failure
 */
public void apply(ProvisioningPlan plan, Map<String, String> options) throws ProvisioningException {
    ProvisioningConfig config = getProvisioningConfig();
    if (config == null) {
        config = ProvisioningConfig.builder().build();
    }
    try (ProvisioningLayout<FeaturePackRuntimeBuilder> layout = getLayoutFactory().newConfigLayout(config, ProvisioningRuntimeBuilder.FP_RT_FACTORY, false)) {
        layout.apply(plan, options);
        doProvision(layout, getFsDiff(), false);
    }
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FeaturePackRuntimeBuilder(org.jboss.galleon.runtime.FeaturePackRuntimeBuilder)

Example 3 with FeaturePackRuntimeBuilder

use of org.jboss.galleon.runtime.FeaturePackRuntimeBuilder 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 4 with FeaturePackRuntimeBuilder

use of org.jboss.galleon.runtime.FeaturePackRuntimeBuilder 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)

Example 5 with FeaturePackRuntimeBuilder

use of org.jboss.galleon.runtime.FeaturePackRuntimeBuilder in project galleon by wildfly.

the class ProvisioningManager method uninstall.

/**
 * Uninstalls the specified feature-pack.
 *
 * @param fpid  feature-pack ID
 * @param pluginOptions  provisioning plugin options
 * @throws ProvisioningException  in case of a failure
 */
public void uninstall(FeaturePackLocation.FPID fpid, Map<String, String> pluginOptions) throws ProvisioningException {
    ProvisioningConfig config = getProvisioningConfig();
    if (config == null || !config.hasFeaturePackDeps()) {
        throw new ProvisioningException(Errors.unknownFeaturePack(fpid));
    }
    try (ProvisioningLayout<FeaturePackRuntimeBuilder> layout = getLayoutFactory().newConfigLayout(config, ProvisioningRuntimeBuilder.FP_RT_FACTORY, false)) {
        layout.uninstall(resolveUniverseSpec(fpid.getLocation()).getFPID(), pluginOptions);
        doProvision(layout, getFsDiff(), false);
    }
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) FeaturePackRuntimeBuilder(org.jboss.galleon.runtime.FeaturePackRuntimeBuilder)

Aggregations

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