Search in sources :

Example 1 with ResolvedFeatureSpec

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

the class FeatureSpecsBuilder method buildTree.

public Group buildTree(ProvisioningLayout<FeaturePackRuntime> layout, PmSession session, FPID fpid, FPID id, Map<Identity, Group> allPackages, boolean useCache, Set<ResolvedSpecId> wantedSpecs) throws IOException, ProvisioningException {
    // Build the tree of specs located in all feature-packs
    FeatureGroupsBuilder grpBuilder = new FeatureGroupsBuilder();
    Set<FeatureSpecInfo> specs = new HashSet<>();
    for (ResolvedFeatureSpec resolvedSpec : layout.getFeaturePack(fpid.getProducer()).getFeatureSpecs()) {
        ResolvedSpecId resolved = resolvedSpec.getId();
        if (wantedSpecs == null || wantedSpecs.contains(resolved)) {
            FeatureSpecInfo specInfo = allspecs.get(resolved);
            if (specInfo == null) {
                Set<Identity> missingPackages = new HashSet<>();
                FeatureSpec spec = resolvedSpec.getSpec();
                specInfo = new FeatureSpecInfo(resolved, id, spec);
                Identity specId = Identity.fromChannel(resolved.getProducer(), resolved.getName());
                boolean featureEnabled = true;
                for (PackageDependencySpec p : spec.getLocalPackageDeps()) {
                    Identity identity = Identity.fromChannel(resolved.getProducer(), p.getName());
                    Group grp = allPackages.get(identity);
                    // Group can be null if the modules have not been installed.
                    if (grp != null) {
                        specInfo.addPackage(grp.getPackage());
                        attachProvider(specId, grp, new HashSet<>());
                    } else {
                        featureEnabled = false;
                        missingPackages.add(identity);
                    }
                }
                for (String o : spec.getPackageOrigins()) {
                    for (PackageDependencySpec p : spec.getExternalPackageDeps(o)) {
                        Identity identity = Identity.fromString(o, p.getName());
                        Group grp = allPackages.get(identity);
                        if (grp != null) {
                            specInfo.addPackage(grp.getPackage());
                            attachProvider(specId, grp, new HashSet<>());
                        } else {
                            featureEnabled = false;
                            missingPackages.add(identity);
                        }
                    }
                }
                specInfo.setEnabled(featureEnabled);
                specInfo.setMissingPackages(missingPackages);
                allspecs.put(resolved, specInfo);
                specs.add(specInfo);
            }
            String fullSpecName = resolved.getName();
            List<String> path = new ArrayList<>();
            Group parent = grpBuilder.buildFeatureSpecGroups(fullSpecName, specInfo, path);
            parent.setFeatureSpec(specInfo);
        }
    }
    return grpBuilder.getRoot();
}
Also used : ResolvedFeatureSpec(org.jboss.galleon.runtime.ResolvedFeatureSpec) FeatureSpec(org.jboss.galleon.spec.FeatureSpec) ArrayList(java.util.ArrayList) ResolvedSpecId(org.jboss.galleon.runtime.ResolvedSpecId) PackageDependencySpec(org.jboss.galleon.spec.PackageDependencySpec) ResolvedFeatureSpec(org.jboss.galleon.runtime.ResolvedFeatureSpec) HashSet(java.util.HashSet)

Example 2 with ResolvedFeatureSpec

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

the class ProvisionedConfigBuilder method handle.

@Override
public void handle(ProvisionedConfigHandler handler) throws ProvisioningException {
    if (!hasFeatures()) {
        return;
    }
    handler.prepare(this);
    ResolvedSpecId lastHandledSpecId = null;
    for (ProvisionedFeature feature : features) {
        if (!feature.getSpecId().equals(lastHandledSpecId)) {
            if (lastHandledSpecId == null || !feature.getSpecId().getProducer().equals(lastHandledSpecId.getProducer())) {
                handler.nextFeaturePack(feature.getSpecId().getProducer().getLocation().getFPID());
            }
            // TODO: complete spec isn't available here, but specId is enough for marshalling
            handler.nextSpec(new ResolvedFeatureSpec(feature.getSpecId(), null, FeatureSpec.builder().build()));
            lastHandledSpecId = feature.getSpecId();
        }
        handler.nextFeature(feature);
    }
    handler.done();
}
Also used : ProvisionedFeature(org.jboss.galleon.state.ProvisionedFeature) ResolvedSpecId(org.jboss.galleon.runtime.ResolvedSpecId) ResolvedFeatureSpec(org.jboss.galleon.runtime.ResolvedFeatureSpec)

Aggregations

ResolvedFeatureSpec (org.jboss.galleon.runtime.ResolvedFeatureSpec)2 ResolvedSpecId (org.jboss.galleon.runtime.ResolvedSpecId)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 FeatureSpec (org.jboss.galleon.spec.FeatureSpec)1 PackageDependencySpec (org.jboss.galleon.spec.PackageDependencySpec)1 ProvisionedFeature (org.jboss.galleon.state.ProvisionedFeature)1