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;
}
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());
}
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);
}
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);
}
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);
}
Aggregations