Search in sources :

Example 1 with CapabilitySpec

use of org.jboss.galleon.spec.CapabilitySpec in project galleon by wildfly.

the class SpecOnlyConfigArranger method orderCapabilityProviders.

private List<CircularRefInfo> orderCapabilityProviders(ResolvedFeature feature, List<CircularRefInfo> circularRefs) throws ProvisioningException {
    for (CapabilitySpec capSpec : feature.spec.xmlSpec.getRequiredCapabilities()) {
        final List<String> resolvedCaps = capResolver.resolve(capSpec, feature);
        if (resolvedCaps.isEmpty()) {
            continue;
        }
        for (String resolvedCap : resolvedCaps) {
            final CapabilityProviders providers;
            try {
                providers = getProviders(resolvedCap, false);
            } catch (ProvisioningException e) {
                throw new ProvisioningException(Errors.noCapabilityProvider(feature, capSpec, resolvedCap));
            }
            final List<CircularRefInfo> circles = orderProviders(providers);
            if (circularRefs == null) {
                circularRefs = circles;
            } else {
                if (circularRefs.size() == 1) {
                    final CircularRefInfo first = circularRefs.get(0);
                    circularRefs = new ArrayList<>(1 + circles.size());
                    circularRefs.add(first);
                }
                circularRefs.addAll(circles);
            }
        }
    }
    return circularRefs;
}
Also used : CapabilitySpec(org.jboss.galleon.spec.CapabilitySpec) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 2 with CapabilitySpec

use of org.jboss.galleon.spec.CapabilitySpec in project galleon by wildfly.

the class DefaultBranchedConfigArranger method orderCapabilityProviders.

private List<CircularRefInfo> orderCapabilityProviders(ResolvedFeature feature, List<CircularRefInfo> circularRefs) throws ProvisioningException {
    for (CapabilitySpec capSpec : feature.spec.xmlSpec.getRequiredCapabilities()) {
        final List<String> resolvedCaps = capResolver.resolve(capSpec, feature);
        if (resolvedCaps.isEmpty()) {
            continue;
        }
        for (String resolvedCap : resolvedCaps) {
            final CapabilityProviders providers;
            try {
                providers = getProviders(resolvedCap, false);
            } catch (ProvisioningException e) {
                throw new ProvisioningException(Errors.noCapabilityProvider(feature, capSpec, resolvedCap));
            }
            circularRefs = CollectionUtils.addAll(circularRefs, orderProviders(providers));
            if (providers.isProvided()) {
                feature.addBranchDep(providers.branches.iterator().next(), false);
            // System.out.println("added branch dep on cap provider " + feature.getId() + " -> " + providers.branches);
            } else {
                providers.addBranchDependee(feature);
            }
        }
    }
    return circularRefs;
}
Also used : CapabilitySpec(org.jboss.galleon.spec.CapabilitySpec) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 3 with CapabilitySpec

use of org.jboss.galleon.spec.CapabilitySpec in project galleon by wildfly.

the class FeatureSpecXmlWriter method writeCaps.

private void writeCaps(final ElementNode parent, Set<CapabilitySpec> caps) {
    for (CapabilitySpec cap : caps) {
        final ElementNode capE = addElement(parent, Element.CAPABILITY);
        addAttribute(capE, Attribute.NAME, cap.toString());
        if (cap.isOptional()) {
            addAttribute(capE, Attribute.OPTIONAL, TRUE);
        }
    }
}
Also used : CapabilitySpec(org.jboss.galleon.spec.CapabilitySpec) ElementNode(org.jboss.galleon.xml.util.ElementNode)

Example 4 with CapabilitySpec

use of org.jboss.galleon.spec.CapabilitySpec in project galleon by wildfly.

the class StateInfoUtil method displayFeatureSpec.

