final fix for module slotting
This commit is contained in:
@@ -42,24 +42,28 @@ public abstract class AbstractXmlBuilder {
|
|||||||
protected final String ns;
|
protected final String ns;
|
||||||
protected final Document xmldoc;
|
protected final Document xmldoc;
|
||||||
protected final Element dependenciesElement;
|
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();
|
DocumentBuilder docbuilder = this.dbfactory.newDocumentBuilder();
|
||||||
|
|
||||||
this.ns = ns;
|
this.ns = ns;
|
||||||
this.xmldoc = docbuilder.newDocument();
|
this.xmldoc = docbuilder.newDocument();
|
||||||
this.dependenciesElement = this.xmldoc.createElementNS(this.ns, "dependencies");
|
this.dependenciesElement = this.xmldoc.createElementNS(this.ns, "dependencies");
|
||||||
|
this.enableSlotAttribute = enableSlotAttribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getXmlFilename();
|
public abstract String getXmlFilename();
|
||||||
|
|
||||||
public void addDependency(Module module, boolean isDeployment) {
|
public void addDependency(Module module, boolean isDeployment) {
|
||||||
String name = module.id;
|
String name = module.id;
|
||||||
if (module.version != null)
|
if (!this.enableSlotAttribute && module.version != null && !module.version.equals("main"))
|
||||||
name += ":" + module.version;
|
name += ":" + module.version;
|
||||||
|
|
||||||
Element moduleElement = this.xmldoc.createElementNS(this.ns, "module");
|
Element moduleElement = this.xmldoc.createElementNS(this.ns, "module");
|
||||||
moduleElement.setAttribute("name", name);
|
moduleElement.setAttribute("name", name);
|
||||||
|
if (this.enableSlotAttribute && module.version != null && !module.version.equals("main"))
|
||||||
|
moduleElement.setAttribute("slot", module.version);
|
||||||
if (module.export)
|
if (module.export)
|
||||||
moduleElement.setAttribute("export", Boolean.TRUE.toString());
|
moduleElement.setAttribute("export", Boolean.TRUE.toString());
|
||||||
if (isDeployment && module.exportMetaInf)
|
if (isDeployment && module.exportMetaInf)
|
||||||
|
@@ -25,7 +25,7 @@ import org.w3c.dom.Element;
|
|||||||
public class DeploymentXmlBuilder extends AbstractXmlBuilder {
|
public class DeploymentXmlBuilder extends AbstractXmlBuilder {
|
||||||
|
|
||||||
public DeploymentXmlBuilder(String schemaVersion) throws ParserConfigurationException {
|
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");
|
Element deploymentElement = this.xmldoc.createElementNS(this.ns, "deployment");
|
||||||
deploymentElement.appendChild(this.dependenciesElement);
|
deploymentElement.appendChild(this.dependenciesElement);
|
||||||
|
@@ -33,13 +33,17 @@ public class ModuleXmlBuilder extends AbstractXmlBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ModuleXmlBuilder(String id, String schemaVersion, String moduleVersion) throws ParserConfigurationException {
|
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");
|
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");
|
Element moduleElement = this.xmldoc.createElementNS(this.ns, "module");
|
||||||
moduleElement.setAttribute("name", id);
|
moduleElement.setAttribute("name", name);
|
||||||
if (moduleVersion != null)
|
if (this.enableSlotAttribute && moduleVersion != null && !moduleVersion.equals("main"))
|
||||||
moduleElement.setAttribute("slot", moduleVersion);
|
moduleElement.setAttribute("slot", moduleVersion);
|
||||||
moduleElement.appendChild(this.resourcesElement);
|
moduleElement.appendChild(this.resourcesElement);
|
||||||
moduleElement.appendChild(this.dependenciesElement);
|
moduleElement.appendChild(this.dependenciesElement);
|
||||||
|
Reference in New Issue
Block a user