Search in sources :

Example 1 with FeatureId

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

the class ProvisioningRuntimeBuilder method resolveExcludedIds.

private Set<ResolvedFeatureId> resolveExcludedIds(Set<ResolvedFeatureId> resolvedIds, Map<FeatureId, String> features) throws ProvisioningException {
    for (Map.Entry<FeatureId, String> excluded : features.entrySet()) {
        final FeatureId excludedId = excluded.getKey();
        final ResolvedFeatureSpec resolvedSpec = getFeatureSpec(excludedId.getSpec().getName());
        if (parentFeature != null) {
            resolvedIds = CollectionUtils.add(resolvedIds, resolvedSpec.resolveIdFromForeignKey(parentFeature.id, excluded.getValue(), excludedId.getParams()));
        } else {
            resolvedIds = CollectionUtils.add(resolvedIds, resolvedSpec.resolveFeatureId(excludedId.getParams()));
        }
    }
    return resolvedIds;
}
Also used : FeatureId(org.jboss.galleon.spec.FeatureId) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 2 with FeatureId

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

the class FeatureGroupXmlWriter method addFeatureGroupIncludeExclude.

static void addFeatureGroupIncludeExclude(FeatureGroupSupport dep, String ns, final ElementNode depE) {
    if (dep.hasExcludedSpecs()) {
        for (SpecId spec : dep.getExcludedSpecs()) {
            final ElementNode excludeE = addElement(depE, Element.EXCLUDE.getLocalName(), ns);
            addAttribute(excludeE, Attribute.SPEC, spec.toString());
        }
    }
    if (dep.hasExcludedFeatures()) {
        for (Map.Entry<FeatureId, String> excluded : dep.getExcludedFeatures().entrySet()) {
            final ElementNode excludeE = addElement(depE, Element.EXCLUDE.getLocalName(), ns);
            addAttribute(excludeE, Attribute.FEATURE_ID, excluded.getKey().toString());
            if (excluded.getValue() != null) {
                addAttribute(excludeE, Attribute.PARENT_REF, excluded.getValue());
            }
        }
    }
    if (dep.hasIncludedSpecs()) {
        for (SpecId spec : dep.getIncludedSpecs()) {
            final ElementNode includeE = addElement(depE, Element.INCLUDE.getLocalName(), ns);
            addAttribute(includeE, Attribute.SPEC, spec.toString());
        }
    }
    if (dep.hasIncludedFeatures()) {
        for (Map.Entry<FeatureId, FeatureConfig> entry : dep.getIncludedFeatures().entrySet()) {
            final ElementNode includeE = addElement(depE, Element.INCLUDE.getLocalName(), ns);
            addAttribute(includeE, Attribute.FEATURE_ID, entry.getKey().toString());
            final FeatureConfig fc = entry.getValue();
            if (fc.getParentRef() != null) {
                addAttribute(includeE, Attribute.PARENT_REF, fc.getParentRef());
            }
            if (fc != null) {
                addFeatureConfigBody(includeE, entry.getKey(), fc, ns);
            }
        }
    }
}
Also used : FeatureId(org.jboss.galleon.spec.FeatureId) FeatureConfig(org.jboss.galleon.config.FeatureConfig) ElementNode(org.jboss.galleon.xml.util.ElementNode) SpecId(org.jboss.galleon.spec.SpecId) Map(java.util.Map)

Example 3 with FeatureId

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

the class ProvisioningRuntimeBuilder method resolveIncludedIds.

private Map<ResolvedFeatureId, FeatureConfig> resolveIncludedIds(Map<ResolvedFeatureId, FeatureConfig> includedFeatures, Map<FeatureId, FeatureConfig> features) throws ProvisioningException {
    for (Map.Entry<FeatureId, FeatureConfig> included : features.entrySet()) {
        final FeatureConfig fc = new FeatureConfig(included.getValue());
        final ResolvedFeatureSpec resolvedSpec = getFeatureSpec(fc.getSpecId().getName());
        if (parentFeature != null) {
            includedFeatures = CollectionUtils.put(includedFeatures, resolvedSpec.resolveIdFromForeignKey(parentFeature.id, fc.getParentRef(), fc.getParams()), fc);
        } else {
            includedFeatures = CollectionUtils.put(includedFeatures, resolvedSpec.resolveFeatureId(fc.getParams()), fc);
        }
    }
    return includedFeatures;
}
Also used : FeatureId(org.jboss.galleon.spec.FeatureId) FeatureConfig(org.jboss.galleon.config.FeatureConfig) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 4 with FeatureId

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

