diff --git a/spring-framework-reference/src/validation.xml b/spring-framework-reference/src/validation.xml
index 8049b8b7d72..0fae35b2dd7 100644
--- a/spring-framework-reference/src/validation.xml
+++ b/spring-framework-reference/src/validation.xml
@@ -26,17 +26,16 @@
The BeanWrapper is a fundamental concept in the
Spring Framework and is used in a lot of places. However, you probably
- will not ever have the need to use the BeanWrapper directly. Because this
+ will not have the need to use the BeanWrapper directly. Because this
is reference documentation however, we felt that some explanation might be
- in order. We're explaining the BeanWrapper in this chapter since if you were
- going to use it at all, you would probably do so when trying to bind
- data to objects, which is strongly related to the BeanWrapper.
-
- Spring uses PropertyEditors all over the place. The concept of a
- PropertyEditor is part of the JavaBeans specification. Just as the
- BeanWrapper, it's best to explain the use of PropertyEditors in this
- chapter as well, since it's closely related to the BeanWrapper and the
- DataBinder.
+ in order. We will explain the BeanWrapper in this chapter since, if you were
+ going to use it at all, you would most likely do so when trying to bind data to objects.
+
+ Spring's DataBinder and the lower-level BeanWrapper both use PropertyEditors to parse and format property values.
+ The PropertyEditor concept is part of the JavaBeans specification, and is also explained in this chapter.
+ Spring 3 introduces a "core.convert" package that provides a general type conversion facility, as well as a higher-level "format" package for formatting UI field values.
+ These new packages may be used as simpler alternatives to PropertyEditors, and will also be discussed in this chapter.
+
@@ -749,4 +748,320 @@ public final class CustomPropertyEditorRegistrar implements PropertyEditorRegist
+
+ Spring 3 Type Conversion
+
+ Spring 3 introduces a core.convert package that provides a general type conversion system.
+ The system defines a SPI to implement type conversion logic, as well as a API to execute type conversions at runtime.
+ Within a Spring container, if configured, this system can be used as an alternative to PropertyEditors to convert externalized bean property value strings to required property types.
+ The public API may also be used anywhere in your application where type coersion is needed.
+
+
+ Converter SPI
+
+ The SPI to implement type conversion logic is simple and strongly typed:
+
+ {
+ T convert(S source) throws Exception;
+}]]>
+
+
+ To create your own Converter, simply implement the Converter interface.
+ Parameterize S as the type you are converting from, and T as the type you are converting to.
+ For each call to convert(S), the source argument is guaranteed to be NOT null.
+ Your Converter may throw any Exception if conversion fails.
+ An IllegalArgumentException is often thrown to report an invalid source value.
+ Take special care to ensure your Converter implementation is thread safe.
+
+
+ Several converter implementations are provided in the core.convert.converters package as a convenience.
+ These include converters to from String to Numbers and other common types.
+ Note StringToInteger as an example Converter implementation:
+
+ {
+ public Integer convert(String source) {
+ return Integer.valueOf(source);
+ }
+}]]>
+
+
+
+ ConversionService API
+
+ The ConversionService defines a public API for executing type conversion logic at runtime.
+ Converters are always executed behind this API.
+ User code should not depend on the Converter SPI.
+
+ sourceType, Class> targetType);
+
+ T convert(Object source, Class targetType);
+
+}]]>
+
+
+ Most ConversionService implementations also implement ConverterRegistry, which provides a SPI for registering converters.
+ Internally, a ConversionService implementation delegates to its registered Converters to carry out type conversion logic.
+
+
+ Two ConversionService implementations are provided with the system in the core.convert.support package.
+ GenericConversionService is a generic implementation designed to be explicitly configured, either programatically or declaratively as a Spring bean.
+ DefaultConversionService is a subclass that pre-registers the common Converters in the core.converter package as a convenience.
+
+
+
+ Configuring a ConversionService
+
+ A ConversionService is a stateless object designed to be instantiated on application startup, then shared between multiple threads.
+ In a Spring application, you typically configure a ConversionService instance per Spring container (or ApplicationContext).
+ That ConversionService will be picked up by Spring and then used whenever a type conversion needs to be performed by the framework.
+ You may also inject this ConversionService into any of your beans and invoke it directly.
+ If no ConversionService is registered with Spring, the original PropertyEditor-based system is used.
+
+
+ To register the DefaultConversionService with Spring, simply configure it as a bean with the id conversionService:
+
+ ]]>
+
+
+ To override the default converter set with your own custom converter(s), set the converters property:
+
+
+
+
+
+
+
+]]>
+
+
+
+ Using a ConversionService programatically
+
+ To work with a ConversionService instance programatically, simply inject a reference to it like you would any other bean:
+
+
+
+
+
+
+
+