Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review Converter resolution algorithm [SPR-6314] #10980

Closed
spring-projects-issues opened this issue Nov 9, 2009 · 1 comment
Closed

Review Converter resolution algorithm [SPR-6314] #10980

spring-projects-issues opened this issue Nov 9, 2009 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply type: task A general task

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 9, 2009

Keith Donald opened SPR-6314 and commented

The Converter resolution algorithm for Spring 3's new Type Conversion System used by Spring EL, Spring Beans, and Spring MVC needs to be reviewed carefully, since its such a core part of the Framework going forward and it has gotten more complex since the additional support for annotation-driven conversion (see #10979).

CURRENT ALGORITHM

  • A ConversionService is asked to convert field of type S to field of type T
  • ConversionService looks up all registered converters converting from S.
  • Of that set, conversion service gets a set of "Matchable" converters that can go from S to T.
  • It goes through each matchable converter in order until it finds a match, and that's the selected converter that will be used

EXAMPLE

  • Consider converting from java.lang.String to java.util.Date
  • You could have a single default converter registered for the String->Date type pair and another one for that pair when the target Date is annotated with @DateTimeFormat
  • In that case, that would be two matchable converters for S->T that get put in a stack. The last one added is first out, and we go through the stack until we find the first match.

The main things to consider about the algorithm:

  • We consider the source->target type pair the "most significant" in terms of Converter resolution. This is in contrast to indexing first on something like an annotation type, then determining if an annotation-driven converter matches the S->T request. This allows the core Converter resolution algorithm to be unaware of annotation matching concepts, but it prevents annotation-driven formatting from being associated with abstract types.
  • Is the class/interface hierarchy search a potential performance concern? Are there optimizations we could make there?

Affects: 3.0 RC1

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Closing groups of outdated issues. Please reopen if still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants