use of org.jboss.galleon.config.ConfigModel 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.ConfigModel 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));
}
}
}
use of org.jboss.galleon.config.ConfigModel in project galleon by wildfly.
the class LayersConfigBuilder method build.
ProvisioningConfig build() throws ProvisioningException, IOException {
// Reuse existing configuration builder.
ProvisioningConfig existing = mgr.getProvisioningConfig();
ProvisioningConfig.Builder builder = null;
FeaturePackConfig.Builder fpBuilder = null;
ConfigModel.Builder configBuilder = null;
if (existing != null) {
builder = ProvisioningConfig.builder(existing);
ConfigId id = new ConfigId(model, config);
if (existing.hasDefinedConfig(id)) {
ConfigModel cmodel = existing.getDefinedConfig(id);
configBuilder = ConfigModel.builder(cmodel);
handleLayers(configBuilder, cmodel);
builder.removeConfig(id);
}
if (builder.hasFeaturePackDep(loc.getProducer())) {
FeaturePackConfig fp = existing.getFeaturePackDep(loc.getProducer());
fpBuilder = FeaturePackConfig.builder(fp);
builder.removeFeaturePackDep(fp.getLocation());
}
}
if (builder == null) {
builder = ProvisioningConfig.builder();
}
if (configBuilder == null) {
configBuilder = ConfigModel.builder(model, config);
handleLayers(configBuilder, null);
}
if (fpBuilder == null) {
fpBuilder = FeaturePackConfig.builder(loc).setInheritConfigs(false).setInheritPackages(false);
}
builder.addConfig(configBuilder.build());
builder.addFeaturePackDep(fpBuilder.build());
return builder.build();
}
use of org.jboss.galleon.config.ConfigModel in project galleon by wildfly.
the class FeaturePackInstaller method install.
public void install() {
try (ProvisioningManager manager = ProvisioningManager.builder().addArtifactResolver(LegacyGalleon1RepositoryManager.newInstance(repoHome)).setInstallationHome(installationDir).setRecordState(recordState).build()) {
System.setProperty("org.wildfly.logging.skipLogManagerCheck", "true");
ConfigModel config = null;
if (customConfig != null && Files.exists(customConfig)) {
try (BufferedReader reader = Files.newBufferedReader(customConfig)) {
config = ConfigXmlParser.getInstance().parse(reader);
} catch (XMLStreamException | IOException ex) {
throw new IllegalArgumentException("Couldn't load the customization configuration " + customConfig, ex);
}
}
if (localPath != null) {
fpl = manager.getLayoutFactory().addLocal(localPath, false);
}
FeaturePackConfig.Builder fpConfigBuilder = FeaturePackConfig.builder(fpl).setInheritPackages(inheritPackages).setInheritConfigs(inheritConfigs);
if (includedConfigs != null && !includedConfigs.isEmpty()) {
for (ConfigurationId configId : includedConfigs) {
if (configId.isModelOnly()) {
fpConfigBuilder.includeConfigModel(configId.getId().getModel());
} else {
fpConfigBuilder.includeDefaultConfig(configId.getId());
}
}
}
if (config != null) {
fpConfigBuilder.addConfig(config);
}
if (includedPackages != null && !includedPackages.isEmpty()) {
for (String includedPackage : includedPackages) {
fpConfigBuilder.includePackage(includedPackage);
}
}
if (excludedPackages != null && !excludedPackages.isEmpty()) {
for (String excludedPackage : excludedPackages) {
fpConfigBuilder.excludePackage(excludedPackage);
}
}
manager.install(fpConfigBuilder.build(), pluginOptions);
} catch (ProvisioningException ex) {
throw new IllegalArgumentException("Couldn't install feature-pack " + fpl, ex);
} finally {
System.clearProperty("org.wildfly.logging.skipLogManagerCheck");
}
}
use of org.jboss.galleon.config.ConfigModel in project galleon by wildfly.
the class ProvisioningRuntimeBuilder method collectDefaultConfigs.
private void collectDefaultConfigs(FeaturePackConfig fpConfig) throws ProvisioningException {
thisOrigin = layout.getFeaturePack(fpConfig.getLocation().getProducer());
final FeaturePackRuntimeBuilder parentFp = setOrigin(thisOrigin);
try {
if (fpConfig.hasDefinedConfigs()) {
for (ConfigModel config : fpConfig.getDefinedConfigs()) {
final ConfigId id = config.getId();
if (id.isModelOnly() || fpConfigStack.isFilteredOut(thisOrigin.producer, id, true)) {
continue;
}
ConfigModelStack configStack = configsToBuild.get(id);
if (configStack == null) {
configStack = getConfigStack(id);
configsToBuild = CollectionUtils.putLinked(configsToBuild, id, configStack);
}
}
}
if (!fpConfig.isTransitive()) {
if (fpConfig.hasIncludedConfigs()) {
for (ConfigId id : fpConfig.getIncludedConfigs()) {
collectConfigIfNotFiltered(thisOrigin.producer, id);
}
}
final FeaturePackSpec currentSpec = currentOrigin.getSpec();
if (currentSpec.hasDefinedConfigs()) {
for (ConfigModel config : currentSpec.getDefinedConfigs()) {
collectConfigIfNotFiltered(thisOrigin.producer, config.getId());
}
}
if (currentSpec.hasFeaturePackDeps()) {
boolean extendedStackLevel = false;
if (currentSpec.hasTransitiveDeps()) {
for (FeaturePackConfig fpDep : currentSpec.getTransitiveDeps()) {
extendedStackLevel |= fpConfigStack.push(fpDep, extendedStackLevel);
}
}
for (FeaturePackConfig fpDep : currentSpec.getFeaturePackDeps()) {
extendedStackLevel |= fpConfigStack.push(fpDep, extendedStackLevel);
}
if (extendedStackLevel) {
while (fpConfigStack.hasNext()) {
collectDefaultConfigs(fpConfigStack.next());
}
}
if (extendedStackLevel) {
fpConfigStack.popLevel();
}
}
}
} finally {
this.thisOrigin = parentFp;
setOrigin(parentFp);
}
}
Aggregations