the class ProvisioningDiffProvider method getFeatureId.

private static FeatureId getFeatureId(final ProvisionedFeature feature) throws ProvisioningDescriptionException, ProvisioningException {
    final FeatureId.Builder id = FeatureId.builder(feature.getSpecId().getName());
    final ResolvedFeatureId resolvedId = feature.getId();
    for (String name : resolvedId.getParams().keySet()) {
        id.setParam(name, feature.getConfigParam(name));
    }
    return id.build();
}
Also used : ResolvedFeatureId(org.jboss.galleon.runtime.ResolvedFeatureId) FeatureId(org.jboss.galleon.spec.FeatureId) ResolvedFeatureId(org.jboss.galleon.runtime.ResolvedFeatureId)

Example 5 with FeatureId

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

the class FeatureGroupXml method readInclude.

private static void readInclude(XMLExtendedStreamReader reader, String origin, FeatureGroupBuilderSupport<?> depBuilder) throws XMLStreamException {
    String spec = null;
    String featureIdStr = null;
    String parentRef = null;
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final Attribute attribute = Attribute.of(reader.getAttributeName(i));
        switch(attribute) {
            case FEATURE_ID:
                featureIdStr = reader.getAttributeValue(i);
                break;
            case SPEC:
                spec = reader.getAttributeValue(i);
                break;
            case PARENT_REF:
                parentRef = reader.getAttributeValue(i);
                break;
            default:
                throw ParsingUtils.unexpectedAttribute(reader, i);
        }
    }
    if (spec != null) {
        if (featureIdStr != null) {
            attributesCantBeCombined(Attribute.SPEC, Attribute.FEATURE_ID, reader);
        }
        if (parentRef != null) {
            attributesCantBeCombined(Attribute.SPEC, Attribute.PARENT_REF, reader);
        }
        try {
            depBuilder.includeSpec(origin, spec);
        } catch (ProvisioningDescriptionException e) {
            throw new XMLStreamException("Failed to parse config", e);
        }
        ParsingUtils.parseNoContent(reader);
        return;
    }
    if (featureIdStr == null) {
        throw new XMLStreamException("Either " + Attribute.SPEC + " or " + Attribute.FEATURE_ID + " has to be present", reader.getLocation());
    }
    final FeatureId featureId = parseFeatureId(featureIdStr);
    final FeatureConfig fc = new FeatureConfig();
    fc.setOrigin(origin);
    fc.setParentRef(parentRef);
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case XMLStreamConstants.END_ELEMENT:
                try {
                    depBuilder.includeFeature(featureId, fc);
                } catch (ProvisioningDescriptionException e) {
                    throw new XMLStreamException("Failed to parse config", e);
                }
                return;
            case XMLStreamConstants.START_ELEMENT:
                final Element element = Element.of(reader.getName().getLocalPart());
                switch(element) {
                    case DEPENDS:
                        readFeatureDependency(reader, fc);
                        break;
                    case PARAM:
                        readParameter(reader, fc);
                        break;
                    case FEATURE:
                        final FeatureConfig nested = new FeatureConfig();
                        readFeatureConfig(reader, nested);
                        fc.addFeature(nested);
                        break;
                    case RESET_PARAM:
                        fc.resetParam(readParamAttr(reader));
                        break;
                    case UNSET_PARAM:
                        fc.unsetParam(readParamAttr(reader));
                        break;
                    default:
                        throw ParsingUtils.unexpectedContent(reader);
                }
                break;
            default:
                throw ParsingUtils.unexpectedContent(reader);
        }
    }
    throw ParsingUtils.endOfDocument(reader.getLocation());
}
Also used : FeatureId(org.jboss.galleon.spec.FeatureId) XMLStreamException(javax.xml.stream.XMLStreamException) FeatureConfig(org.jboss.galleon.config.FeatureConfig) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Aggregations

FeatureId (org.jboss.galleon.spec.FeatureId)5 Map (java.util.Map)3 FeatureConfig (org.jboss.galleon.config.FeatureConfig)3 LinkedHashMap (java.util.LinkedHashMap)2 XMLStreamException (javax.xml.stream.XMLStreamException)1 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)1 ResolvedFeatureId (org.jboss.galleon.runtime.ResolvedFeatureId)1 SpecId (org.jboss.galleon.spec.SpecId)1 ElementNode (org.jboss.galleon.xml.util.ElementNode)1