Repository navigation
WW-3476 Add package-scoped constants - #2005
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wire the provider like other pluggable core services (struts-beans.xml, StrutsBeanSelectionProvider alias, struts.scopedConstantProvider). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…errides Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cher path Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukaszlenart
marked this pull request as ready for review
October 10, 2026 16:07
…ures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…om the container once Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukaszlenart
commented
Oct 10, 2026
…Names Matches the Container contract ContainerImpl follows; callers iterate the result without a null check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion extension point Lists it in the StrutsBeanSelectionProvider extension-point table, adds struts.scopedConstantProvider to default.properties, and pins that the constant selects a custom bean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
It changes core configuration parsing, inheritance, startup validation, and dependency-injection APIs, warranting final human review.
0 open findings
What changed in this PR
Introduces opt-in package-scoped Struts constants with inheritance, startup validation, and runtime resolution.
Changes:
- Adds the 7.5 DTD and package configuration storage/parsing.
- Adds scopable-constant registration, validation, and provider wiring.
- Adds comprehensive configuration, inheritance, fallback, and wiring tests.
| File | Description |
|---|---|
docs/superpowers/specs/2026-10-10-WW-3476-scoped-constants-design.md |
Documents the design. |
docs/superpowers/plans/2026-10-10-WW-3476-scoped-constants.md |
Records the implementation plan. |
core/src/test/resources/org/apache/struts2/config/struts-scoped-constants-unregistered.xml |
Tests unregistered constants. |
core/src/test/resources/org/apache/struts2/config/struts-scoped-constants-two-beans.xml |
Tests multiple registries. |
core/src/test/resources/org/apache/struts2/config/struts-scoped-constants-registered.xml |
Tests registered constants. |
core/src/test/resources/org/apache/struts2/config/struts-scoped-constants-provider.xml |
Provides lookup scenarios. |
core/src/test/resources/org/apache/struts2/config/struts-scoped-constants-no-registry.xml |
Tests an empty registry. |
core/src/test/resources/org/apache/struts2/config/struts-scoped-constants-custom-provider.xml |
Configures a custom provider. |
core/src/test/resources/org/apache/struts2/config/struts-scoped-constants-abstract-unregistered.xml |
Tests abstract-package validation. |
core/src/test/resources/org/apache/struts2/config/providers/struts-scoped-constants-old-dtd.xml |
Tests old-DTD rejection. |
core/src/test/resources/org/apache/struts2/config/providers/struts-scoped-constants-inheritance.xml |
Tests package inheritance. |
core/src/test/resources/org/apache/struts2/config/providers/struts-scoped-constants-duplicate.xml |
Tests duplicate rejection. |
core/src/test/java/org/apache/struts2/config/StrutsScopedConstantProviderTest.java |
Tests runtime resolution and fallback. |
core/src/test/java/org/apache/struts2/config/SecondScopableConstants.java |
Supplies a second test registry. |
core/src/test/java/org/apache/struts2/config/ScopedConstantsValidationTest.java |
Tests startup validation. |
core/src/test/java/org/apache/struts2/config/ScopedConstantProviderWiringTest.java |
Tests provider selection. |
core/src/test/java/org/apache/struts2/config/ScopableConstantsTest.java |
Tests registry collection. |
core/src/test/java/org/apache/struts2/config/SampleScopableConstants.java |
Supplies test constant names. |
core/src/test/java/org/apache/struts2/config/providers/XmlConfigurationProviderPackagesTest.java |
Tests XML parsing behavior. |
core/src/test/java/org/apache/struts2/config/entities/PackageConfigTest.java |
Tests storage and inheritance. |
core/src/test/java/org/apache/struts2/config/CustomScopedConstantProvider.java |
Supplies a custom test provider. |
core/src/main/resources/struts-beans.xml |
Registers the default provider bean. |
core/src/main/resources/struts-7.5.dtd |
Defines package-scoped constants. |
core/src/main/resources/org/apache/struts2/default.properties |
Selects the default provider. |
core/src/main/java/org/apache/struts2/StrutsConstants.java |
Adds the provider-selection key. |
core/src/main/java/org/apache/struts2/mock/MockContainer.java |
Aligns mock instance-name behavior. |
core/src/main/java/org/apache/struts2/config/StrutsXmlConfigurationProvider.java |
Registers the new DTD. |
core/src/main/java/org/apache/struts2/config/StrutsScopedConstantProvider.java |
Implements scoped lookup. |
core/src/main/java/org/apache/struts2/config/StrutsBeanSelectionProvider.java |
Adds provider alias selection. |
core/src/main/java/org/apache/struts2/config/ScopedConstantProvider.java |
Defines the lookup API. |
core/src/main/java/org/apache/struts2/config/ScopableConstants.java |
Defines the opt-in registry. |
core/src/main/java/org/apache/struts2/config/providers/XmlDocConfigurationProvider.java |
Parses scoped constants. |
core/src/main/java/org/apache/struts2/config/providers/StrutsDefaultConfigurationProvider.java |
Registers the test-harness provider. |
core/src/main/java/org/apache/struts2/config/impl/DefaultConfiguration.java |
Validates declarations at startup. |
core/src/main/java/org/apache/struts2/config/entities/PackageConfig.java |
Stores and merges scoped values. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
lukaszlenart
commented
Oct 11, 2026
….providers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c939805 committed only the renames; this adds the package declarations, imports and the struts-beans.xml class name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes WW-3476
Summary
Adds package-scoped constants: a
<package>can override selected constants, and child packages inherit the override throughextends.struts-7.5.dtd: a copy of 6.5 plus a repeatable<scoped-constant name value/>as the first child of<package>. Published DTDs are unchanged; this follows the WW-5409 /struts-6.5.dtdprecedent.PackageConfig: stores the package's own overrides (getScopedConstants()) and, atbuild(), a merged view (getAllScopedConstants()). Parents merge first and the package's own entries win, in the same order asgetAllResultTypeConfigs().ScopableConstants: components opt a constant in by registering a named bean. The scopable set is the union of all registered beans.DefaultConfigurationrejects a<scoped-constant>whose name no bean registered, including in abstract packages, so a typo or an override nothing reads fails loudly.ScopedConstantProvider.getValue(name)(defaultStrutsScopedConstantProvider): resolves the value against the current invocation's package and falls back to the global constant. The value already injected into singletons is never changed. It is wired likeParameterAuthorizer:struts-beans.xml, aStrutsBeanSelectionProvideralias, andstruts.scopedConstantProvider.Design notes
PrefixBasedActionMapper(struts.mapper.prefixMapping).struts.parameters.requireAnnotations, DMI, CSP,devMode). Otherwise a single package could relax an application-wide setting.${...}evaluation.Design spec and implementation plan:
docs/superpowers/specs/2026-10-10-WW-3476-scoped-constants-design.md,docs/superpowers/plans/2026-10-10-WW-3476-scoped-constants.md.Follow-ups
dtds/struts-7.5.dtdon struts-site before the release (rename the DTD and its public id together if the release ships under a different version).Test plan
PackageConfigTest: child overrides parent, two-level inheritance, which of several parents wins, builder copy, unmodifiable maps, equalityXmlConfigurationProviderPackagesTest: parse and inherit, duplicate name fails, element rejected under the 6.5 DTDScopedConstantsValidationTest: registered name loads, unregistered and abstract-package overrides fail, no registry, union of several beansStrutsScopedConstantProviderTest: package value wins, inherited value, empty override, global fallback (no context, invocation, proxy, config or package), unset constant givesnull, unregistered name throws, global value untouchedScopedConstantProviderWiringTest: the Dispatcher path resolvesStrutsScopedConstantProvider./mvnw test -DskipAssembly -pl core,plugins/convention: core 3439/3439, convention 66/66🤖 Generated with Claude Code