-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Converter auto-register itself to ConversionService [SPR-6415] #11081
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
Comments
Keith Donald commented Related to this: some converters require a callback into the ConversionService. Some sort of conversion service aware concept would simplify the config of such converters. |
Lance Arlaus commented I ran into both these issues on my current project where I'm using the conversion service.
Notes
Code
|
Mark Kralj-Taylor commented Could a JAR META-INF entry be used to identify converters? This would allow infrastructure converters to be picked up in a zero touch way from Jars on the classpath. Spring could even use the same mechanism for its default converters. |
Liu, Yinwei David commented Hi, META-INF/services/spring.convert.Converters sample file: Is it possible that Spring can provide a similar solution for Converters auto registration? |
André Wolf commented I found a very simple solution which seems to work fine for me. I just created a common super class
For me it's a preferable solution, because it does not need a |
Kosta Krauth commented A variation on Andre's approach, registering all the converters once the context has been loaded does the trick too. Didn't encounter any issues with the SpringJUnitClassRunner. With this approach, the Converters can be implemented in the standard way without any additional classes.
The approach of adding a component with the FactoryBean<ConversionService> interface that registers all Converters on itself works as well, as long as you don't autowire the ConversionService into Converters themselves. That scenario quickly descends into circular dependency hell. |
This approach requires more fine-grained knowledge of the application. This looks like a general auto-configuration feature rather than a Spring Framework concern. I'm closing this issue as a result. |
Liu, Yinwei David opened SPR-6415 and commented
Hi,
Currently, we can only register a CustomConverter by configuring it in Spring configuration file in Spring 3.0.0.RC2. However, we want the ability which allows all Converters to register themselves into the global ConversionService by default.
In Spring 3.0.RC2, we can use ConversionServiceFactoryBean to create a ConversionService in Spring config. If people have a lot of Converter in the infrastructure libraries, they need to register all customized converters by themself, so we think it would be good if Converter itself can register itself.
Affects: 3.0 RC1, 3.0 RC2
4 votes, 8 watchers
The text was updated successfully, but these errors were encountered: