Search in sources :

Example 16 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class ProvisionedConfigXmlWriter method toElement.

protected ElementNode toElement(ProvisionedConfig config, String ns) throws XMLStreamException {
    final ElementNode configE = addElement(null, Element.CONFIG.getLocalName(), ns);
    if (config.getName() != null) {
        addAttribute(configE, Attribute.NAME, config.getName());
    }
    if (config.getModel() != null) {
        addAttribute(configE, Attribute.MODEL, config.getModel());
    }
    if (config.hasProperties()) {
        final ElementNode propsE = addElement(configE, Element.PROPS.getLocalName(), ns);
        for (Map.Entry<String, String> entry : config.getProperties().entrySet()) {
            final ElementNode propE = addElement(propsE, Element.PROP.getLocalName(), ns);
            addAttribute(propE, Attribute.NAME, entry.getKey());
            addAttribute(propE, Attribute.VALUE, entry.getValue());
        }
    }
    if (config.hasLayers()) {
        final ElementNode propsE = addElement(configE, Element.LAYERS.getLocalName(), ns);
        for (ConfigId layerId : config.getLayers()) {
            final ElementNode propE = addElement(propsE, Element.LAYER.getLocalName(), ns);
            if (layerId.getModel() != null) {
                addAttribute(propE, Attribute.MODEL, layerId.getModel());
            }
            addAttribute(propE, Attribute.NAME, layerId.getName());
        }
    }
    if (config.hasFeatures()) {
        try {
            config.handle(new XmlConfigHandler(configE));
        } catch (ProvisioningException e) {
            throw new XMLStreamException("Failed to marshal ProvisionedConfig", e);
        }
    }
    return configE;
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) ProvisioningException(org.jboss.galleon.ProvisioningException) ConfigId(org.jboss.galleon.config.ConfigId) ElementNode(org.jboss.galleon.xml.util.ElementNode) Map(java.util.Map)

Example 17 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class ProvisionedStateXmlWriter method writeFeaturePack.

private void writeFeaturePack(ElementNode fp, FeaturePack<?> featurePack) {
    addAttribute(fp, Attribute.LOCATION, featurePack.getFPID().toString());
    if (featurePack.hasPackages()) {
        final ElementNode packages = addElement(fp, Element.PACKAGES);
        for (FeaturePackPackage pkg : featurePack.getPackages()) {
            final ElementNode pkgElement = addElement(packages, Element.PACKAGE);
            addAttribute(pkgElement, Attribute.NAME, pkg.getName());
        }
    }
}
Also used : FeaturePackPackage(org.jboss.galleon.state.FeaturePackPackage) ElementNode(org.jboss.galleon.xml.util.ElementNode)

Example 18 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class ProvisionedStateXmlWriter method toElement.

@Override
protected ElementNode toElement(FeaturePackSet<?> provisionedState) throws XMLStreamException {
    final ElementNode pkg = addElement(null, Element.INSTALLATION);
    if (provisionedState.hasFeaturePacks()) {
        for (FeaturePack<?> fp : provisionedState.getFeaturePacks()) {
            final ElementNode fpElement = addElement(pkg, Element.FEATURE_PACK);
            writeFeaturePack(fpElement, fp);
        }
    }
    if (provisionedState.hasConfigs()) {
        for (ProvisionedConfig config : provisionedState.getConfigs()) {
            pkg.addChild(ProvisionedConfigXmlWriter.getInstance().toElement(config, Element.CONFIG.getNamespace()));
        }
    }
    return pkg;
}
Also used : ElementNode(org.jboss.galleon.xml.util.ElementNode) ProvisionedConfig(org.jboss.galleon.state.ProvisionedConfig)

Example 19 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class FeatureGroupXmlWriter method addFeatureGroupDepBody.

public static void addFeatureGroupDepBody(FeatureGroupSupport dep, final ElementNode depE, String ns) {
    if (dep.getName() != null) {
        addAttribute(depE, Attribute.NAME, dep.getName());
    }
    if (!dep.isInheritFeatures()) {
        addAttribute(depE, Attribute.INHERIT_FEATURES, FALSE);
    }
    addFeatureGroupIncludeExclude(dep, ns, depE);
    writeFeatureGroupSpecBody(depE, dep, ns);
    if (dep.hasExternalFeatureGroups()) {
        for (Map.Entry<String, FeatureGroup> entry : dep.getExternalFeatureGroups().entrySet()) {
            final ElementNode fpE = addElement(depE, Element.ORIGIN.getLocalName(), ns);
            addAttribute(fpE, Attribute.NAME, entry.getKey());
            addFeatureGroupIncludeExclude(entry.getValue(), ns, fpE);
        }
    }
    if (dep.hasPackageDeps()) {
        PackageXmlWriter.writePackageDeps(dep, addElement(depE, Element.PACKAGES.getLocalName(), ns));
    }
}
Also used : FeatureGroup(org.jboss.galleon.config.FeatureGroup) ElementNode(org.jboss.galleon.xml.util.ElementNode) Map(java.util.Map)

Example 20 with ElementNode

use of org.jboss.galleon.xml.util.ElementNode in project galleon by wildfly.

the class FeatureGroupXmlWriter method addFeatureConfig.

public static void addFeatureConfig(ElementNode parentE, FeatureConfig fc, String ns) {
    final ElementNode fcE = addElement(parentE, Element.FEATURE.getLocalName(), ns);
    addAttribute(fcE, Attribute.SPEC, fc.getSpecId().toString());
    if (fc.getParentRef() != null) {
        addAttribute(fcE, Attribute.PARENT_REF, fc.getParentRef());
    }
    addFeatureConfigBody(fcE, null, fc, ns);
}
Also used : ElementNode(org.jboss.galleon.xml.util.ElementNode)

Aggregations

ElementNode (org.jboss.galleon.xml.util.ElementNode)27 Map (java.util.Map)8 TextNode (org.jboss.galleon.xml.util.TextNode)4 XMLStreamException (javax.xml.stream.XMLStreamException)3 ConfigId (org.jboss.galleon.config.ConfigId)3 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)2 FeatureDependencySpec (org.jboss.galleon.spec.FeatureDependencySpec)2 ProvisioningException (org.jboss.galleon.ProvisioningException)1 ConfigItem (org.jboss.galleon.config.ConfigItem)1 ConfigModel (org.jboss.galleon.config.ConfigModel)1 FeatureConfig (org.jboss.galleon.config.FeatureConfig)1 FeatureGroup (org.jboss.galleon.config.FeatureGroup)1 CapabilitySpec (org.jboss.galleon.spec.CapabilitySpec)1 ConfigLayerDependency (org.jboss.galleon.spec.ConfigLayerDependency)1 FeatureAnnotation (org.jboss.galleon.spec.FeatureAnnotation)1 FeatureId (org.jboss.galleon.spec.FeatureId)1 FeaturePackPlugin (org.jboss.galleon.spec.FeaturePackPlugin)1 FeatureParameterSpec (org.jboss.galleon.spec.FeatureParameterSpec)1 FeatureReferenceSpec (org.jboss.galleon.spec.FeatureReferenceSpec)1 PackageDependencySpec (org.jboss.galleon.spec.PackageDependencySpec)1