Search in sources :

Example 71 with FeatureConfig

use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.

the class FeatureGroupXml method handleFeatureGroupBodyElement.

public static boolean handleFeatureGroupBodyElement(XMLExtendedStreamReader reader, FeatureGroupBuilderSupport<?> builder) throws XMLStreamException {
    final Element element = Element.of(reader.getName().getLocalPart());
    switch(element) {
        case INCLUDE:
            readInclude(reader, null, builder);
            break;
        case EXCLUDE:
            readExclude(reader, null, builder);
            break;
        case ORIGIN:
            readOriginIncludeExclude(reader, builder);
            break;
        case FEATURE_GROUP:
            builder.addFeatureGroup(readFeatureGroupDependency(null, reader));
            break;
        case FEATURE:
            final FeatureConfig nested = new FeatureConfig();
            readFeatureConfig(reader, nested);
            builder.addFeature(nested);
            break;
        case PACKAGES:
            PackageDepsSpecXmlParser.parsePackageDeps(Element.PACKAGES, reader, builder);
            break;
        default:
            return false;
    }
    return true;
}
Also used : FeatureConfig(org.jboss.galleon.config.FeatureConfig)

Example 72 with FeatureConfig

use of org.jboss.galleon.config.FeatureConfig 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)

Example 73 with FeatureConfig

use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.

the class FeatureGroupParsingTestCase method testMain.

@Test
public void testMain() throws Exception {
    final FeatureGroup xmlConfig = parseConfig("feature-group.xml");
    final FeatureGroup expected = FeatureGroup.builder("groupName").addFeatureGroup(FeatureGroup.builder("dep1").setInheritFeatures(true).build()).addFeatureGroup(FeatureGroup.builder("dep2").setInheritFeatures(false).build()).addFeatureGroup(FeatureGroup.builder("dep3").setInheritFeatures(false).includeSpec("spec1").includeFeature(FeatureId.fromString("spec2:p1=v1,p2=v2"), new FeatureConfig("spec2").setParam("p1", "v1").setParam("p2", "v2")).includeFeature(FeatureId.fromString("spec3:p1=v1"), new FeatureConfig("spec3").addFeatureDep(FeatureId.fromString("spec4:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec5:p1=v1,p2=v2")).setParam("p1", "v1").setParam("p2", "v2").addFeature(new FeatureConfig("spec9").setParam("p1", "v1").addFeature(FeatureConfig.newConfig("spec10").addFeature(FeatureConfig.newConfig("spec11").setParentRef("spec10-ref").setParam("p1", "v1"))))).excludeSpec("spec6").excludeSpec("spec7").excludeFeature(FeatureId.fromString("spec8:p1=v1")).excludeFeature(FeatureId.fromString("spec8:p1=v2")).build()).addFeatureGroup(FeatureGroup.forGroup("source4", "dep4")).addFeature(new FeatureConfig("spec1").setOrigin("source4").setParam("p1", "v1").setParam("p2", "v2").addFeatureDep(FeatureId.builder("spec2").setParam("p1", "v1").setParam("p2", "v2").build()).addFeatureDep(FeatureId.create("spec3", "p3", "v3"))).addFeature(new FeatureConfig("spec1").addFeatureDep(FeatureId.fromString("spec2:p1=v1,p2=v2")).addFeatureDep(FeatureId.fromString("spec3:p3=v3")).setParam("p1", "v1").setParam("p2", "v2")).addFeature(new FeatureConfig("spec4").setParam("p1", "v1").addFeature(FeatureConfig.newConfig("spec5").addFeature(FeatureConfig.newConfig("spec6").setParentRef("spec5-ref").setParam("p1", "v1")))).addPackageDep("p1").addPackageDep("p2", true).addPackageDep("fp1", "p2").addPackageDep("fp1", "p3", true).build();
    assertEquals(expected, xmlConfig);
}
Also used : FeatureGroup(org.jboss.galleon.config.FeatureGroup) FeatureConfig(org.jboss.galleon.config.FeatureConfig) Test(org.junit.Test)

Example 74 with FeatureConfig

use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.

the class BasicConfigIncludeExcludeTestCase method createFeaturePacks.

@Override
protected void createFeaturePacks(FeaturePackCreator creator) throws ProvisioningException {
    prod1 = newFpl("prod1", "1", "1.0.0.Final");
    creator.newFeaturePack(prod1.getFPID()).addFeatureSpec(FeatureSpec.builder("specA").addParam(FeatureParameterSpec.createId("id")).addParam(FeatureParameterSpec.create("a", "spec")).addParam(FeatureParameterSpec.create("b", "spec")).addParam(FeatureParameterSpec.create("c", "spec")).build()).addConfig(ConfigModel.builder("model1", "name1").addFeature(new FeatureConfig("specA").setParam("id", "1").setParam("a", "config").setParam("b", "config")).build()).addConfig(ConfigModel.builder("model1", "name2").addFeature(new FeatureConfig("specA").setParam("id", "2").setParam("a", "config").setParam("b", "config")).build()).addService(StateDiffPlugin.class, BasicStateDiffPlugin.class).addPlugin(TestConfigsPersistingPlugin.class);
}
Also used : FeatureConfig(org.jboss.galleon.config.FeatureConfig) StateDiffPlugin(org.jboss.galleon.plugin.StateDiffPlugin)

Example 75 with FeatureConfig

use of org.jboss.galleon.config.FeatureConfig in project galleon by wildfly.

the class BasicPersistFeatureIncludeExcludeAddTestCase method createFeaturePacks.

@Override
protected void createFeaturePacks(FeaturePackCreator creator) throws ProvisioningException {
    prod1 = newFpl("prod1", "1", "1.0.0.Final");
    creator.newFeaturePack(prod1.getFPID()).addFeatureSpec(FeatureSpec.builder("specA").addParam(FeatureParameterSpec.createId("id")).addParam(FeatureParameterSpec.create("a", "spec")).addParam(FeatureParameterSpec.create("b", "spec")).addParam(FeatureParameterSpec.create("c", "spec")).build()).addConfig(ConfigModel.builder("model1", "name1").addFeature(new FeatureConfig("specA").setParam("id", "1").setParam("a", "config").setParam("b", "config")).addFeature(new FeatureConfig("specA").setParam("id", "2").setParam("a", "config").setParam("b", "config")).build()).addService(StateDiffPlugin.class, BasicStateDiffPlugin.class).addPlugin(TestConfigsPersistingPlugin.class);
}
Also used : FeatureConfig(org.jboss.galleon.config.FeatureConfig) StateDiffPlugin(org.jboss.galleon.plugin.StateDiffPlugin)

Aggregations

FeatureConfig (org.jboss.galleon.config.FeatureConfig)76 StateDiffPlugin (org.jboss.galleon.plugin.StateDiffPlugin)8 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)6 FeaturePackCreator (org.jboss.galleon.creator.FeaturePackCreator)5 Test (org.junit.Test)4 Map (java.util.Map)3 FeatureId (org.jboss.galleon.spec.FeatureId)3 LinkedHashMap (java.util.LinkedHashMap)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)2 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)2 HashMap (java.util.HashMap)1 ProvisioningException (org.jboss.galleon.ProvisioningException)1 ConfigId (org.jboss.galleon.config.ConfigId)1 FeatureGroup (org.jboss.galleon.config.FeatureGroup)1 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)1 ResolvedSpecId (org.jboss.galleon.runtime.ResolvedSpecId)1 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)1 SpecId (org.jboss.galleon.spec.SpecId)1 BasicStateDiffPlugin (org.jboss.galleon.userchanges.persist.test.BasicStateDiffPlugin)1