diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/AdministeredObjectMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/AdministeredObjectMetaDataParser.java index b6fe5c888..caadaf8bb 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/AdministeredObjectMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/AdministeredObjectMetaDataParser.java @@ -23,23 +23,7 @@ public static AdministeredObjectMetaData parse(XMLStreamReader reader, PropertyR throws XMLStreamException { AdministeredObjectMetaData metaData = new AdministeredObjectMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - metaData.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, metaData); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/ConnectionFactoryMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/ConnectionFactoryMetaDataParser.java index 753adac45..c3edca4f1 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/ConnectionFactoryMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/ConnectionFactoryMetaDataParser.java @@ -24,23 +24,7 @@ public static ConnectionFactoryMetaData parse(XMLStreamReader reader, PropertyRe throws XMLStreamException { ConnectionFactoryMetaData metaData = new ConnectionFactoryMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - metaData.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, metaData); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/ContextServiceMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/ContextServiceMetaDataParser.java index 0f324c023..46ea90bc0 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/ContextServiceMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/ContextServiceMetaDataParser.java @@ -23,23 +23,7 @@ public static ContextServiceMetaData parse(XMLStreamReader reader, PropertyRepla throws XMLStreamException { ContextServiceMetaData metaData = new ContextServiceMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - metaData.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, metaData); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/DataSourceMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/DataSourceMetaDataParser.java index bc2521e65..60021fac1 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/DataSourceMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/DataSourceMetaDataParser.java @@ -23,23 +23,7 @@ public class DataSourceMetaDataParser extends MetaDataElementParser { public static DataSourceMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { DataSourceMetaData dataSource = new DataSourceMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - dataSource.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, dataSource); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/DescriptionMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/DescriptionMetaDataParser.java index 7d7edd44b..8e56c0868 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/DescriptionMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/DescriptionMetaDataParser.java @@ -20,27 +20,7 @@ public class DescriptionMetaDataParser extends MetaDataElementParser { public static DescriptionImpl parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { DescriptionImpl description = new DescriptionImpl(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if ("http://www.w3.org/XML/1998/namespace".equals(reader.getAttributeNamespace(i)) - && Attribute.forName(reader.getAttributeLocalName(i)) == Attribute.LANG) { - description.setLanguage(value); - } - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - description.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + LanguageMetaDataParser.parseAttributes(reader, description); description.setDescription(getElementText(reader, propertyReplacer)); return description; } diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/DisplayNameMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/DisplayNameMetaDataParser.java index ba41073fc..cc217e699 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/DisplayNameMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/DisplayNameMetaDataParser.java @@ -25,27 +25,7 @@ public static DisplayNameImpl parse(XMLStreamReader reader) throws XMLStreamExce public static DisplayNameImpl parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { DisplayNameImpl displayName = new DisplayNameImpl(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if ("http://www.w3.org/XML/1998/namespace".equals(reader.getAttributeNamespace(i)) - && Attribute.forName(reader.getAttributeLocalName(i)) == Attribute.LANG) { - displayName.setLanguage(value); - } - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - displayName.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + LanguageMetaDataParser.parseAttributes(reader, displayName); displayName.setDisplayName(getElementText(reader, propertyReplacer)); return displayName; } diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/EJBLocalReferenceMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/EJBLocalReferenceMetaDataParser.java index a2c3c6309..0f24e0e4a 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/EJBLocalReferenceMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/EJBLocalReferenceMetaDataParser.java @@ -27,23 +27,7 @@ public static EJBLocalReferenceMetaData parse(XMLStreamReader reader) throws XML public static EJBLocalReferenceMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { EJBLocalReferenceMetaData ejbReference = new EJBLocalReferenceMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - ejbReference.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, ejbReference); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/EJBReferenceMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/EJBReferenceMetaDataParser.java index aa8eb39b0..0d110c96d 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/EJBReferenceMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/EJBReferenceMetaDataParser.java @@ -22,23 +22,7 @@ public class EJBReferenceMetaDataParser extends MetaDataElementParser { public static EJBReferenceMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { EJBReferenceMetaData ejbReference = new EJBReferenceMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - ejbReference.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, ejbReference); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/EnvironmentEntryMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/EnvironmentEntryMetaDataParser.java index 75a7e9248..00ae01199 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/EnvironmentEntryMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/EnvironmentEntryMetaDataParser.java @@ -21,23 +21,7 @@ public class EnvironmentEntryMetaDataParser extends MetaDataElementParser { public static EnvironmentEntryMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { EnvironmentEntryMetaData environmentEntry = new EnvironmentEntryMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - environmentEntry.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, environmentEntry); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/IconMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/IconMetaDataParser.java index e05cfaa70..f445e52bd 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/IconMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/IconMetaDataParser.java @@ -25,27 +25,7 @@ public static IconImpl parse(XMLStreamReader reader) throws XMLStreamException { public static IconImpl parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { IconImpl icon = new IconImpl(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if ("http://www.w3.org/XML/1998/namespace".equals(reader.getAttributeNamespace(i)) - && Attribute.forName(reader.getAttributeLocalName(i)) == Attribute.LANG) { - icon.setLanguage(value); - } - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - icon.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + LanguageMetaDataParser.parseAttributes(reader, icon); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { final Element element = Element.forName(reader.getLocalName()); diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/IdMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/IdMetaDataParser.java new file mode 100644 index 000000000..080996e00 --- /dev/null +++ b/common/src/main/java/org/jboss/metadata/parser/ee/IdMetaDataParser.java @@ -0,0 +1,36 @@ +/* + * Copyright The JBoss Metadata Authors + * SPDX-License-Identifier: Apache-2.0 + */ +package org.jboss.metadata.parser.ee; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.jboss.metadata.javaee.support.IdMetaData; +import org.jboss.metadata.parser.util.MetaDataElementParser; + +/** + * @author Paul Ferraro + */ +public class IdMetaDataParser extends MetaDataElementParser { + + public static void parseAttributes(XMLStreamReader reader, IdMetaData metaData) throws XMLStreamException { + for (int i = 0; i < reader.getAttributeCount(); i++) { + parseAttribute(reader, i, metaData); + } + } + + public static void parseAttribute(XMLStreamReader reader, int index, IdMetaData metaData) throws XMLStreamException { + if (!attributeHasNamespace(reader, index)) { + switch (Attribute.forName(reader.getAttributeLocalName(index))) { + case ID: { + metaData.setId(reader.getAttributeValue(index)); + break; + } + default: + throw unexpectedAttribute(reader, index); + } + } + } +} diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/JMSConnectionFactoryMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/JMSConnectionFactoryMetaDataParser.java index 745938318..3ea13dea7 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/JMSConnectionFactoryMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/JMSConnectionFactoryMetaDataParser.java @@ -23,23 +23,7 @@ public static JMSConnectionFactoryMetaData parse(XMLStreamReader reader, Propert throws XMLStreamException { JMSConnectionFactoryMetaData metaData = new JMSConnectionFactoryMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - metaData.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, metaData); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/JMSDestinationMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/JMSDestinationMetaDataParser.java index 83b4c9f84..76f0aafdf 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/JMSDestinationMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/JMSDestinationMetaDataParser.java @@ -23,23 +23,7 @@ public static JMSDestinationMetaData parse(XMLStreamReader reader, PropertyRepla throws XMLStreamException { JMSDestinationMetaData metaData = new JMSDestinationMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - metaData.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, metaData); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/LanguageMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/LanguageMetaDataParser.java new file mode 100644 index 000000000..81938818c --- /dev/null +++ b/common/src/main/java/org/jboss/metadata/parser/ee/LanguageMetaDataParser.java @@ -0,0 +1,37 @@ +/* + * Copyright The JBoss Metadata Authors + * SPDX-License-Identifier: Apache-2.0 + */ +package org.jboss.metadata.parser.ee; + +import javax.xml.XMLConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.jboss.metadata.javaee.support.LanguageMetaData; +import org.jboss.metadata.parser.util.MetaDataElementParser; + +/** + * @author Paul Ferraro + */ +public class LanguageMetaDataParser extends MetaDataElementParser { + + public static void parseAttributes(XMLStreamReader reader, LanguageMetaData metaData) throws XMLStreamException { + for (int i = 0; i < reader.getAttributeCount(); i++) { + parseAttribute(reader, i, metaData); + } + } + + public static void parseAttribute(XMLStreamReader reader, int index, LanguageMetaData metaData) throws XMLStreamException { + switch (Attribute.forName(reader.getAttributeLocalName(index))) { + case LANG: { + if (XMLConstants.XML_NS_URI.equals(reader.getAttributeNamespace(index))) { + metaData.setLanguage(reader.getAttributeValue(index)); + break; + } // Otherwise, fall through + } + default: + IdMetaDataParser.parseAttribute(reader, index, metaData); + } + } +} diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/MailSessionMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/MailSessionMetaDataParser.java index b724b5021..000816983 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/MailSessionMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/MailSessionMetaDataParser.java @@ -23,23 +23,7 @@ public static MailSessionMetaData parse(XMLStreamReader reader, PropertyReplacer throws XMLStreamException { MailSessionMetaData metaData = new MailSessionMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - metaData.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, metaData); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/ManagedExecutorMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/ManagedExecutorMetaDataParser.java index cc64f2392..9a25c37e9 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/ManagedExecutorMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/ManagedExecutorMetaDataParser.java @@ -27,23 +27,7 @@ public static ManagedExecutorMetaData parse(XMLStreamReader reader, PropertyRepl public static void parse(XMLStreamReader reader, PropertyReplacer propertyReplacer, ManagedExecutorMetaData metaData) throws XMLStreamException { - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - metaData.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, metaData); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/ManagedThreadFactoryMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/ManagedThreadFactoryMetaDataParser.java index 08036c533..d1acc860d 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/ManagedThreadFactoryMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/ManagedThreadFactoryMetaDataParser.java @@ -22,23 +22,7 @@ public static ManagedThreadFactoryMetaData parse(XMLStreamReader reader, Propert throws XMLStreamException { ManagedThreadFactoryMetaData metaData = new ManagedThreadFactoryMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - metaData.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, metaData); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/MessageDestinationMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/MessageDestinationMetaDataParser.java index 8ea0b8b87..55c106c3c 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/MessageDestinationMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/MessageDestinationMetaDataParser.java @@ -21,23 +21,7 @@ public class MessageDestinationMetaDataParser extends MetaDataElementParser { public static MessageDestinationMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { MessageDestinationMetaData messageDestination = new MessageDestinationMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - messageDestination.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, messageDestination); DescriptionGroupMetaData descriptionGroup = new DescriptionGroupMetaData(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/MessageDestinationReferenceMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/MessageDestinationReferenceMetaDataParser.java index 1fba1210e..e43cd41e0 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/MessageDestinationReferenceMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/MessageDestinationReferenceMetaDataParser.java @@ -22,23 +22,7 @@ public class MessageDestinationReferenceMetaDataParser extends MetaDataElementPa public static MessageDestinationReferenceMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { MessageDestinationReferenceMetaData mdReference = new MessageDestinationReferenceMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - mdReference.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, mdReference); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/ParamValueMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/ParamValueMetaDataParser.java index 5dace37da..61dea735b 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/ParamValueMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/ParamValueMetaDataParser.java @@ -26,23 +26,7 @@ public static ParamValueMetaData parse(XMLStreamReader reader) throws XMLStreamE public static ParamValueMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { ParamValueMetaData paramValue = new ParamValueMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - paramValue.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, paramValue); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/PersistenceContextReferenceMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/PersistenceContextReferenceMetaDataParser.java index c4a2682ad..971f4237d 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/PersistenceContextReferenceMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/PersistenceContextReferenceMetaDataParser.java @@ -29,23 +29,7 @@ public static PersistenceContextReferenceMetaData parse(XMLStreamReader reader) public static PersistenceContextReferenceMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { PersistenceContextReferenceMetaData pcReference = new PersistenceContextReferenceMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - pcReference.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, pcReference); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/PersistenceUnitReferenceMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/PersistenceUnitReferenceMetaDataParser.java index 303ef6635..c4e9f6737 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/PersistenceUnitReferenceMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/PersistenceUnitReferenceMetaDataParser.java @@ -21,23 +21,7 @@ public class PersistenceUnitReferenceMetaDataParser extends MetaDataElementParse public static PersistenceUnitReferenceMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { PersistenceUnitReferenceMetaData puReference = new PersistenceUnitReferenceMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - puReference.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, puReference); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/PortComponentRefParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/PortComponentRefParser.java index 97831806f..c4fee194a 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/PortComponentRefParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/PortComponentRefParser.java @@ -24,23 +24,7 @@ public class PortComponentRefParser extends MetaDataElementParser { public static JBossPortComponentRef parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { JBossPortComponentRef portComponentRef = new JBossPortComponentRef(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - portComponentRef.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, portComponentRef); // Handle elements List stubProperties = new LinkedList(); diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/PropertyMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/PropertyMetaDataParser.java index 94d88c627..02db21917 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/PropertyMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/PropertyMetaDataParser.java @@ -20,23 +20,7 @@ public class PropertyMetaDataParser extends MetaDataElementParser { public static PropertyMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { PropertyMetaData property = new PropertyMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - property.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, property); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/ResourceEnvironmentReferenceMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/ResourceEnvironmentReferenceMetaDataParser.java index 2381297a5..8af6d5362 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/ResourceEnvironmentReferenceMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/ResourceEnvironmentReferenceMetaDataParser.java @@ -21,23 +21,7 @@ public class ResourceEnvironmentReferenceMetaDataParser extends MetaDataElementP public static ResourceEnvironmentReferenceMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { ResourceEnvironmentReferenceMetaData resourceReference = new ResourceEnvironmentReferenceMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - resourceReference.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, resourceReference); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/ResourceReferenceMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/ResourceReferenceMetaDataParser.java index 7dd72604c..7685d021d 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/ResourceReferenceMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/ResourceReferenceMetaDataParser.java @@ -23,23 +23,7 @@ public class ResourceReferenceMetaDataParser extends MetaDataElementParser { public static ResourceReferenceMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { ResourceReferenceMetaData resourceReference = new ResourceReferenceMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - resourceReference.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, resourceReference); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/RunAsMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/RunAsMetaDataParser.java index b6aa9d333..51f391bfc 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/RunAsMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/RunAsMetaDataParser.java @@ -21,23 +21,7 @@ public class RunAsMetaDataParser extends MetaDataElementParser { public static RunAsMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { RunAsMetaData runAs = new RunAsMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - runAs.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, runAs); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/SecurityRoleMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/SecurityRoleMetaDataParser.java index 83f58ede7..bbee865a7 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/SecurityRoleMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/SecurityRoleMetaDataParser.java @@ -29,23 +29,7 @@ public static SecurityRoleMetaData parse(XMLStreamReader reader) throws XMLStrea public static SecurityRoleMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { SecurityRoleMetaData securityRole = new SecurityRoleMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - securityRole.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, securityRole); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/SecurityRoleRefMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/SecurityRoleRefMetaDataParser.java index 88ff20775..35f286dce 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/SecurityRoleRefMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/SecurityRoleRefMetaDataParser.java @@ -26,23 +26,7 @@ public static SecurityRoleRefMetaData parse(XMLStreamReader reader) throws XMLSt public static SecurityRoleRefMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { SecurityRoleRefMetaData securityRoleRef = new SecurityRoleRefMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - securityRoleRef.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, securityRoleRef); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/ServiceReferenceHandlerChainMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/ServiceReferenceHandlerChainMetaDataParser.java index 36fc6590b..25cacc62f 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/ServiceReferenceHandlerChainMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/ServiceReferenceHandlerChainMetaDataParser.java @@ -24,23 +24,7 @@ public class ServiceReferenceHandlerChainMetaDataParser extends MetaDataElementP public static ServiceReferenceHandlerChainMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { ServiceReferenceHandlerChainMetaData handlerChain = new ServiceReferenceHandlerChainMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - handlerChain.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, handlerChain); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/ServiceReferenceHandlerMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/ServiceReferenceHandlerMetaDataParser.java index f73e266ac..81b695af1 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/ServiceReferenceHandlerMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/ServiceReferenceHandlerMetaDataParser.java @@ -26,23 +26,7 @@ public class ServiceReferenceHandlerMetaDataParser extends MetaDataElementParser public static ServiceReferenceHandlerMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { ServiceReferenceHandlerMetaData handler = new ServiceReferenceHandlerMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - handler.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, handler); DescriptionGroupMetaData descriptionGroup = new DescriptionGroupMetaData(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/ee/ServiceReferenceMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/ee/ServiceReferenceMetaDataParser.java index 1d6bba95e..01af02747 100644 --- a/common/src/main/java/org/jboss/metadata/parser/ee/ServiceReferenceMetaDataParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/ee/ServiceReferenceMetaDataParser.java @@ -29,23 +29,7 @@ public class ServiceReferenceMetaDataParser extends MetaDataElementParser { public static ServiceReferenceMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { JBossServiceReferenceMetaData serviceReference = new JBossServiceReferenceMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - serviceReference.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, serviceReference); DescriptionGroupMetaData descriptionGroup = new DescriptionGroupMetaData(); // Handle elements diff --git a/common/src/main/java/org/jboss/metadata/parser/util/MetaDataElementParser.java b/common/src/main/java/org/jboss/metadata/parser/util/MetaDataElementParser.java index 9631c7195..4b257e468 100644 --- a/common/src/main/java/org/jboss/metadata/parser/util/MetaDataElementParser.java +++ b/common/src/main/java/org/jboss/metadata/parser/util/MetaDataElementParser.java @@ -14,6 +14,7 @@ import java.util.SortedMap; import java.util.TreeMap; +import javax.xml.XMLConstants; import javax.xml.namespace.QName; import javax.xml.stream.XMLResolver; import javax.xml.stream.XMLStreamConstants; @@ -357,7 +358,8 @@ protected static QName parseQName(final XMLStreamReader reader, final String qna } protected static boolean attributeHasNamespace(final XMLStreamReader reader, final int i) { - return !(reader.getAttributeNamespace(i) == null || "".equals(reader.getAttributeNamespace(i))); + String namespace = reader.getAttributeNamespace(i); + return !(namespace == null || XMLConstants.NULL_NS_URI.equals(namespace)); } /** diff --git a/common/src/main/java/org/jboss/metadata/parser/util/Version.java b/common/src/main/java/org/jboss/metadata/parser/util/Version.java new file mode 100644 index 000000000..c76f084a0 --- /dev/null +++ b/common/src/main/java/org/jboss/metadata/parser/util/Version.java @@ -0,0 +1,30 @@ +/* + * Copyright The JBoss Metadata Authors + * SPDX-License-Identifier: Apache-2.0 + */ +package org.jboss.metadata.parser.util; + +/** + * Encapsulates the version of some metadata. + * @author Paul Ferraro + */ +public interface Version> extends Comparable { + + /** + * Returns the major component of this version. + * @return the major component of this version. + */ + int major(); + + /** + * Returns the minor component of this version. + * @return the manor component of this version. + */ + int minor(); + + @Override + default int compareTo(V version) { + int result = Integer.compare(this.major(), this.minor()); + return (result == 0) ? Integer.compare(this.minor(), version.minor()) : result; + } +} diff --git a/common/src/main/java/org/jboss/metadata/parser/util/Versioned.java b/common/src/main/java/org/jboss/metadata/parser/util/Versioned.java new file mode 100644 index 000000000..2140f607a --- /dev/null +++ b/common/src/main/java/org/jboss/metadata/parser/util/Versioned.java @@ -0,0 +1,23 @@ +/* + * Copyright The JBoss Metadata Authors + * SPDX-License-Identifier: Apache-2.0 + */ +package org.jboss.metadata.parser.util; + +/** + * A versioned object. + * @author Paul Ferraro + */ +public interface Versioned> { + + V getVersion(); + + /** + * Indicates whether this version is at least as recent as the specified version. + * @param version a version + * @return true, if this version is at least as recent as the specified version, false otherwise. + */ + default boolean since(V version) { + return this.getVersion().compareTo(version) >= 0; + } +} diff --git a/common/src/main/java/org/jboss/metadata/parser/util/VersionedMetaDataParser.java b/common/src/main/java/org/jboss/metadata/parser/util/VersionedMetaDataParser.java new file mode 100644 index 000000000..444676a34 --- /dev/null +++ b/common/src/main/java/org/jboss/metadata/parser/util/VersionedMetaDataParser.java @@ -0,0 +1,28 @@ +/* + * Copyright The JBoss Metadata Authors + * SPDX-License-Identifier: Apache-2.0 + */ +package org.jboss.metadata.parser.util; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.jboss.metadata.property.PropertyReplacer; + +/** + * A versioned meta data parser. + * @author Paul Ferraro + * @param the meta data type + * @param the version type + */ +public interface VersionedMetaDataParser> extends Versioned { + + /** + * Parses metadata from the specified reader using the specified property replacer. + * @param reader an xml reader + * @param replacer a property replacer + * @return a parsed meta data instance + * @throws XMLStreamException if the metadata could not be parsed + */ + M parse(XMLStreamReader reader, PropertyReplacer replacer) throws XMLStreamException; +} diff --git a/web/src/main/java/org/jboss/metadata/merge/web/spec/CookieConfigMetaDataMerger.java b/web/src/main/java/org/jboss/metadata/merge/web/spec/CookieConfigMetaDataMerger.java index 1d69391f4..71ca1de5b 100644 --- a/web/src/main/java/org/jboss/metadata/merge/web/spec/CookieConfigMetaDataMerger.java +++ b/web/src/main/java/org/jboss/metadata/merge/web/spec/CookieConfigMetaDataMerger.java @@ -4,7 +4,10 @@ */ package org.jboss.metadata.merge.web.spec; +import java.util.List; + import org.jboss.metadata.merge.javaee.support.IdMetaDataImplMerger; +import org.jboss.metadata.web.spec.AttributeValueMetaData; import org.jboss.metadata.web.spec.CookieConfigMetaData; /** @@ -82,6 +85,14 @@ public static void augment(CookieConfigMetaData dest, CookieConfigMetaData webFr throw new IllegalStateException("Unresolved conflict on max age"); } } + List fragmentAttributes = webFragmentMetaData.getAttributes(); + if (fragmentAttributes != null) { + List destinationAttributes = dest.getAttributes(); + if (destinationAttributes == null) { + dest.setAttributes(fragmentAttributes); + } else if (!resolveConflicts && !destinationAttributes.equals(fragmentAttributes) && (webMetaData == null || webMetaData.getAttributes() == null)) { + throw new IllegalStateException("Unresolved conflict on cookie attributes: " + destinationAttributes); + } + } } - } diff --git a/web/src/main/java/org/jboss/metadata/parser/jbossweb/JBossWebMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/jbossweb/JBossWebMetaDataParser.java index 5a877b9d7..830eb41e6 100644 --- a/web/src/main/java/org/jboss/metadata/parser/jbossweb/JBossWebMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/jbossweb/JBossWebMetaDataParser.java @@ -47,7 +47,7 @@ public static JBossWebMetaData parse(XMLStreamReader reader, PropertyReplacer pr if (reader.getEventType() == DTD) { String dtdLocation = readDTDLocation(reader); if (dtdLocation != null) { - version = Version.findVersion(dtdLocation); + version = Version.fromLocation(dtdLocation); } if (version == null) { // DTD->getText() is incomplete and not parsable with Xerces from Sun JDK 6, @@ -58,7 +58,7 @@ public static JBossWebMetaData parse(XMLStreamReader reader, PropertyReplacer pr } String schemaLocation = readSchemaLocation(reader); if (schemaLocation != null) { - version = Version.findVersion(schemaLocation); + version = Version.fromLocation(schemaLocation); } if (version == null) { version = Version.JBOSS_WEB_6_0; @@ -126,7 +126,7 @@ public static JBossWebMetaData parse(XMLStreamReader reader, PropertyReplacer pr listeners.add(ContainerListenerMetaDataParser.parse(reader, propertyReplacer)); break; case SESSION_CONFIG: - wmd.setSessionConfig(SessionConfigMetaDataParser.parse(reader, propertyReplacer)); + wmd.setSessionConfig(new SessionConfigMetaDataParser(version.getServletVersion()).parse(reader, propertyReplacer)); break; case VALVE: List valves = wmd.getValves(); diff --git a/web/src/main/java/org/jboss/metadata/parser/jbossweb/Location.java b/web/src/main/java/org/jboss/metadata/parser/jbossweb/Location.java index 5f41f1bba..139c19015 100644 --- a/web/src/main/java/org/jboss/metadata/parser/jbossweb/Location.java +++ b/web/src/main/java/org/jboss/metadata/parser/jbossweb/Location.java @@ -12,6 +12,6 @@ public class Location { */ @Deprecated public static Version getVersion(String location) { - return Version.findVersion(location); + return Version.fromLocation(location); } } diff --git a/web/src/main/java/org/jboss/metadata/parser/jbossweb/Version.java b/web/src/main/java/org/jboss/metadata/parser/jbossweb/Version.java index ec8b540aa..2d2319549 100644 --- a/web/src/main/java/org/jboss/metadata/parser/jbossweb/Version.java +++ b/web/src/main/java/org/jboss/metadata/parser/jbossweb/Version.java @@ -6,48 +6,87 @@ package org.jboss.metadata.parser.jbossweb; import java.util.EnumSet; -import java.util.HashMap; import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; -public enum Version { - JBOSS_WEB_3_0("http://www.jboss.org/j2ee/dtd/jboss-web_3_0.dtd"), - JBOSS_WEB_3_2("http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd"), - JBOSS_WEB_4_0("http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd"), - JBOSS_WEB_4_2("http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd"), - JBOSS_WEB_5_0("http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd"), - JBOSS_WEB_5_1(5, 1), - JBOSS_WEB_6_0(6, 0), - JBOSS_WEB_7_0(7, 0), - JBOSS_WEB_7_1(7, 1), - JBOSS_WEB_7_2(7, 2), - JBOSS_WEB_8_0(8, 0), - JBOSS_WEB_10_0(10, 0), - JBOSS_WEB_11_0(11, 0), - JBOSS_WEB_12_0(12, 0), - JBOSS_WEB_12_1(12, 1), - JBOSS_WEB_13_0(13, 0), - JBOSS_WEB_14_0(14, 0), - JBOSS_WEB_14_1(14, 1), - JBOSS_WEB_15_0(15, 0), +public enum Version implements org.jboss.metadata.parser.util.Version { + JBOSS_WEB_3_0(org.jboss.metadata.parser.servlet.Version.SERVLET_3_0, 3, 0, "http://www.jboss.org/j2ee/dtd/jboss-web_%d_%d.dtd"), + JBOSS_WEB_3_2(org.jboss.metadata.parser.servlet.Version.SERVLET_3_0, 3, 2, "http://www.jboss.org/j2ee/dtd/jboss-web_%d_%d.dtd"), + JBOSS_WEB_4_0(org.jboss.metadata.parser.servlet.Version.SERVLET_3_0, 4, 0, "http://www.jboss.org/j2ee/dtd/jboss-web_%d_%d.dtd"), + JBOSS_WEB_4_2(org.jboss.metadata.parser.servlet.Version.SERVLET_3_0, 4, 2, "http://www.jboss.org/j2ee/dtd/jboss-web_%d_%d.dtd"), + JBOSS_WEB_5_0(org.jboss.metadata.parser.servlet.Version.SERVLET_3_0, 5, 0, "http://www.jboss.org/j2ee/dtd/jboss-web_%d_%d.dtd"), + JBOSS_WEB_5_1(org.jboss.metadata.parser.servlet.Version.SERVLET_3_0, 5, 1), + JBOSS_WEB_6_0(org.jboss.metadata.parser.servlet.Version.SERVLET_3_0, 6, 0), + JBOSS_WEB_7_0(org.jboss.metadata.parser.servlet.Version.SERVLET_3_0, 7, 0), + JBOSS_WEB_7_1(org.jboss.metadata.parser.servlet.Version.SERVLET_3_0, 7, 1), + JBOSS_WEB_7_2(org.jboss.metadata.parser.servlet.Version.SERVLET_3_0, 7, 2), + JBOSS_WEB_8_0(org.jboss.metadata.parser.servlet.Version.SERVLET_3_1, 8, 0), + JBOSS_WEB_10_0(org.jboss.metadata.parser.servlet.Version.SERVLET_3_1, 10, 0), + JBOSS_WEB_11_0(org.jboss.metadata.parser.servlet.Version.SERVLET_3_1, 11, 0), + JBOSS_WEB_12_0(org.jboss.metadata.parser.servlet.Version.SERVLET_3_1, 12, 0), + JBOSS_WEB_12_1(org.jboss.metadata.parser.servlet.Version.SERVLET_3_1, 12, 1), + JBOSS_WEB_13_0(org.jboss.metadata.parser.servlet.Version.SERVLET_4_0, 13, 0), + JBOSS_WEB_14_0(org.jboss.metadata.parser.servlet.Version.SERVLET_4_0, 14, 0), + JBOSS_WEB_14_1(org.jboss.metadata.parser.servlet.Version.SERVLET_4_0, 14, 1), + JBOSS_WEB_15_0(org.jboss.metadata.parser.servlet.Version.SERVLET_6_0, 15, 0), ; + // The corresponding servlet version + private final org.jboss.metadata.parser.servlet.Version servletVersion; + private final int major; + private final int minor; private final String location; - Version(int major, int minor) { - this(String.format("https://www.jboss.org/j2ee/schema/jboss-web_%d_%d.xsd", major, minor)); + Version(org.jboss.metadata.parser.servlet.Version version, int major, int minor) { + this(version, major, minor, "https://www.jboss.org/j2ee/schema/jboss-web_%d_%d.xsd"); } - Version(String location) { - this.location = location; + Version(org.jboss.metadata.parser.servlet.Version servletVersion, int major, int minor, String locationPattern) { + this.servletVersion = servletVersion; + this.major = major; + this.minor = minor; + this.location = String.format(locationPattern, major, minor); } - private static final Map versions = new HashMap<>(); - static { - for (Version version : EnumSet.allOf(Version.class)) { - versions.put(version.location, version); - } + public org.jboss.metadata.parser.servlet.Version getServletVersion() { + return this.servletVersion; } - public static Version findVersion(String location) { - return versions.get(location); + @Override + public int major() { + return this.major; + } + + @Override + public int minor() { + return this.minor; + } + + String getLocation() { + return this.location; + } + + /** + * @deprecated Use {@link #toString()} instead. + */ + @Deprecated(forRemoval = true) + public String versionString() { + return this.toString(); + } + + @Override + public String toString() { + return this.major + "." + this.minor; + } + + private static final Map VERSIONS = EnumSet.allOf(Version.class).stream().collect(Collectors.toMap(Version::toString, Function.identity())); + private static final Map LOCATIONS = EnumSet.allOf(Version.class).stream().collect(Collectors.toMap(Version::getLocation, Function.identity())); + + public static Version fromLocation(String location) { + return LOCATIONS.get(location); + } + + public static Version fromString(String version) { + return VERSIONS.get(version); } } diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/AbstractVersionedMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/AbstractVersionedMetaDataParser.java new file mode 100644 index 000000000..3e25c062e --- /dev/null +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/AbstractVersionedMetaDataParser.java @@ -0,0 +1,26 @@ +/* + * Copyright The JBoss Metadata Authors + * SPDX-License-Identifier: Apache-2.0 + */ +package org.jboss.metadata.parser.servlet; + +import org.jboss.metadata.parser.util.MetaDataElementParser; +import org.jboss.metadata.parser.util.VersionedMetaDataParser; + +/** + * Abstract meta data parser. + * @author Paul Ferraro + */ +public abstract class AbstractVersionedMetaDataParser extends MetaDataElementParser implements VersionedMetaDataParser { + + private final Version version; + + AbstractVersionedMetaDataParser(Version version) { + this.version = version; + } + + @Override + public Version getVersion() { + return this.version; + } +} diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/AuthConstraintMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/AuthConstraintMetaDataParser.java index a1f7d6673..30ea366b7 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/AuthConstraintMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/AuthConstraintMetaDataParser.java @@ -13,6 +13,7 @@ import org.jboss.metadata.javaee.spec.DescriptionsImpl; import org.jboss.metadata.parser.ee.DescriptionsMetaDataParser; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.AuthConstraintMetaData; @@ -25,23 +26,7 @@ public class AuthConstraintMetaDataParser extends MetaDataElementParser { public static AuthConstraintMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { AuthConstraintMetaData authConstraint = new AuthConstraintMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - authConstraint.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, authConstraint); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/CookieConfigMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/CookieConfigMetaDataParser.java index b12126f73..a21da383f 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/CookieConfigMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/CookieConfigMetaDataParser.java @@ -5,38 +5,33 @@ package org.jboss.metadata.parser.servlet; +import java.util.LinkedList; +import java.util.List; + import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; -import org.jboss.metadata.parser.util.MetaDataElementParser; +import org.jboss.metadata.javaee.spec.DescriptionsImpl; +import org.jboss.metadata.parser.ee.DescriptionsMetaDataParser; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.property.PropertyReplacer; +import org.jboss.metadata.web.spec.AttributeValueMetaData; import org.jboss.metadata.web.spec.CookieConfigMetaData; /** * @author Remy Maucherat */ -public class CookieConfigMetaDataParser extends MetaDataElementParser { +public class CookieConfigMetaDataParser extends AbstractVersionedMetaDataParser { + + CookieConfigMetaDataParser(Version version) { + super(version); + } - public static CookieConfigMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { + @Override + public CookieConfigMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { CookieConfigMetaData cookieConfig = new CookieConfigMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - cookieConfig.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, cookieConfig); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { @@ -75,6 +70,16 @@ public static CookieConfigMetaData parse(XMLStreamReader reader, PropertyReplace throw unexpectedValue(reader, e); } break; + case ATTRIBUTE: + if (this.since(Version.SERVLET_6_0)) { + List attributes = cookieConfig.getAttributes(); + if (attributes == null) { + attributes = new LinkedList<>(); + cookieConfig.setAttributes(attributes); + } + attributes.add(this.parseAttribute(reader, propertyReplacer)); + break; + } // else fall through default: throw unexpectedElement(reader); } @@ -83,4 +88,31 @@ public static CookieConfigMetaData parse(XMLStreamReader reader, PropertyReplace return cookieConfig; } + private static final String ATTRIBUTE_NAME = "attribute-name"; + private static final String ATTRIBUTE_VALUE = "attribute-value"; + + protected AttributeValueMetaData parseAttribute(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { + AttributeValueMetaData metaData = new AttributeValueMetaData(); + + IdMetaDataParser.parseAttributes(reader, metaData); + + DescriptionsImpl descriptions = new DescriptionsImpl(); + while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { + switch (reader.getLocalName()) { + case ATTRIBUTE_NAME: + metaData.setAttributeName(getElementText(reader, propertyReplacer)); + break; + case ATTRIBUTE_VALUE: + metaData.setAttributeValue(getElementText(reader, propertyReplacer)); + break; + default: + if (DescriptionsMetaDataParser.parse(reader, descriptions, propertyReplacer)) { + metaData.setDescriptions(descriptions); + } else { + throw unexpectedElement(reader); + } + } + } + return metaData; + } } diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/Element.java b/web/src/main/java/org/jboss/metadata/parser/servlet/Element.java index c5d9c362a..92892363d 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/Element.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/Element.java @@ -21,6 +21,7 @@ public enum Element { ABSOLUTE_ORDERING("absolute-ordering"), AFTER("after"), ASYNC_SUPPORTED("async-supported"), + ATTRIBUTE("attribute"), AUTH_CONSTRAINT("auth-constraint"), AUTH_METHOD("auth-method"), diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/ErrorPageMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/ErrorPageMetaDataParser.java index b62cbaf31..e364655b9 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/ErrorPageMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/ErrorPageMetaDataParser.java @@ -8,6 +8,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.ErrorPageMetaData; @@ -20,23 +21,7 @@ public class ErrorPageMetaDataParser extends MetaDataElementParser { public static ErrorPageMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { ErrorPageMetaData errorPage = new ErrorPageMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - errorPage.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, errorPage); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/FilterMappingMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/FilterMappingMetaDataParser.java index 93ad30d3f..9e093bb8b 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/FilterMappingMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/FilterMappingMetaDataParser.java @@ -11,6 +11,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.DispatcherType; @@ -24,23 +25,7 @@ public class FilterMappingMetaDataParser extends MetaDataElementParser { public static FilterMappingMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { FilterMappingMetaData filterMapping = new FilterMappingMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - filterMapping.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, filterMapping); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/FilterMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/FilterMetaDataParser.java index 6ad283feb..e882655de 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/FilterMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/FilterMetaDataParser.java @@ -14,6 +14,7 @@ import org.jboss.metadata.javaee.spec.DescriptionGroupMetaData; import org.jboss.metadata.javaee.spec.ParamValueMetaData; import org.jboss.metadata.parser.ee.DescriptionGroupMetaDataParser; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.ee.ParamValueMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; @@ -27,23 +28,7 @@ public class FilterMetaDataParser extends MetaDataElementParser { public static FilterMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { FilterMetaData filter = new FilterMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - filter.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, filter); DescriptionGroupMetaData descriptionGroup = new DescriptionGroupMetaData(); // Handle elements diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/FormLoginConfigMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/FormLoginConfigMetaDataParser.java index 671bb8867..ebc3906cb 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/FormLoginConfigMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/FormLoginConfigMetaDataParser.java @@ -8,6 +8,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.FormLoginConfigMetaData; @@ -20,23 +21,7 @@ public class FormLoginConfigMetaDataParser extends MetaDataElementParser { public static FormLoginConfigMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { FormLoginConfigMetaData formLoginConfig = new FormLoginConfigMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - formLoginConfig.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, formLoginConfig); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/JspConfigMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/JspConfigMetaDataParser.java index 8d29f1ae7..d89e8c699 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/JspConfigMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/JspConfigMetaDataParser.java @@ -11,6 +11,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.JspConfigMetaData; @@ -25,23 +26,7 @@ public class JspConfigMetaDataParser extends MetaDataElementParser { public static JspConfigMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { JspConfigMetaData jspConfig = new JspConfigMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - jspConfig.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, jspConfig); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/JspPropertyGroupMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/JspPropertyGroupMetaDataParser.java index 912f62575..c468e7123 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/JspPropertyGroupMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/JspPropertyGroupMetaDataParser.java @@ -13,6 +13,7 @@ import org.jboss.metadata.javaee.spec.DescriptionGroupMetaData; import org.jboss.metadata.parser.ee.DescriptionGroupMetaDataParser; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.JspPropertyGroupMetaData; @@ -25,23 +26,7 @@ public class JspPropertyGroupMetaDataParser extends MetaDataElementParser { public static JspPropertyGroupMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { JspPropertyGroupMetaData jspPropertyGroup = new JspPropertyGroupMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - jspPropertyGroup.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, jspPropertyGroup); DescriptionGroupMetaData descriptionGroup = new DescriptionGroupMetaData(); // Handle elements diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/ListenerMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/ListenerMetaDataParser.java index 5f64c8711..b611ccda4 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/ListenerMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/ListenerMetaDataParser.java @@ -10,6 +10,7 @@ import org.jboss.metadata.javaee.spec.DescriptionGroupMetaData; import org.jboss.metadata.parser.ee.DescriptionGroupMetaDataParser; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.ListenerMetaData; @@ -22,23 +23,7 @@ public class ListenerMetaDataParser extends MetaDataElementParser { public static ListenerMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { ListenerMetaData listener = new ListenerMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - listener.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, listener); DescriptionGroupMetaData descriptionGroup = new DescriptionGroupMetaData(); // Handle elements diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/LocaleEncodingMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/LocaleEncodingMetaDataParser.java index 9eab85af1..f6d45fb8d 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/LocaleEncodingMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/LocaleEncodingMetaDataParser.java @@ -8,6 +8,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.LocaleEncodingMetaData; @@ -20,23 +21,7 @@ public class LocaleEncodingMetaDataParser extends MetaDataElementParser { public static LocaleEncodingMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { LocaleEncodingMetaData localeEncoding = new LocaleEncodingMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - localeEncoding.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, localeEncoding); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/LocaleEncodingsMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/LocaleEncodingsMetaDataParser.java index d07e53d9d..ce61618e7 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/LocaleEncodingsMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/LocaleEncodingsMetaDataParser.java @@ -11,6 +11,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.LocaleEncodingMetaData; @@ -24,23 +25,7 @@ public class LocaleEncodingsMetaDataParser extends MetaDataElementParser { public static LocaleEncodingsMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { LocaleEncodingsMetaData localeEncodings = new LocaleEncodingsMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - localeEncodings.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, localeEncodings); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/LoginConfigMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/LoginConfigMetaDataParser.java index 4dde467e4..babd67447 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/LoginConfigMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/LoginConfigMetaDataParser.java @@ -8,6 +8,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.LoginConfigMetaData; @@ -20,23 +21,7 @@ public class LoginConfigMetaDataParser extends MetaDataElementParser { public static LoginConfigMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { LoginConfigMetaData loginConfig = new LoginConfigMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - loginConfig.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, loginConfig); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/MimeMappingMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/MimeMappingMetaDataParser.java index 2640e3673..61a8e3664 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/MimeMappingMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/MimeMappingMetaDataParser.java @@ -8,6 +8,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.MimeMappingMetaData; @@ -20,23 +21,7 @@ public class MimeMappingMetaDataParser extends MetaDataElementParser { public static MimeMappingMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { MimeMappingMetaData mimeMapping = new MimeMappingMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - mimeMapping.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, mimeMapping); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/MultipartConfigMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/MultipartConfigMetaDataParser.java index b9e7011f4..4f9ba2e59 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/MultipartConfigMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/MultipartConfigMetaDataParser.java @@ -8,6 +8,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.MultipartConfigMetaData; @@ -20,23 +21,7 @@ public class MultipartConfigMetaDataParser extends MetaDataElementParser { public static MultipartConfigMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { MultipartConfigMetaData multipartConfig = new MultipartConfigMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - multipartConfig.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, multipartConfig); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/SecurityConstraintMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/SecurityConstraintMetaDataParser.java index 308d394ee..7fc00f547 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/SecurityConstraintMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/SecurityConstraintMetaDataParser.java @@ -8,6 +8,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.SecurityConstraintMetaData; @@ -21,23 +22,7 @@ public class SecurityConstraintMetaDataParser extends MetaDataElementParser { public static SecurityConstraintMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { SecurityConstraintMetaData securityConstraint = new SecurityConstraintMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - securityConstraint.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, securityConstraint); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/ServletMappingMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/ServletMappingMetaDataParser.java index e1ecfad97..eb58b8414 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/ServletMappingMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/ServletMappingMetaDataParser.java @@ -11,6 +11,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.ServletMappingMetaData; @@ -23,23 +24,7 @@ public class ServletMappingMetaDataParser extends MetaDataElementParser { public static ServletMappingMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { ServletMappingMetaData servletMapping = new ServletMappingMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - servletMapping.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, servletMapping); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/ServletMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/ServletMetaDataParser.java index 4503992d4..9cc06d98f 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/ServletMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/ServletMetaDataParser.java @@ -15,6 +15,7 @@ import org.jboss.metadata.javaee.spec.ParamValueMetaData; import org.jboss.metadata.javaee.spec.SecurityRoleRefsMetaData; import org.jboss.metadata.parser.ee.DescriptionGroupMetaDataParser; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.ee.ParamValueMetaDataParser; import org.jboss.metadata.parser.ee.RunAsMetaDataParser; import org.jboss.metadata.parser.ee.SecurityRoleRefMetaDataParser; @@ -30,23 +31,7 @@ public class ServletMetaDataParser extends MetaDataElementParser { public static ServletMetaData parse(XMLStreamReader reader, final PropertyReplacer propertyReplacer) throws XMLStreamException { ServletMetaData servlet = new ServletMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - servlet.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, servlet); DescriptionGroupMetaData descriptionGroup = new DescriptionGroupMetaData(); // Handle elements diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/SessionConfigMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/SessionConfigMetaDataParser.java index d11a57fc1..07cfefb03 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/SessionConfigMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/SessionConfigMetaDataParser.java @@ -5,13 +5,13 @@ package org.jboss.metadata.parser.servlet; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; -import org.jboss.metadata.parser.util.MetaDataElementParser; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.SessionConfigMetaData; import org.jboss.metadata.web.spec.SessionTrackingModeType; @@ -19,28 +19,17 @@ /** * @author Remy Maucherat */ -public class SessionConfigMetaDataParser extends MetaDataElementParser { +public class SessionConfigMetaDataParser extends AbstractVersionedMetaDataParser { - public static SessionConfigMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { + public SessionConfigMetaDataParser(Version version) { + super(version); + } + + @Override + public SessionConfigMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { SessionConfigMetaData sessionConfig = new SessionConfigMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - sessionConfig.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, sessionConfig); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { @@ -54,12 +43,12 @@ public static SessionConfigMetaData parse(XMLStreamReader reader, PropertyReplac } break; case COOKIE_CONFIG: - sessionConfig.setCookieConfig(CookieConfigMetaDataParser.parse(reader, propertyReplacer)); + sessionConfig.setCookieConfig(new CookieConfigMetaDataParser(this.getVersion()).parse(reader, propertyReplacer)); break; case TRACKING_MODE: List trackingModes = sessionConfig.getSessionTrackingModes(); if (trackingModes == null) { - trackingModes = new ArrayList(); + trackingModes = new LinkedList<>(); sessionConfig.setSessionTrackingModes(trackingModes); } try { @@ -75,5 +64,4 @@ public static SessionConfigMetaData parse(XMLStreamReader reader, PropertyReplac return sessionConfig; } - } diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/TaglibMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/TaglibMetaDataParser.java index 7ec63236c..d2316c1c4 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/TaglibMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/TaglibMetaDataParser.java @@ -8,6 +8,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.TaglibMetaData; @@ -20,23 +21,7 @@ public class TaglibMetaDataParser extends MetaDataElementParser { public static TaglibMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { TaglibMetaData taglib = new TaglibMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - taglib.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, taglib); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/UserDataConstraintMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/UserDataConstraintMetaDataParser.java index 128f0c4b1..6b3c5c5b9 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/UserDataConstraintMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/UserDataConstraintMetaDataParser.java @@ -10,6 +10,7 @@ import org.jboss.metadata.javaee.spec.DescriptionsImpl; import org.jboss.metadata.parser.ee.DescriptionsMetaDataParser; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.TransportGuaranteeType; @@ -23,23 +24,7 @@ public class UserDataConstraintMetaDataParser extends MetaDataElementParser { public static UserDataConstraintMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { UserDataConstraintMetaData userDataConstraint = new UserDataConstraintMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - userDataConstraint.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, userDataConstraint); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/Version.java b/web/src/main/java/org/jboss/metadata/parser/servlet/Version.java index 99c8ca52b..51d0aeab6 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/Version.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/Version.java @@ -5,48 +5,80 @@ package org.jboss.metadata.parser.servlet; -import java.util.HashMap; +import java.util.EnumSet; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; -public enum Version { +public enum Version implements org.jboss.metadata.parser.util.Version { - SERVLET_2_2("2.2"), SERVLET_2_3("2.3"), SERVLET_2_4("2.4"), SERVLET_2_5("2.5"), SERVLET_3_0("3.0"), SERVLET_3_1("3.1"), SERVLET_4_0("4.0"), SERVLET_5_0("5.0"), SERVLET_6_0("6.0"); + SERVLET_2_2(2, 2, "http://java.sun.com/j2ee/dtds/web-app_%d_%d.dtd"), + SERVLET_2_3(2, 3, "http://java.sun.com/dtd/web-app_%d_%d.dtd"), + SERVLET_2_4(2, 4, "http://java.sun.com/xml/ns/j2ee/web-app_%d_%d.xsd"), + SERVLET_2_5(2, 5, "http://java.sun.com/xml/ns/javaee/web-app_%d_%d.xsd"), + SERVLET_3_0(3, 0, "http://java.sun.com/xml/ns/javaee/web-app_%d_%d.xsd"), + SERVLET_3_1(3, 1, "http://xmlns.jcp.org/xml/ns/javaee/web-app_%d_%d.xsd"), + SERVLET_4_0(4, 0, "http://xmlns.jcp.org/xml/ns/javaee/web-app_%d_%d.xsd"), + SERVLET_5_0(5, 0), + SERVLET_6_0(6, 0), + ; + public static final Version LATEST = Version.SERVLET_6_0; + private static final Map VERSIONS = EnumSet.allOf(Version.class).stream().collect(Collectors.toMap(Version::toString, Function.identity())); + private static final Map SYSTEM_IDS = EnumSet.allOf(Version.class).stream().collect(Collectors.toMap(Version::getSystemId, Function.identity())); - private static final HashMap systemIDmap = new HashMap(); + private static final Map PUBLIC_IDS = EnumSet.of(Version.SERVLET_2_2, Version.SERVLET_2_3).stream() + .collect(Collectors.toMap(version -> String.format("-//Sun Microsystems, Inc.//DTD Web Application %d.%d//EN", version.major(), version.minor()), Function.identity())); - static { - systemIDmap.put("http://java.sun.com/j2ee/dtds/web-app_2_2.dtd", Version.SERVLET_2_2); - systemIDmap.put("http://java.sun.com/dtd/web-app_2_3.dtd", Version.SERVLET_2_3); - systemIDmap.put("http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd", Version.SERVLET_2_4); - systemIDmap.put("http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd", Version.SERVLET_2_5); - systemIDmap.put("http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd", Version.SERVLET_3_0); - systemIDmap.put("http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd", Version.SERVLET_3_1); - systemIDmap.put("http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd", Version.SERVLET_4_0); - systemIDmap.put("https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd", Version.SERVLET_5_0); - systemIDmap.put("https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd", Version.SERVLET_6_0); - } + private final int major; + private final int minor; + private final String systemId; - private static final HashMap publicIDmap = new HashMap(); + Version(int major, int minor) { + this(major, minor, "https://jakarta.ee/xml/ns/jakartaee/web-app_%d_%d.xsd"); + } - static { - publicIDmap.put("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN", Version.SERVLET_2_2); - publicIDmap.put("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN", Version.SERVLET_2_3); + Version(int major, int minor, String systemIdFormat) { + this.major = major; + this.minor = minor; + this.systemId = String.format(systemIdFormat, major, minor); } - Version(String version) { - this.version = version; + @Override + public int major() { + return this.major; } - public static Version fromSystemID(String systemID) { - return systemIDmap.get(systemID); + @Override + public int minor() { + return this.minor; } - public static Version fromPublicID(String publicID) { - return publicIDmap.get(publicID); + @Override + public String toString() { + return this.major + "." + this.minor; } - private final String version; + public String getSystemId() { + return this.systemId; + } + /** + * @deprecated Use {@link #toString()} instead. + */ + @Deprecated(forRemoval = true) public String versionString() { - return version; + return this.toString(); + } + + public static Version fromString(String version) { + return VERSIONS.get(version); + } + + public static Version fromSystemID(String systemID) { + return SYSTEM_IDS.get(systemID); + } + + public static Version fromPublicID(String publicID) { + return PUBLIC_IDS.get(publicID); } } diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/WebCommonMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/WebCommonMetaDataParser.java index 02e10abdb..26e2f6340 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/WebCommonMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/WebCommonMetaDataParser.java @@ -36,7 +36,7 @@ */ public class WebCommonMetaDataParser extends MetaDataElementParser { - public static boolean parse(XMLStreamReader reader, WebCommonMetaData wmd, PropertyReplacer propertyReplacer) throws XMLStreamException { + public static boolean parse(XMLStreamReader reader, Version version, WebCommonMetaData wmd, PropertyReplacer propertyReplacer) throws XMLStreamException { // Only look at the current element, no iteration final Element element = Element.forName(reader.getLocalName()); switch (element) { @@ -95,7 +95,7 @@ public static boolean parse(XMLStreamReader reader, WebCommonMetaData wmd, Prope case SESSION_CONFIG: if (wmd.getSessionConfig() != null) throw new XMLStreamException("Multiple session-config elements detected", reader.getLocation()); - wmd.setSessionConfig(SessionConfigMetaDataParser.parse(reader, propertyReplacer)); + wmd.setSessionConfig(new SessionConfigMetaDataParser(version).parse(reader, propertyReplacer)); break; case MIME_MAPPING: List mimeMappings = wmd.getMimeMappings(); diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/WebFragmentMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/WebFragmentMetaDataParser.java index 075ece1ec..91c69f3af 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/WebFragmentMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/WebFragmentMetaDataParser.java @@ -5,6 +5,8 @@ package org.jboss.metadata.parser.servlet; +import java.util.Optional; + import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; @@ -12,6 +14,7 @@ import org.jboss.metadata.javaee.spec.EnvironmentRefsGroupMetaData; import org.jboss.metadata.parser.ee.DescriptionGroupMetaDataParser; import org.jboss.metadata.parser.ee.EnvironmentRefsGroupMetaDataParser; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.WebFragmentMetaData; @@ -41,10 +44,6 @@ public static WebFragmentMetaData parse(XMLStreamReader reader, PropertyReplacer } final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { - case ID: { - wmd.setId(value); - break; - } case VERSION: { wmd.setVersion(value); break; @@ -56,15 +55,16 @@ public static WebFragmentMetaData parse(XMLStreamReader reader, PropertyReplacer break; } default: - throw unexpectedAttribute(reader, i); + IdMetaDataParser.parseAttribute(reader, i, wmd); } } + Version version = Optional.ofNullable(wmd.getVersion()).map(Version::fromString).orElse(Version.LATEST); DescriptionGroupMetaData descriptionGroup = new DescriptionGroupMetaData(); EnvironmentRefsGroupMetaData env = new EnvironmentRefsGroupMetaData(); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { - if (WebCommonMetaDataParser.parse(reader, wmd, propertyReplacer)) { + if (WebCommonMetaDataParser.parse(reader, version, wmd, propertyReplacer)) { continue; } if (EnvironmentRefsGroupMetaDataParser.parse(reader, env, propertyReplacer)) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/WebMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/WebMetaDataParser.java index 887d45b6c..1e29b2a12 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/WebMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/WebMetaDataParser.java @@ -15,6 +15,7 @@ import org.jboss.metadata.javaee.spec.EnvironmentRefsGroupMetaData; import org.jboss.metadata.parser.ee.DescriptionGroupMetaDataParser; import org.jboss.metadata.parser.ee.EnvironmentRefsGroupMetaDataParser; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.JspConfigMetaData; @@ -59,40 +60,16 @@ public static WebMetaData parse(XMLStreamReader reader, DTDInfo info, boolean va } WebMetaData wmd = new WebMetaData(); if (version == null) { - // Look at the versionString attribute - String versionString = null; - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - if (attribute == Attribute.VERSION) { - versionString = reader.getAttributeValue(i); - } - } - if ("2.4".equals(versionString)) { - version = Version.SERVLET_2_4; - } else if ("2.5".equals(versionString)) { - version = Version.SERVLET_2_5; - } else if ("3.0".equals(versionString)) { - version = Version.SERVLET_3_0; - } else if ("3.1".equals(versionString)) { - version = Version.SERVLET_3_1; - } else if ("4.0".equals(versionString)) { - version = Version.SERVLET_4_0; - } else if ("5.0".equals(versionString)) { - version = Version.SERVLET_5_0; - } else if ("6.0".equals(versionString)) { - version = Version.SERVLET_6_0; + String versionString = reader.getAttributeValue(null, Attribute.VERSION.getLocalName()); + if (versionString != null) { + version = Version.fromString(versionString); } } - if(version != null) { - wmd.setVersion(version.versionString()); + if (version != null) { + wmd.setVersion(version.toString()); } // Set the publicId / systemId - if (info != null) - wmd.setDTD(info.getBaseURI(), info.getPublicID(), info.getSystemID()); + wmd.setDTD(info.getBaseURI(), info.getPublicID(), info.getSystemID()); // Set the schema location if we have one if (schemaLocation != null) @@ -107,10 +84,6 @@ public static WebMetaData parse(XMLStreamReader reader, DTDInfo info, boolean va } final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { - case ID: { - wmd.setId(value); - break; - } case VERSION: { wmd.setVersion(value); break; @@ -122,7 +95,7 @@ public static WebMetaData parse(XMLStreamReader reader, DTDInfo info, boolean va break; } default: - throw unexpectedAttribute(reader, i); + IdMetaDataParser.parseAttribute(reader, i, wmd); } } @@ -130,7 +103,7 @@ public static WebMetaData parse(XMLStreamReader reader, DTDInfo info, boolean va EnvironmentRefsGroupMetaData env = new EnvironmentRefsGroupMetaData(); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { - if (WebCommonMetaDataParser.parse(reader, wmd, propertyReplacer)) { + if (WebCommonMetaDataParser.parse(reader, version, wmd, propertyReplacer)) { continue; } if (EnvironmentRefsGroupMetaDataParser.parse(reader, env, propertyReplacer)) { diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/WebResourceCollectionMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/WebResourceCollectionMetaDataParser.java index 0dddbb971..1b8d79a45 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/WebResourceCollectionMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/WebResourceCollectionMetaDataParser.java @@ -13,6 +13,7 @@ import org.jboss.metadata.javaee.spec.DescriptionsImpl; import org.jboss.metadata.parser.ee.DescriptionsMetaDataParser; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.WebResourceCollectionMetaData; @@ -25,23 +26,7 @@ public class WebResourceCollectionMetaDataParser extends MetaDataElementParser { public static WebResourceCollectionMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { WebResourceCollectionMetaData webResourceCollection = new WebResourceCollectionMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - webResourceCollection.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, webResourceCollection); DescriptionsImpl descriptions = new DescriptionsImpl(); // Handle elements diff --git a/web/src/main/java/org/jboss/metadata/parser/servlet/WelcomeFileListMetaDataParser.java b/web/src/main/java/org/jboss/metadata/parser/servlet/WelcomeFileListMetaDataParser.java index 75dccf6ad..45113734c 100644 --- a/web/src/main/java/org/jboss/metadata/parser/servlet/WelcomeFileListMetaDataParser.java +++ b/web/src/main/java/org/jboss/metadata/parser/servlet/WelcomeFileListMetaDataParser.java @@ -11,6 +11,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.jboss.metadata.parser.ee.IdMetaDataParser; import org.jboss.metadata.parser.util.MetaDataElementParser; import org.jboss.metadata.property.PropertyReplacer; import org.jboss.metadata.web.spec.WelcomeFileListMetaData; @@ -23,23 +24,7 @@ public class WelcomeFileListMetaDataParser extends MetaDataElementParser { public static WelcomeFileListMetaData parse(XMLStreamReader reader, PropertyReplacer propertyReplacer) throws XMLStreamException { WelcomeFileListMetaData welcomeFileList = new WelcomeFileListMetaData(); - // Handle attributes - final int count = reader.getAttributeCount(); - for (int i = 0; i < count; i++) { - final String value = reader.getAttributeValue(i); - if (attributeHasNamespace(reader, i)) { - continue; - } - final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); - switch (attribute) { - case ID: { - welcomeFileList.setId(value); - break; - } - default: - throw unexpectedAttribute(reader, i); - } - } + IdMetaDataParser.parseAttributes(reader, welcomeFileList); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { diff --git a/web/src/main/java/org/jboss/metadata/web/spec/AttributeValueMetaData.java b/web/src/main/java/org/jboss/metadata/web/spec/AttributeValueMetaData.java new file mode 100644 index 000000000..cdeb0c474 --- /dev/null +++ b/web/src/main/java/org/jboss/metadata/web/spec/AttributeValueMetaData.java @@ -0,0 +1,34 @@ +/* + * Copyright The JBoss Metadata Authors + * SPDX-License-Identifier: Apache-2.0 + */ +package org.jboss.metadata.web.spec; + +import org.jboss.metadata.javaee.support.IdMetaDataImplWithDescriptions; + +/** + * Describes an attribute name/value pair. + * @author Paul Ferraro + */ +public class AttributeValueMetaData extends IdMetaDataImplWithDescriptions { + private static final long serialVersionUID = 1; + + private String attributeName; + private String attributeValue; + + public String getAttributeName() { + return this.attributeName; + } + + public void setAttributeName(String attributeName) { + this.attributeName = attributeName; + } + + public String getAttributeValue() { + return this.attributeValue; + } + + public void setAttributeValue(String attributeValue) { + this.attributeValue = attributeValue; + } +} diff --git a/web/src/main/java/org/jboss/metadata/web/spec/CookieConfigMetaData.java b/web/src/main/java/org/jboss/metadata/web/spec/CookieConfigMetaData.java index 11a045cb0..42981fa5f 100644 --- a/web/src/main/java/org/jboss/metadata/web/spec/CookieConfigMetaData.java +++ b/web/src/main/java/org/jboss/metadata/web/spec/CookieConfigMetaData.java @@ -4,6 +4,8 @@ */ package org.jboss.metadata.web.spec; +import java.util.List; + import org.jboss.metadata.javaee.support.IdMetaDataImpl; /** @@ -23,6 +25,7 @@ public class CookieConfigMetaData extends IdMetaDataImpl { private boolean secureSet = false; private int maxAge = -1; private boolean maxAgeSet = false; + private List attributes; public String getName() { return name; @@ -83,6 +86,14 @@ public void setMaxAge(int maxAge) { maxAgeSet = true; } + public List getAttributes() { + return this.attributes; + } + + public void setAttributes(List attributes) { + this.attributes = attributes; + } + public boolean getHttpOnlySet() { return httpOnlySet; } diff --git a/web/src/test/java/org/jboss/test/metadata/web/WebApp10EverythingUnitTestCase.java b/web/src/test/java/org/jboss/test/metadata/web/WebApp10EverythingUnitTestCase.java index 0e5ccef53..9ce9dcd40 100644 --- a/web/src/test/java/org/jboss/test/metadata/web/WebApp10EverythingUnitTestCase.java +++ b/web/src/test/java/org/jboss/test/metadata/web/WebApp10EverythingUnitTestCase.java @@ -4,7 +4,10 @@ */ package org.jboss.test.metadata.web; +import java.util.List; + import org.jboss.metadata.merge.javaee.spec.JavaEEVersion; +import org.jboss.metadata.web.spec.AttributeValueMetaData; import org.jboss.metadata.web.spec.WebMetaData; /** @@ -19,4 +22,13 @@ public void testEverything() throws Exception { WebMetaData webApp = unmarshal(); assertEverything(webApp, Mode.SPEC, JavaEEVersion.V10); } + + protected void assertCookieAttributes(List attributes) { + assertNotNull("cookie attributes not set", attributes); + assertEquals(2, attributes.size()); + assertEquals("SameSite", attributes.get(0).getAttributeName()); + assertEquals("None", attributes.get(0).getAttributeValue()); + assertEquals("foo", attributes.get(1).getAttributeName()); + assertEquals("bar", attributes.get(1).getAttributeValue()); + } } diff --git a/web/src/test/java/org/jboss/test/metadata/web/WebApp6EverythingUnitTestCase.java b/web/src/test/java/org/jboss/test/metadata/web/WebApp6EverythingUnitTestCase.java index 77ff325e1..1a27cf405 100644 --- a/web/src/test/java/org/jboss/test/metadata/web/WebApp6EverythingUnitTestCase.java +++ b/web/src/test/java/org/jboss/test/metadata/web/WebApp6EverythingUnitTestCase.java @@ -13,7 +13,9 @@ import org.jboss.metadata.javaee.spec.SecurityRoleRefsMetaData; import org.jboss.metadata.merge.javaee.spec.JavaEEVersion; import org.jboss.metadata.web.spec.AbsoluteOrderingMetaData; +import org.jboss.metadata.web.spec.AttributeValueMetaData; import org.jboss.metadata.web.spec.AuthConstraintMetaData; +import org.jboss.metadata.web.spec.CookieConfigMetaData; import org.jboss.metadata.web.spec.DispatcherType; import org.jboss.metadata.web.spec.FilterMappingMetaData; import org.jboss.metadata.web.spec.FilterMetaData; @@ -25,6 +27,8 @@ import org.jboss.metadata.web.spec.ServletMappingMetaData; import org.jboss.metadata.web.spec.ServletMetaData; import org.jboss.metadata.web.spec.ServletsMetaData; +import org.jboss.metadata.web.spec.SessionConfigMetaData; +import org.jboss.metadata.web.spec.SessionTrackingModeType; import org.jboss.metadata.web.spec.TransportGuaranteeType; import org.jboss.metadata.web.spec.UserDataConstraintMetaData; import org.jboss.metadata.web.spec.WebMetaData; @@ -58,8 +62,7 @@ protected void assertEverything(WebMetaData webApp, Mode mode, JavaEEVersion jav assertDenyUncoveredHttpMethods(webApp); assertSecurityConstraints(webApp); assertAbsoluteOrdering(webApp); - assertNotNull("no session config set", webApp.getSessionConfig()); - assertEquals(30, webApp.getSessionConfig().getSessionTimeout()); + assertSessionConfig(webApp.getSessionConfig()); } protected void assertAbsoluteOrdering(WebMetaData webApp) @@ -214,4 +217,30 @@ protected void assertUncheckedSecurityConstraint(SecurityConstraintMetaData scmd protected void assertModuleName(WebMetaData webApp) { assertEquals("foo", webApp.getModuleName()); } + + protected void assertSessionConfig(SessionConfigMetaData metaData) { + assertNotNull("no session config set", metaData); + assertEquals(-1, metaData.getSessionTimeout()); + assertCookieConfig(metaData.getCookieConfig()); + assertEquals(List.of(SessionTrackingModeType.COOKIE), metaData.getSessionTrackingModes()); + } + + protected void assertCookieConfig(CookieConfigMetaData metaData) { + assertNotNull("no cookie config set", metaData); + assertEquals("session", metaData.getName()); + assertEquals(".jboss.org", metaData.getDomain()); + assertEquals("/", metaData.getPath()); + assertEquals("Test", metaData.getComment()); + assertTrue(metaData.getHttpOnlySet()); + assertTrue(metaData.getHttpOnly()); + assertTrue(metaData.getSecureSet()); + assertTrue(metaData.getSecure()); + assertTrue(metaData.getMaxAgeSet()); + assertEquals(10, metaData.getMaxAge()); + assertCookieAttributes(metaData.getAttributes()); + } + + protected void assertCookieAttributes(List attributes) { + assertNull(attributes); + } } diff --git a/web/src/test/resources/org/jboss/test/metadata/web/WebApp10DenyUncoveredHttpMethods_testEverything.xml b/web/src/test/resources/org/jboss/test/metadata/web/WebApp10DenyUncoveredHttpMethods_testEverything.xml index 31a75d817..3c510aabf 100644 --- a/web/src/test/resources/org/jboss/test/metadata/web/WebApp10DenyUncoveredHttpMethods_testEverything.xml +++ b/web/src/test/resources/org/jboss/test/metadata/web/WebApp10DenyUncoveredHttpMethods_testEverything.xml @@ -162,6 +162,7 @@ + -1 session .jboss.org @@ -1155,8 +1156,8 @@ webAppManagedExecutor1-desc webAppManagedExecutor1-name webAppManagedExecutor1-contextServiceRef - 1 1 + 1 webAppManagedExecutor1Property1Name webAppManagedExecutor1Property1Value @@ -1170,8 +1171,8 @@ webAppManagedExecutor2-desc webAppManagedExecutor2-name webAppManagedExecutor2-contextServiceRef - 2 2 + 2 webAppManagedExecutor2Property1Name webAppManagedExecutor2Property1Value @@ -1190,8 +1191,8 @@ webAppManagedScheduledExecutor1-desc webAppManagedScheduledExecutor1-name webAppManagedScheduledExecutor1-contextServiceRef - 1 1 + 1 webAppManagedScheduledExecutor1Property1Name webAppManagedScheduledExecutor1Property1Value @@ -1205,8 +1206,8 @@ webAppManagedScheduledExecutor2-desc webAppManagedScheduledExecutor2-name webAppManagedScheduledExecutor2-contextServiceRef - 2 2 + 2 webAppManagedScheduledExecutor2Property1Name webAppManagedScheduledExecutor2Property1Value diff --git a/web/src/test/resources/org/jboss/test/metadata/web/WebApp10DenyUncoveredHttpMethods_testInvalidElement.xml b/web/src/test/resources/org/jboss/test/metadata/web/WebApp10DenyUncoveredHttpMethods_testInvalidElement.xml index e4a496ae9..b75aa0fab 100644 --- a/web/src/test/resources/org/jboss/test/metadata/web/WebApp10DenyUncoveredHttpMethods_testInvalidElement.xml +++ b/web/src/test/resources/org/jboss/test/metadata/web/WebApp10DenyUncoveredHttpMethods_testInvalidElement.xml @@ -162,7 +162,8 @@ - + -1 + session .jboss.org / @@ -1157,8 +1158,8 @@ webAppManagedExecutor1-desc webAppManagedExecutor1-name webAppManagedExecutor1-contextServiceRef - 1 1 + 1 webAppManagedExecutor1Property1Name webAppManagedExecutor1Property1Value @@ -1172,8 +1173,8 @@ webAppManagedExecutor2-desc webAppManagedExecutor2-name webAppManagedExecutor2-contextServiceRef - 2 2 + 2 webAppManagedExecutor2Property1Name webAppManagedExecutor2Property1Value @@ -1192,8 +1193,8 @@ webAppManagedScheduledExecutor1-desc webAppManagedScheduledExecutor1-name webAppManagedScheduledExecutor1-contextServiceRef - 1 1 + 1 webAppManagedScheduledExecutor1Property1Name webAppManagedScheduledExecutor1Property1Value @@ -1207,8 +1208,8 @@ webAppManagedScheduledExecutor2-desc webAppManagedScheduledExecutor2-name webAppManagedScheduledExecutor2-contextServiceRef - 2 2 + 2 webAppManagedScheduledExecutor2Property1Name webAppManagedScheduledExecutor2Property1Value diff --git a/web/src/test/resources/org/jboss/test/metadata/web/WebApp10Everything_testEverything.xml b/web/src/test/resources/org/jboss/test/metadata/web/WebApp10Everything_testEverything.xml index 043ad94de..a9b22a649 100644 --- a/web/src/test/resources/org/jboss/test/metadata/web/WebApp10Everything_testEverything.xml +++ b/web/src/test/resources/org/jboss/test/metadata/web/WebApp10Everything_testEverything.xml @@ -5,8 +5,6 @@ --> foo @@ -162,7 +160,8 @@ - + -1 + session .jboss.org / @@ -170,6 +169,14 @@ true true 10 + + SameSite + None + + + foo + bar + COOKIE @@ -1154,8 +1161,8 @@ webAppManagedExecutor1-desc webAppManagedExecutor1-name webAppManagedExecutor1-contextServiceRef - 1 1 + 1 webAppManagedExecutor1Property1Name webAppManagedExecutor1Property1Value @@ -1169,8 +1176,8 @@ webAppManagedExecutor2-desc webAppManagedExecutor2-name webAppManagedExecutor2-contextServiceRef - 2 2 + 2 webAppManagedExecutor2Property1Name webAppManagedExecutor2Property1Value @@ -1189,8 +1196,8 @@ webAppManagedScheduledExecutor1-desc webAppManagedScheduledExecutor1-name webAppManagedScheduledExecutor1-contextServiceRef - 1 1 + 1 webAppManagedScheduledExecutor1Property1Name webAppManagedScheduledExecutor1Property1Value @@ -1204,8 +1211,8 @@ webAppManagedScheduledExecutor2-desc webAppManagedScheduledExecutor2-name webAppManagedScheduledExecutor2-contextServiceRef - 2 2 + 2 webAppManagedScheduledExecutor2Property1Name webAppManagedScheduledExecutor2Property1Value diff --git a/web/src/test/resources/org/jboss/test/metadata/web/WebApp10Fragment_testEverything.xml b/web/src/test/resources/org/jboss/test/metadata/web/WebApp10Fragment_testEverything.xml index fbf89e3a7..aa78ed02b 100644 --- a/web/src/test/resources/org/jboss/test/metadata/web/WebApp10Fragment_testEverything.xml +++ b/web/src/test/resources/org/jboss/test/metadata/web/WebApp10Fragment_testEverything.xml @@ -1142,8 +1142,8 @@ webAppManagedExecutor1-desc webAppManagedExecutor1-name webAppManagedExecutor1-contextServiceRef - 1 1 + 1 webAppManagedExecutor1Property1Name webAppManagedExecutor1Property1Value @@ -1157,8 +1157,8 @@ webAppManagedExecutor2-desc webAppManagedExecutor2-name webAppManagedExecutor2-contextServiceRef - 2 2 + 2 webAppManagedExecutor2Property1Name webAppManagedExecutor2Property1Value @@ -1177,8 +1177,8 @@ webAppManagedScheduledExecutor1-desc webAppManagedScheduledExecutor1-name webAppManagedScheduledExecutor1-contextServiceRef - 1 1 + 1 webAppManagedScheduledExecutor1Property1Name webAppManagedScheduledExecutor1Property1Value @@ -1192,8 +1192,8 @@ webAppManagedScheduledExecutor2-desc webAppManagedScheduledExecutor2-name webAppManagedScheduledExecutor2-contextServiceRef - 2 2 + 2 webAppManagedScheduledExecutor2Property1Name webAppManagedScheduledExecutor2Property1Value diff --git a/web/src/test/resources/org/jboss/test/metadata/web/WebApp6Everything_testEverything.xml b/web/src/test/resources/org/jboss/test/metadata/web/WebApp6Everything_testEverything.xml index 888204b88..9c41e9286 100644 --- a/web/src/test/resources/org/jboss/test/metadata/web/WebApp6Everything_testEverything.xml +++ b/web/src/test/resources/org/jboss/test/metadata/web/WebApp6Everything_testEverything.xml @@ -162,7 +162,8 @@ - + -1 + session .jboss.org / diff --git a/web/src/test/resources/org/jboss/test/metadata/web/WebApp7Everything_testEverything.xml b/web/src/test/resources/org/jboss/test/metadata/web/WebApp7Everything_testEverything.xml index 564a08de9..a5cbb24b2 100644 --- a/web/src/test/resources/org/jboss/test/metadata/web/WebApp7Everything_testEverything.xml +++ b/web/src/test/resources/org/jboss/test/metadata/web/WebApp7Everything_testEverything.xml @@ -162,7 +162,8 @@ - + -1 + session .jboss.org / diff --git a/web/src/test/resources/org/jboss/test/metadata/web/WebApp8Everything_testEverything.xml b/web/src/test/resources/org/jboss/test/metadata/web/WebApp8Everything_testEverything.xml index ee2616dac..1d764f513 100644 --- a/web/src/test/resources/org/jboss/test/metadata/web/WebApp8Everything_testEverything.xml +++ b/web/src/test/resources/org/jboss/test/metadata/web/WebApp8Everything_testEverything.xml @@ -162,7 +162,8 @@ - + -1 + session .jboss.org / diff --git a/web/src/test/resources/org/jboss/test/metadata/web/WebApp9Everything_testEverything.xml b/web/src/test/resources/org/jboss/test/metadata/web/WebApp9Everything_testEverything.xml index 8eac7a6b1..bd9b81c7a 100644 --- a/web/src/test/resources/org/jboss/test/metadata/web/WebApp9Everything_testEverything.xml +++ b/web/src/test/resources/org/jboss/test/metadata/web/WebApp9Everything_testEverything.xml @@ -162,7 +162,8 @@ - + -1 + session .jboss.org /