private static void displayFeatureSpec(PmCommandInvocation session, Group grp) throws IOException {
    FeatureSpecInfo f = grp.getSpec();
    session.println("");
    session.println("Feature type       : " + f.getSpecId().getName());
    session.println("Feature origin     : " + f.getSpecId().getProducer());
    session.println("Feature description: " + f.getDescription());
    if (!f.isEnabled()) {
        session.println("WARNING! The feature is not enabled.");
        session.println("Missing packages");
        for (Identity m : f.getMissingPackages()) {
            session.println(m.toString());
        }
    }
    List<FeatureParameterSpec> idparams = f.getSpec().getIdParams();
    String tab = "  ";
    session.println(Config.getLineSeparator() + "Feature Id parameters");
    if (idparams.isEmpty()) {
        session.println("NONE");
    } else {
        for (FeatureParameterSpec param : idparams) {
            StringBuilder builder = new StringBuilder();
            builder.append(tab + param.getName()).append(Config.getLineSeparator());
            builder.append(tab + tab + "description  : " + "no description available").append(Config.getLineSeparator());
            builder.append(tab + tab + "type         : " + param.getType()).append(Config.getLineSeparator());
            builder.append(tab + tab + "default-value: " + param.getDefaultValue()).append(Config.getLineSeparator());
            builder.append(tab + tab + "nillable     : " + param.isNillable()).append(Config.getLineSeparator());
            session.print(builder.toString());
        }
    }
    // Add spec parameters
    session.println(Config.getLineSeparator() + "Feature parameters");
    Map<String, FeatureParameterSpec> params = f.getSpec().getParams();
    if (params.isEmpty()) {
        session.println("NONE");
    } else {
        for (Entry<String, FeatureParameterSpec> entry : params.entrySet()) {
            FeatureParameterSpec param = entry.getValue();
            if (!param.isFeatureId()) {
                StringBuilder builder = new StringBuilder();
                builder.append(tab + param.getName()).append(Config.getLineSeparator());
                builder.append(tab + tab + "description  : " + "no description available").append(Config.getLineSeparator());
                builder.append(tab + tab + "type         : " + param.getType()).append(Config.getLineSeparator());
                builder.append(tab + tab + "default-value: " + param.getDefaultValue()).append(Config.getLineSeparator());
                builder.append(tab + tab + "nillable     : " + param.isNillable()).append(Config.getLineSeparator());
                session.println(builder.toString());
            }
        }
    }
    session.println(Config.getLineSeparator() + "Packages");
    if (f.getPackages().isEmpty()) {
        session.println(tab + "NONE");
    } else {
        for (PackageInfo p : f.getPackages()) {
            session.println(p.getIdentity().toString());
        }
    }
    session.println(Config.getLineSeparator() + "Provided capabilities");
    if (f.getSpec().getProvidedCapabilities().isEmpty()) {
        session.println(tab + "NONE");
    } else {
        for (CapabilitySpec c : f.getSpec().getProvidedCapabilities()) {
            session.println(tab + c.toString());
        }
    }
    session.println(Config.getLineSeparator() + "Consumed capabilities");
    if (f.getSpec().getRequiredCapabilities().isEmpty()) {
        session.println(tab + "NONE");
    } else {
        for (CapabilitySpec c : f.getSpec().getRequiredCapabilities()) {
            session.println(tab + c.toString());
        }
    }
    session.println(Config.getLineSeparator() + "Features dependencies");
    if (f.getSpec().getFeatureDeps().isEmpty()) {
        session.println(tab + "NONE");
    } else {
        for (FeatureDependencySpec c : f.getSpec().getFeatureDeps()) {
            session.println(tab + c.getFeatureId().toString());
        }
    }
    session.println(Config.getLineSeparator() + "Features references");
    if (f.getSpec().getFeatureRefs().isEmpty()) {
        session.println(tab + "NONE");
    } else {
        for (FeatureReferenceSpec c : f.getSpec().getFeatureRefs()) {
            session.println(tab + c.getFeature());
        }
    }
    session.println(Config.getLineSeparator() + "Features Annotations");
    if (f.getSpec().getAnnotations().isEmpty()) {
        session.println(tab + "NONE");
    } else {
        for (FeatureAnnotation c : f.getSpec().getAnnotations()) {
            session.println(tab + c.toString());
        }
    }
}
Also used : CapabilitySpec(org.jboss.galleon.spec.CapabilitySpec) PackageInfo(org.jboss.galleon.cli.model.PackageInfo) FeatureDependencySpec(org.jboss.galleon.spec.FeatureDependencySpec) FeatureReferenceSpec(org.jboss.galleon.spec.FeatureReferenceSpec) FeatureParameterSpec(org.jboss.galleon.spec.FeatureParameterSpec) FeatureSpecInfo(org.jboss.galleon.cli.model.FeatureSpecInfo) Identity(org.jboss.galleon.cli.model.Identity) FeatureAnnotation(org.jboss.galleon.spec.FeatureAnnotation)

Aggregations

CapabilitySpec (org.jboss.galleon.spec.CapabilitySpec)4 ProvisioningException (org.jboss.galleon.ProvisioningException)2 FeatureSpecInfo (org.jboss.galleon.cli.model.FeatureSpecInfo)1 Identity (org.jboss.galleon.cli.model.Identity)1 PackageInfo (org.jboss.galleon.cli.model.PackageInfo)1 FeatureAnnotation (org.jboss.galleon.spec.FeatureAnnotation)1 FeatureDependencySpec (org.jboss.galleon.spec.FeatureDependencySpec)1 FeatureParameterSpec (org.jboss.galleon.spec.FeatureParameterSpec)1 FeatureReferenceSpec (org.jboss.galleon.spec.FeatureReferenceSpec)1 ElementNode (org.jboss.galleon.xml.util.ElementNode)1