WW-4291 Allow Spring bean names for type converters#1562
Merged
lukaszlenart merged 1 commit intomainfrom Feb 6, 2026
Merged
Conversation
d4e170a to
995e4e2
Compare
5f05abc to
4d1fd16
Compare
jogep
approved these changes
Feb 1, 2026
core/src/main/java/org/apache/struts2/config/AbstractBeanSelectionProvider.java
Show resolved
Hide resolved
Implement two-phase processing for conversion properties to enable Spring bean name resolution in struts-conversion.properties files. The issue was a timing problem: type converters were processed during bootstrap phase before SpringObjectFactory was available. Now: - Early phase: process struts-default-conversion.properties (class names) - Late phase: process user properties when SpringObjectFactory is ready Changes: - Add UserConversionPropertiesProvider interface for late initialization - Add UserConversionPropertiesProcessor to trigger late phase processing - Split StrutsConversionPropertiesProcessor.init() into early/late phases - Register new beans in DefaultConfiguration and struts-beans.xml - Add alias in StrutsBeanSelectionProvider for dependency injection - Improve JavaDocs for BeanSelectionProvider classes Closes WW-4291 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
4d1fd16 to
e0d2683
Compare
|
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.



Summary
This PR implements two-phase processing for conversion properties to enable Spring bean name resolution in
struts-conversion.propertiesfiles.Problem: Users could not reference Spring bean names in conversion properties. When specifying a bean name (e.g., "myConverter") instead of a fully qualified class name, a
ClassNotFoundExceptionwas thrown.Root Cause: Type converters were processed during the bootstrap phase before
SpringObjectFactorywas available.SpringObjectFactory.getClassInstance()already supports bean names viacontainsBean()check, but it wasn't being used during early initialization.Solution: Split conversion property processing into two phases:
struts-default-conversion.propertiesonly - contains class namesstruts-conversion.properties,xwork-conversion.properties) whenSpringObjectFactoryis availableChanges
UserConversionPropertiesProviderinterface defining the late initialization contractUserConversionPropertiesProcessorimplementingInitializablefor late-phase processingStrutsConversionPropertiesProcessorto implementUserConversionPropertiesProviderand splitinit()into early/late phasesDefaultConfigurationandstruts-beans.xmlStrutsBeanSelectionProviderfor proper dependency injectionDefaultConfiguration.reloadContainer()BeanSelectionProviderandAbstractBeanSelectionProviderUsage After This Change
Users can now specify Spring bean names in
struts-conversion.properties:Test Plan
StrutsConversionPropertiesProcessortwo-phase processingSpringObjectFactorymvn test -DskipAssemblyFixes WW-4291
🤖 Generated with Claude Code