Search in sources :

Example 1 with ResolvedFeatureId

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

the class ProvisionedConfigXmlParser30 method readFeature.

private static void readFeature(XMLExtendedStreamReader reader, ResolvedSpecId specId, ProvisionedConfigBuilder config) throws XMLStreamException {
    ResolvedFeatureId id = null;
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final Attribute attribute = Attribute.of(reader.getAttributeName(i));
        switch(attribute) {
            case ID:
                try {
                    id = ResolvedFeatureId.fromString(reader.getAttributeValue(i));
                } catch (ProvisioningDescriptionException e) {
                    throw new XMLStreamException(Errors.parseXml(), e);
                }
                break;
            default:
                throw ParsingUtils.unexpectedContent(reader);
        }
    }
    final ProvisionedFeatureBuilder featureBuilder = id == null ? ProvisionedFeatureBuilder.builder(specId) : ProvisionedFeatureBuilder.builder(id);
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case XMLStreamConstants.END_ELEMENT:
                {
                    try {
                        config.addFeature(featureBuilder.build());
                    } catch (ProvisioningDescriptionException e) {
                        throw new XMLStreamException("Failed to instantiate provisioned feature", reader.getLocation(), e);
                    }
                    return;
                }
            case XMLStreamConstants.START_ELEMENT:
                {
                    final Element element = Element.of(reader.getName());
                    switch(element) {
                        case PARAM:
                            readParam(reader, featureBuilder);
                            break;
                        default:
                            throw ParsingUtils.unexpectedContent(reader);
                    }
                    break;
                }
            default:
                {
                    throw ParsingUtils.unexpectedContent(reader);
                }
        }
    }
    throw ParsingUtils.endOfDocument(reader.getLocation());
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException) ResolvedFeatureId(org.jboss.galleon.runtime.ResolvedFeatureId)

Example 2 with ResolvedFeatureId

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

Aggregations

ResolvedFeatureId (org.jboss.galleon.runtime.ResolvedFeatureId)2 XMLStreamException (javax.xml.stream.XMLStreamException)1 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)1 FeatureId (org.jboss.galleon.spec.FeatureId)1