[
https://issues.apache.org/jira/browse/WW-3476?focusedWorklogId=1046792&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1046792
]
ASF GitHub Bot logged work on WW-3476:
--------------------------------------
Author: ASF GitHub Bot
Created on: 10/Oct/26 15:50
Start Date: 10/Oct/26 15:50
Worklog Time Spent: 10m
Work Description: lukaszlenart opened a new pull request, #2005:
URL: https://github.com/apache/struts/pull/2005
Fixes [WW-3476](https://issues.apache.org/jira/browse/WW-3476)
## Summary
Adds package-scoped constants: a `<package>` can override selected
constants, and child packages inherit the override through `extends`.
```xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 7.5//EN"
"https://struts.apache.org/dtds/struts-7.5.dtd">
<package name="admin" extends="struts-default" namespace="/admin">
<scoped-constant name="some.scopable.constant" value="x"/>
</package>
```
- **`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.dtd` precedent.
- **`PackageConfig`**: stores the package's own overrides
(`getScopedConstants()`) and, at `build()`, a merged view
(`getAllScopedConstants()`). Parents merge first and the package's own entries
win, in the same order as `getAllResultTypeConfigs()`.
- **`ScopableConstants`**: components opt a constant in by registering a
named bean. The scopable set is the union of all registered beans.
- **Startup validation**: `DefaultConfiguration` rejects 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)`** (default
`StrutsScopedConstantProvider`): 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 like
`ParameterAuthorizer`: `struts-beans.xml`, a `StrutsBeanSelectionProvider`
alias, and `struts.scopedConstantProvider`.
## Design notes
- **Opt-in, no adopters yet.** Constants are injected into singletons once
at startup, so transparently overriding *every* constant per package would need
a container per package. That is out of reach for 7.x. Instead, each component
that wants a scoped value reads it through the provider. No constant is
registered as scopable in this PR; each adopter (UI theme, i18n, Convention
result path, …) is a follow-up.
- **Some constants can never be scoped**: anything consumed before the
package is known, such as the ActionMapper or multipart limits. The
per-URL-space mapper need from the ticket is already covered by
`PrefixBasedActionMapper` (`struts.mapper.prefixMapping`).
- **Security switches should not be registered as scopable** without a
deliberate decision (`struts.parameters.requireAnnotations`, DMI, CSP,
`devMode`). Otherwise a single package could relax an application-wide setting.
- **Values are static strings.** No `${...}` 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
- Publish `dtds/struts-7.5.dtd` on struts-site before the release (rename
the DTD and its public id together if the release ships under a different
version).
## Test plan
- [x] `PackageConfigTest`: child overrides parent, two-level inheritance,
which of several parents wins, builder copy, unmodifiable maps, equality
- [x] `XmlConfigurationProviderPackagesTest`: parse and inherit, duplicate
name fails, element rejected under the 6.5 DTD
- [x] `ScopedConstantsValidationTest`: registered name loads, unregistered
and abstract-package overrides fail, no registry, union of several beans
- [x] `StrutsScopedConstantProviderTest`: package value wins, inherited
value, empty override, global fallback (no context, invocation, proxy, config
or package), unset constant gives `null`, unregistered name throws, global
value untouched
- [x] `ScopedConstantProviderWiringTest`: the Dispatcher path resolves
`StrutsScopedConstantProvider`
- [x] `./mvnw test -DskipAssembly -pl core,plugins/convention`: core
3439/3439, convention 66/66
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Issue Time Tracking
-------------------
Worklog Id: (was: 1046792)
Remaining Estimate: 0h
Time Spent: 10m
> Allow overwriting of constants for each package
> -----------------------------------------------
>
> Key: WW-3476
> URL: https://issues.apache.org/jira/browse/WW-3476
> Project: Struts 2
> Issue Type: New Feature
> Components: XML Configuration
> Affects Versions: 2.2.1
> Reporter: Johannes Geppert
> Assignee: Lukasz Lenart
> Priority: Major
> Fix For: 7.5.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Allow to overwriting of constants for each package.
> So I can specify as example for each package an other ActionMapper, Local or
> other location for the JSP Files.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)