Need more flexibility around conversion strategies and how to bootstrap different conversion strategies. [SPR-6381] #11047
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Oleg Zhurakousky opened SPR-6381 and commented
Related to #10464
As a developer I need:
For example:
Object.toString() is not always the right default strategy since implementation of the toString() method often tailored more toward displaying an object in the logs, rather then creating a true String representation of it
Object to Map and vice versa, also is not always a good default strategy since Object might represent some type of a structure that could be represented as more then a single entry Map
The bottom line is as a developer I want to have a choice and control as to how canConvert() method behaves. In other words if I want to convert Foo to String and there is no FooToString cnverter I want to see can't convert exception and not rely on the default generic strategy.
Currently in SI we have to remove bunch of converters in order to use the ConversionService
I also need ability to chain/synthesize converters. However, this strategy will not work if we have ObjectTo* and *ToObject converters since everything is an object, which means the default state of such converter must only have strongly typed converters pre-registered or empty.
Overall I think we need flexibility and therefore several strategies needed. So I think what would be appropriate is to have a Factory class with Factory methods fronting the ConversionService creation, this allowing to bootstrap several implementations.
For example
etc. . .
Obviously not passing any additional converters will result in the initial state of the ConversionService to correspond to the implementation of the factory method. Configuration would also be simple:
{CODE}
<bean id="conversionService" class="ConversionServiceFactory" factory-method="createSyntheticConverter">
<constructor-arg>
<list>
. . .
</bean>
{CODE}
Affects: 3.0 RC2
Issue Links:
The text was updated successfully, but these errors were encountered: