use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method collectDefaultConfigs.
private void collectDefaultConfigs() throws ProvisioningException {
if (config.hasDefinedConfigs()) {
for (ConfigModel config : config.getDefinedConfigs()) {
final ConfigId id = config.getId();
if (id.isModelOnly()) {
continue;
}
ConfigModelStack configStack = configsToBuild.get(id);
if (configStack == null) {
configStack = getConfigStack(id);
configsToBuild = CollectionUtils.putLinked(configsToBuild, id, configStack);
}
}
}
if (pushFpDepConfigs(config)) {
while (fpConfigStack.hasNext()) {
collectDefaultConfigs(fpConfigStack.next());
}
fpConfigStack.popLevel();
}
}
use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.
the class ConfigModelStack method merge.
void merge(ConfigModelStack other) throws ProvisioningException {
if (!other.props.isEmpty()) {
if (props.isEmpty()) {
props = other.props;
} else {
for (Map.Entry<String, String> prop : other.props.entrySet()) {
if (!props.containsKey(prop.getKey())) {
props.put(prop.getKey(), prop.getValue());
}
}
}
}
if (!other.configDeps.isEmpty()) {
if (configDeps.isEmpty()) {
configDeps = other.configDeps;
} else {
for (Map.Entry<String, ConfigId> configDep : other.configDeps.entrySet()) {
if (!configDeps.containsKey(configDep.getKey())) {
configDeps.put(configDep.getKey(), configDep.getValue());
}
}
}
}
if (other.includedLayers != null && !other.includedLayers.isEmpty()) {
for (ConfigId layerId : other.includedLayers) {
if (addLayer(layerId)) {
includedLayer(layerId);
}
}
}
if (other.specFeatures.isEmpty()) {
return;
}
for (Map.Entry<ResolvedSpecId, SpecFeatures> entry : other.specFeatures.entrySet()) {
final SpecFeatures otherSpecFeatures = entry.getValue();
SpecFeatures specFeatures = null;
for (ResolvedFeature feature : otherSpecFeatures.getFeatures()) {
if (lastProcessedScope.isFilteredOut(feature.getSpecId(), feature.id)) {
continue;
}
if (feature.id == null) {
if (specFeatures == null) {
specFeatures = getSpecFeatures(otherSpecFeatures.spec);
}
specFeatures.add(feature);
continue;
}
final ResolvedFeature localFeature = features.get(feature.id);
if (localFeature == null) {
feature = feature.copy(++featureIncludeCount);
features.put(feature.id, feature);
if (specFeatures == null) {
specFeatures = getSpecFeatures(otherSpecFeatures.spec);
}
specFeatures.add(feature);
} else {
localFeature.merge(feature, false);
}
}
}
}
use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.
the class StateInfoUtil method buildConfigs.
public static String buildConfigs(Map<String, List<ConfigInfo>> configs, ProvisioningLayout<FeaturePackLayout> pLayout) throws ProvisioningException, IOException {
if (!configs.isEmpty()) {
boolean hasLayers = false;
List<Table.Node> nodes = new ArrayList<>();
Map<String, Map<String, Set<String>>> layers = LayersConfigBuilder.getAllLayers(pLayout);
for (Entry<String, List<ConfigInfo>> entry : configs.entrySet()) {
if (!entry.getValue().isEmpty()) {
Table.Node model = new Table.Node(entry.getKey());
nodes.add(model);
for (ConfigInfo name : entry.getValue()) {
Table.Node nameNode = new Table.Node(name.getName());
model.addNext(nameNode);
// Compute the direct dependencies only, remove dependencies of dependencies.
for (ConfigId id : name.getlayers()) {
Map<String, Set<String>> map = layers.get(entry.getKey());
boolean foundAsDependency = false;
if (map != null) {
for (ConfigId l : name.getlayers()) {
if (l.getName().equals(id.getName())) {
continue;
}
Set<String> deps = map.get(l.getName());
if (deps != null) {
if (deps.contains(id.getName())) {
foundAsDependency = true;
break;
}
}
}
}
if (!foundAsDependency) {
hasLayers = true;
nameNode.addNext(new Table.Node(id.getName()));
}
}
ConfigModel m = pLayout.getConfig().getDefinedConfig(name.getId());
if (m != null) {
if (m.hasExcludedLayers()) {
for (String ex : m.getExcludedLayers()) {
hasLayers = true;
nameNode.addNext(new Table.Node(ex + "(excluded)"));
}
}
}
}
}
}
Table.Tree table;
if (hasLayers) {
table = new Table.Tree(Headers.CONFIGURATION, Headers.NAME, Headers.LAYERS);
} else {
table = new Table.Tree(Headers.CONFIGURATION, Headers.NAME);
}
table.addAll(nodes);
return "Configurations" + Config.getLineSeparator() + table.build();
}
return null;
}
use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.
the class ProvisioningXmlParser30 method parseConfigModelRef.
private static void parseConfigModelRef(XMLExtendedStreamReader reader, ConfigCustomizationsBuilder<?> fpBuilder, boolean include) throws XMLStreamException {
String name = null;
String model = null;
Boolean namedConfigsOnly = null;
for (int i = 0; i < reader.getAttributeCount(); i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i).getLocalPart());
switch(attribute) {
case NAME:
name = reader.getAttributeValue(i);
break;
case MODEL:
model = reader.getAttributeValue(i);
break;
case NAMED_MODELS_ONLY:
namedConfigsOnly = Boolean.parseBoolean(reader.getAttributeValue(i));
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
}
try {
if (include) {
if (name == null) {
fpBuilder.includeConfigModel(model);
} else {
fpBuilder.includeDefaultConfig(new ConfigId(model, name));
}
} else if (name == null) {
if (namedConfigsOnly != null) {
fpBuilder.excludeConfigModel(model, namedConfigsOnly);
} else {
fpBuilder.excludeConfigModel(model);
}
} else {
fpBuilder.excludeDefaultConfig(model, name);
}
} catch (ProvisioningDescriptionException e) {
throw new XMLStreamException(e);
}
ParsingUtils.parseNoContent(reader);
}
use of org.jboss.galleon.config.ConfigId in project galleon by wildfly.
the class ProvisioningXmlWriter method writeConfigCustomizations.
static void writeConfigCustomizations(ElementNode parent, String ns, ConfigCustomizations configCustoms) {
ElementNode defConfigsE = null;
final Boolean inheritConfigs = configCustoms.getInheritConfigs();
if (inheritConfigs != null) {
defConfigsE = addElement(parent, Element.DEFAULT_CONFIGS.getLocalName(), ns);
addAttribute(defConfigsE, Attribute.INHERIT, inheritConfigs.toString());
}
if (!configCustoms.isInheritModelOnlyConfigs()) {
if (defConfigsE == null) {
defConfigsE = addElement(parent, Element.DEFAULT_CONFIGS.getLocalName(), ns);
}
addAttribute(defConfigsE, Attribute.INHERIT_UNNAMED_MODELS, FALSE);
}
if (configCustoms.hasFullModelsExcluded()) {
if (defConfigsE == null) {
defConfigsE = addElement(parent, Element.DEFAULT_CONFIGS.getLocalName(), ns);
}
for (Map.Entry<String, Boolean> excluded : configCustoms.getFullModelsExcluded().entrySet()) {
final ElementNode exclude = addElement(defConfigsE, Element.EXCLUDE.getLocalName(), ns);
addAttribute(exclude, Attribute.MODEL, excluded.getKey());
if (!excluded.getValue()) {
addAttribute(exclude, Attribute.NAMED_MODELS_ONLY, FALSE);
}
}
}
if (configCustoms.hasFullModelsIncluded()) {
if (defConfigsE == null) {
defConfigsE = addElement(parent, Element.DEFAULT_CONFIGS.getLocalName(), ns);
}
final String[] array = configCustoms.getFullModelsIncluded().toArray(new String[configCustoms.getFullModelsIncluded().size()]);
Arrays.sort(array);
for (String modelName : array) {
final ElementNode included = addElement(defConfigsE, Element.INCLUDE.getLocalName(), ns);
addAttribute(included, Attribute.MODEL, modelName);
}
}
if (configCustoms.hasExcludedConfigs()) {
if (defConfigsE == null) {
defConfigsE = addElement(parent, Element.DEFAULT_CONFIGS.getLocalName(), ns);
}
for (ConfigId configId : configCustoms.getExcludedConfigs()) {
final ElementNode excluded = addElement(defConfigsE, Element.EXCLUDE.getLocalName(), ns);
if (configId.getModel() != null) {
addAttribute(excluded, Attribute.MODEL, configId.getModel());
}
if (configId.getName() != null) {
addAttribute(excluded, Attribute.NAME, configId.getName());
}
}
}
if (configCustoms.hasIncludedConfigs()) {
if (defConfigsE == null) {
defConfigsE = addElement(parent, Element.DEFAULT_CONFIGS.getLocalName(), ns);
}
for (ConfigId config : configCustoms.getIncludedConfigs()) {
final ElementNode includeElement = addElement(defConfigsE, Element.INCLUDE.getLocalName(), ns);
if (config.getModel() != null) {
addAttribute(includeElement, Attribute.MODEL, config.getModel());
}
if (config.getName() != null) {
addAttribute(includeElement, Attribute.NAME, config.getName());
}
}
}
if (configCustoms.hasDefinedConfigs()) {
for (ConfigModel config : configCustoms.getDefinedConfigs()) {
parent.addChild(ConfigXmlWriter.getInstance().toElement(config, ns));
}
}
}
Aggregations