Skip to content

Add i18n support for description and display-name elements in web.xml - #1064

Open
ABin-Huang wants to merge 7 commits into
apache:mainfrom
ABin-Huang:webxml-i18n
Open

Add i18n support for description and display-name elements in web.xml#1064
ABin-Huang wants to merge 7 commits into
apache:mainfrom
ABin-Huang:webxml-i18n

Conversation

@ABin-Huang

Copy link
Copy Markdown

This PR addresses the "WebXml Internationalization Support" item from TODO.md and implements internationalization support for the description and display-name elements in web.xml / web-fragment.xml. Per the deployment descriptor specification, these elements may be repeated with different xml:lang attributes to provide multi-language metadata.

Summary of changes

  • New LocaleElement class holding the element content and its optional xml:lang value
  • ResourceBase, FilterDef, ServletDef, SecurityRoleRef, SecurityConstraint, SecurityCollection, MessageDestination, ContextService and WebXml now store description / display-name as lists of LocaleElement
  • Existing String-based getters/setters are preserved for backwards compatibility; the default (language-less) element is returned when present
  • WebXml.merge() combines elements from different languages and detects conflicts when two fragments define the same language with different content
  • WebRuleSet parses the xml:lang attribute (with namespace URI fallback) and populates the new structures via a new LocaleElementRule
  • toXml() serializes all locale aware elements, including the xml:lang attribute

Testing

  • New TestWebXmlI18n with 11 test cases covering parsing, round-trip serialization, setter semantics and merge behaviour
  • Existing descriptor tests remain green (TestWebXml, TestWebRuleSet, TestWebXmlParser, TestSecurityConstraint, TestFilterDef, TestServletDef, TestWebXmlOrdering)
  • ant validate -Dexecute.validate=true (checkstyle) passes

Add a LocaleElement class to capture the content of locale-aware
deployment descriptor elements together with their optional xml:lang
attribute and use it to support multiple description and display-name
elements with language variants throughout the descriptor model.
Add a LocaleElement class to capture the content of locale-aware
deployment descriptor elements together with their optional xml:lang
attribute and use it to support multiple description and display-name
elements with language variants throughout the descriptor model.

This commit updates the value classes: SecurityRoleRef (new description
support), SecurityCollection, MessageDestination and ContextService.
Update ResourceBase (descriptions for env-entry, ejb-ref, ejb-local-ref,
service-ref, resource-ref, resource-env-ref, message-destination-ref and
message-destination), FilterDef and ServletDef to store locale-aware
LocaleElement lists while preserving the String based compatibility
getters and setters.
Update SecurityConstraint to store locale-aware descriptions and display
names with full language support while preserving the String based
compatibility getters and setters.
Replace the string based addCallMethod rules for description and
display-name elements with a new LocaleElementRule that captures the
element content together with the optional xml:lang attribute as a
LocaleElement and adds it via the corresponding addDescription /
addDisplayName method.
Add TestWebXmlI18n covering parsing of multi-language description and
display-name elements (web-app, filter, servlet, security-role-ref,
security-constraint, web-resource-collection, env-entry, resource-ref,
message-destination), toXml round-tripping, setter replacement semantics
and merge behaviour for both distinct languages and same language
conflicts.
Store web-app level description and display-name elements as locale aware
LocaleElement lists, output all locale aware elements with their optional
xml:lang attribute in toXml() and merge descriptions and display names by
language, detecting conflicts when two fragments define the same language.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant