diff --git a/org.springframework.core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java b/org.springframework.core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java index 0af53dd94bd..8b3c3208498 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java +++ b/org.springframework.core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java @@ -31,6 +31,12 @@ public class DefaultConversionService extends GenericConversionService { * Create a new default conversion service, installing the default converters. */ public DefaultConversionService() { + initDefaultConverters(); + } + + // subclassing hooks + + protected void initDefaultConverters() { addConverter(new StringToBooleanConverter()); addConverter(new StringToCharacterConverter()); addConverter(new StringToLocaleConverter()); diff --git a/org.springframework.core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java b/org.springframework.core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java index c77876600a8..ca34e8dd6a7 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java +++ b/org.springframework.core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java @@ -58,9 +58,7 @@ public class GenericConversionService implements ConversionService, ConverterReg private final Set matchableConverters = new LinkedHashSet(); public GenericConversionService() { - addGenericConverter(new CollectionGenericConverter(this)); - addGenericConverter(new MapGenericConverter(this)); - addGenericConverter(new ArrayGenericConverter(this)); + initGenericConverters(); } /** @@ -183,6 +181,16 @@ public class GenericConversionService implements ConversionService, ConverterReg // subclassing hooks + protected void initGenericConverters() { + addGenericConverter(new CollectionGenericConverter(this)); + addGenericConverter(new MapGenericConverter(this)); + addGenericConverter(new ArrayGenericConverter(this)); + } + + protected void addGenericConverter(GenericConverter converter) { + this.matchableConverters.add(converter); + } + protected GenericConverter getConverter(TypeDescriptor sourceType, TypeDescriptor targetType) { GenericConverter converter = matchConverterByClassPair(sourceType.getObjectType(), targetType.getObjectType()); if (converter == null) { @@ -197,10 +205,6 @@ public class GenericConversionService implements ConversionService, ConverterReg // internal helpers - private void addGenericConverter(GenericConverter converter) { - this.matchableConverters.add(converter); - } - private List getRequiredTypeInfo(Object converter) { List typeInfo = new ArrayList(2); if (converter instanceof ConverterInfo) {