final fix for module slotting

This commit is contained in:
2023-02-19 11:47:11 -05:00
parent 1c4e3b04ff
commit 3752a60efd
3 changed files with 14 additions and 6 deletions

View File

@@ -42,24 +42,28 @@ public abstract class AbstractXmlBuilder {
protected final String ns;
protected final Document xmldoc;
protected final Element dependenciesElement;
protected final boolean enableSlotAttribute;
public AbstractXmlBuilder(String ns) throws ParserConfigurationException {
public AbstractXmlBuilder(String ns, boolean enableSlotAttribute) throws ParserConfigurationException {
DocumentBuilder docbuilder = this.dbfactory.newDocumentBuilder();
this.ns = ns;
this.xmldoc = docbuilder.newDocument();
this.dependenciesElement = this.xmldoc.createElementNS(this.ns, "dependencies");
this.enableSlotAttribute = enableSlotAttribute;
}
public abstract String getXmlFilename();
public void addDependency(Module module, boolean isDeployment) {
String name = module.id;
if (module.version != null)
if (!this.enableSlotAttribute && module.version != null && !module.version.equals("main"))
name += ":" + module.version;
Element moduleElement = this.xmldoc.createElementNS(this.ns, "module");
moduleElement.setAttribute("name", name);
if (this.enableSlotAttribute && module.version != null && !module.version.equals("main"))
moduleElement.setAttribute("slot", module.version);
if (module.export)
moduleElement.setAttribute("export", Boolean.TRUE.toString());
if (isDeployment && module.exportMetaInf)

View File

@@ -25,7 +25,7 @@ import org.w3c.dom.Element;
public class DeploymentXmlBuilder extends AbstractXmlBuilder {
public DeploymentXmlBuilder(String schemaVersion) throws ParserConfigurationException {
super("urn:jboss:deployment-structure:" + schemaVersion);
super("urn:jboss:deployment-structure:" + schemaVersion, true);
Element deploymentElement = this.xmldoc.createElementNS(this.ns, "deployment");
deploymentElement.appendChild(this.dependenciesElement);

View File

@@ -33,13 +33,17 @@ public class ModuleXmlBuilder extends AbstractXmlBuilder {
}
public ModuleXmlBuilder(String id, String schemaVersion, String moduleVersion) throws ParserConfigurationException {
super("urn:jboss:module:" + schemaVersion);
super("urn:jboss:module:" + schemaVersion, schemaVersion.equals("1.0") ? true : false);
this.resourcesElement = this.xmldoc.createElementNS(this.ns, "resources");
String name = id;
if (!this.enableSlotAttribute && moduleVersion != null && !moduleVersion.equals("main"))
name += ":" + moduleVersion;
Element moduleElement = this.xmldoc.createElementNS(this.ns, "module");
moduleElement.setAttribute("name", id);
if (moduleVersion != null)
moduleElement.setAttribute("name", name);
if (this.enableSlotAttribute && moduleVersion != null && !moduleVersion.equals("main"))
moduleElement.setAttribute("slot", moduleVersion);
moduleElement.appendChild(this.resourcesElement);
moduleElement.appendChild(this.dependenciesElement);