diff --git a/controller/src/main/java/org/jboss/as/controller/parsing/ExtensionXml.java b/controller/src/main/java/org/jboss/as/controller/parsing/ExtensionXml.java index 7e27dbb34ef..27307ef7519 100644 --- a/controller/src/main/java/org/jboss/as/controller/parsing/ExtensionXml.java +++ b/controller/src/main/java/org/jboss/as/controller/parsing/ExtensionXml.java @@ -72,6 +72,11 @@ public void writeExtensions(final XMLExtendedStreamWriter writer, final ModelNod } } + @Deprecated + public void parseExtensions(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace namespace, final List list) throws XMLStreamException { + parseExtensions(reader, address, namespace.getUriString(), list); + } + public void parseExtensions(final XMLExtendedStreamReader reader, final ModelNode address, final String expectedNs, final List list) throws XMLStreamException { DeferredExtensionContext ctx = this.deferredExtensionContext; diff --git a/controller/src/main/java/org/jboss/as/controller/parsing/Namespace.java b/controller/src/main/java/org/jboss/as/controller/parsing/Namespace.java new file mode 100644 index 00000000000..609f0603858 --- /dev/null +++ b/controller/src/main/java/org/jboss/as/controller/parsing/Namespace.java @@ -0,0 +1,183 @@ +/* + * Copyright The WildFly Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.jboss.as.controller.parsing; + +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.XMLConstants; + +/** + * An enumeration of the supported domain model namespaces. + * + * @author David M. Lloyd + */ +public enum Namespace { + + // must be first + UNKNOWN(null), NONE(null), + + // predefined standard + XML_SCHEMA_INSTANCE("http://www.w3.org/2001/XMLSchema-instance"), + + // domain versions, in numerical order + DOMAIN_1_0(1, "urn:jboss:domain:1.0"), + + DOMAIN_1_1(1, "urn:jboss:domain:1.1"), + + DOMAIN_1_2(1, "urn:jboss:domain:1.2"), + + DOMAIN_1_3(1, "urn:jboss:domain:1.3"), + + DOMAIN_1_4(1, "urn:jboss:domain:1.4"), + + DOMAIN_1_5(1, "urn:jboss:domain:1.5"), + + DOMAIN_1_6(1, "urn:jboss:domain:1.6"), + + DOMAIN_1_7(1, "urn:jboss:domain:1.7"), + + DOMAIN_1_8(1, "urn:jboss:domain:1.8"), + + DOMAIN_2_0(2, "urn:jboss:domain:2.0"), + + DOMAIN_2_1(2, "urn:jboss:domain:2.1"), + + DOMAIN_2_2(2, "urn:jboss:domain:2.2"), + + DOMAIN_3_0(3, "urn:jboss:domain:3.0"), + + DOMAIN_4_0(4, "urn:jboss:domain:4.0"), + + DOMAIN_4_1(4, "urn:jboss:domain:4.1"), + + DOMAIN_4_2(4, "urn:jboss:domain:4.2"), + + // WF 11, EAP 7.1 + DOMAIN_5_0(5, "urn:jboss:domain:5.0"), + + // WF 12 + DOMAIN_6_0(6, "urn:jboss:domain:6.0"), + + // WF 13 + DOMAIN_7_0(7, "urn:jboss:domain:7.0"), + + // WF 14 + DOMAIN_8_0(8, "urn:jboss:domain:8.0"), + + // WF 15 + DOMAIN_9_0(9, "urn:jboss:domain:9.0"), + + // WF 16 / WF 17 / WF 18 + DOMAIN_10_0(10, "urn:jboss:domain:10.0"), + + // EAP 7.3 + DOMAIN_11_0(11, "urn:jboss:domain:11.0"), + + // WF 19 + DOMAIN_12_0(12, "urn:jboss:domain:12.0"), + + // WF 20 + DOMAIN_13_0(13, "urn:jboss:domain:13.0"), + + // WF 21 + DOMAIN_14_0(14, "urn:jboss:domain:14.0"), + + // WF 22 + DOMAIN_15_0(15, "urn:jboss:domain:15.0"), + + // WF 23 + DOMAIN_16_0(16, "urn:jboss:domain:16.0"), + + // WF 24 + DOMAIN_17_0(17, "urn:jboss:domain:17.0"), + + // WF 25 + DOMAIN_18_0(18, "urn:jboss:domain:18.0"), + + // WF 26 + DOMAIN_19_0(19, "urn:jboss:domain:19.0"), + + DOMAIN_20_0(20, "urn:jboss:domain:20.0"); + + /** + * The current namespace version. + */ + public static final Namespace CURRENT = DOMAIN_20_0; + + public static final Namespace[] ALL_NAMESPACES = domainValues(); + + private final int majorVersion; + private final String name; + + Namespace(final String name) { + this(-1, name); + } + + Namespace(final int majorVersion, final String name) { + this.majorVersion = majorVersion; + this.name = name; + } + + /** + * Get the major version represented by this namespace. + * + * @return The major version. + */ + public int getMajorVersion() { + return majorVersion; + } + + /** + * Get the URI of this namespace. + * + * @return the URI + */ + public String getUriString() { + return name; + } + + /** + * Set of all namespaces, excluding the special {@link #UNKNOWN} value. + */ + public static final EnumSet STANDARD_NAMESPACES = EnumSet.complementOf(EnumSet.of(UNKNOWN, XML_SCHEMA_INSTANCE)); + + private static final Map MAP; + + static { + final Map map = new HashMap(); + for (Namespace namespace : values()) { + final String name = namespace.getUriString(); + if (name != null) + map.put(name, namespace); + } + MAP = map; + } + + public static Namespace forUri(String uri) { + // FIXME when STXM-8 is done, remove the null check + if (uri == null || XMLConstants.NULL_NS_URI.equals(uri)) + return NONE; + final Namespace element = MAP.get(uri); + return element == null ? UNKNOWN : element; + } + + public static Namespace[] domainValues() { + Namespace[] temp = values(); + // The 3 is for the 3 namespaces excluded below. + Namespace[] response = new Namespace[temp.length - 3]; + int nextPos = 0; + for (Namespace current : temp) { + if (current != UNKNOWN && current != NONE && current != XML_SCHEMA_INSTANCE) { + response[nextPos++] = current; + } + } + + return response; + } + +} diff --git a/controller/src/main/java/org/jboss/as/controller/parsing/ParseUtils.java b/controller/src/main/java/org/jboss/as/controller/parsing/ParseUtils.java index 11ee253549a..a58116012c8 100644 --- a/controller/src/main/java/org/jboss/as/controller/parsing/ParseUtils.java +++ b/controller/src/main/java/org/jboss/as/controller/parsing/ParseUtils.java @@ -70,6 +70,11 @@ public static Element nextElement(XMLExtendedStreamReader reader, String expecte throw unexpectedElement(reader); } + @Deprecated + public static Element nextElement(XMLExtendedStreamReader reader, Namespace namespace) throws XMLStreamException { + return nextElement(reader, namespace.getUriString()); + } + /** * Get an exception reporting an unexpected XML element. * @param reader the stream reader @@ -320,6 +325,11 @@ public static void requireNoContent(final XMLExtendedStreamReader reader) throws } } + @Deprecated + public static void requireNamespace(final XMLExtendedStreamReader reader, final Namespace namespace) throws XMLStreamException { + requireNamespace(reader, namespace.getUriString()); + } + /** * Require that the namespace of the current element matches the required namespace. * diff --git a/server/src/main/java/org/jboss/as/server/parsing/CommonXml.java b/server/src/main/java/org/jboss/as/server/parsing/CommonXml.java index 41efaa65143..0af071485c0 100644 --- a/server/src/main/java/org/jboss/as/server/parsing/CommonXml.java +++ b/server/src/main/java/org/jboss/as/server/parsing/CommonXml.java @@ -27,6 +27,7 @@ import org.jboss.as.controller.operations.common.SchemaLocationAddHandler; import org.jboss.as.controller.parsing.Attribute; import org.jboss.as.controller.parsing.Element; +import org.jboss.as.controller.parsing.Namespace; import org.jboss.as.controller.persistence.ModelMarshallingContext; import org.jboss.as.controller.persistence.SubsystemMarshallingContext; import org.jboss.dmr.ModelNode; @@ -146,16 +147,42 @@ protected void writePaths(final XMLExtendedStreamWriter writer, final ModelNode pathsXml.writePaths(writer, node, namedPath); } + @Deprecated + protected void parsePaths(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace namespace, final List list, + final boolean requirePath) throws XMLStreamException { + parsePaths(reader, address, namespace.getUriString(), list, requirePath); + } + protected void parsePaths(final XMLExtendedStreamReader reader, final ModelNode address, final String expectedNs, final List list, final boolean requirePath) throws XMLStreamException { pathsXml.parsePaths(reader, address, expectedNs, list, requirePath); } + @Deprecated + protected void parseSystemProperties(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace namespace, + final List updates, boolean standalone) throws XMLStreamException { + parseSystemProperties(reader, address, namespace.getUriString(), updates, standalone); + } protected void parseSystemProperties(final XMLExtendedStreamReader reader, final ModelNode address, final String expectedNs, final List updates, boolean standalone) throws XMLStreamException { systemPropertiesXml.parseSystemProperties(reader, address, expectedNs, updates, standalone); } + @Deprecated + protected void parseInterfaces(final XMLExtendedStreamReader reader, final Set names, final ModelNode address, + final Namespace namespace, final List list, final boolean checkSpecified) throws XMLStreamException { + String namespaceUri = namespace.getUriString(); + String versionString = namespaceUri.substring(namespaceUri.lastIndexOf(':') + 1); + String[] versionSegments = versionString.split("."); + int[] versionInts = new int[versionSegments.length]; + for (int i = 0; i < versionSegments.length; i++) { + versionInts[i] = Integer.parseInt(versionSegments[i]); + } + IntVersion version = new IntVersion(versionInts); + + parseInterfaces(reader, names, address, version, namespace.getUriString(), list, checkSpecified); + } + protected void parseInterfaces(final XMLExtendedStreamReader reader, final Set names, final ModelNode address, final IntVersion version, final String expectedNs, final List list, final boolean checkSpecified) throws XMLStreamException { interfacesXml.parseInterfaces(reader, names, address, version, expectedNs, list, checkSpecified); @@ -188,6 +215,11 @@ protected void parseDeploymentOverlays(final XMLExtendedStreamReader reader, fin deploymentOverlaysXml.parseDeploymentOverlays(reader, namespace, baseAddress, list, allowContent, allowDeployment); } + @Deprecated + protected void parseVault(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace namespace, final List list) throws XMLStreamException { + parseVault(reader, address, namespace.getUriString(), list); + } + protected void parseVault(final XMLExtendedStreamReader reader, final ModelNode address, final String expectedNs, final List list) throws XMLStreamException { vaultXml.parseVault(reader, address, expectedNs, list); } diff --git a/server/src/main/java/org/jboss/as/server/parsing/VaultXml.java b/server/src/main/java/org/jboss/as/server/parsing/VaultXml.java index bcf30a955b0..cba71e6205f 100644 --- a/server/src/main/java/org/jboss/as/server/parsing/VaultXml.java +++ b/server/src/main/java/org/jboss/as/server/parsing/VaultXml.java @@ -16,6 +16,7 @@ import javax.xml.stream.XMLStreamException; import org.jboss.as.controller.parsing.Element; +import org.jboss.as.controller.parsing.Namespace; import org.jboss.dmr.ModelNode; import org.jboss.staxmapper.XMLExtendedStreamReader; @@ -32,6 +33,11 @@ */ class VaultXml { + @Deprecated + void parseVault(final XMLExtendedStreamReader reader, final ModelNode address, final Namespace namespace, final List list) throws XMLStreamException { + parseVault(reader, address, namespace.getUriString(), list); + } + void parseVault(final XMLExtendedStreamReader reader, final ModelNode address, final String expectedNs, final List list) throws XMLStreamException { while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { requireNamespace(reader, expectedNs);