SPR-7311 - Clarify usage of PropertyEditorRegistrars VS. plain configuration of customEditors property in CustomEditorConfigurer JavaDoc.
This commit is contained in:
@@ -35,13 +35,15 @@ import org.springframework.util.ClassUtils;
|
||||
/**
|
||||
* {@link BeanFactoryPostProcessor} implementation that allows for convenient
|
||||
* registration of custom {@link PropertyEditor property editors}.
|
||||
*
|
||||
* <p>As of Spring 2.0, the recommended usage is to use custom
|
||||
* {@link PropertyEditorRegistrar} implementations that in turn register
|
||||
* any desired editors on a given
|
||||
* {@link org.springframework.beans.PropertyEditorRegistry registry}.
|
||||
* Each PropertyEditorRegistrar can register any number of custom editors.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* In case you want to register {@link PropertyEditor} instances, the
|
||||
* recommended usage as of Spring 2.0 is to use custom
|
||||
* {@link PropertyEditorRegistrar} implementations that in turn register any
|
||||
* desired editor instances on a given
|
||||
* {@link org.springframework.beans.PropertyEditorRegistry registry}. Each
|
||||
* PropertyEditorRegistrar can register any number of custom editors.
|
||||
*
|
||||
* <pre class="code">
|
||||
* <bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
|
||||
* <property name="propertyEditorRegistrars">
|
||||
@@ -50,10 +52,14 @@ import org.springframework.util.ClassUtils;
|
||||
* <bean class="mypackage.MyObjectEditorRegistrar"/>
|
||||
* </list>
|
||||
* </property>
|
||||
* </bean></pre>
|
||||
*
|
||||
* <p>Alternative configuration example with custom editor classes:
|
||||
*
|
||||
* </bean>
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
* It's perfectly fine to register {@link PropertyEditor} <em>classes</em> via
|
||||
* the {@code customEditors} property. Spring will create fresh instances of
|
||||
* them for each editing attempt then:
|
||||
*
|
||||
* <pre class="code">
|
||||
* <bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
|
||||
* <property name="customEditors">
|
||||
@@ -62,9 +68,19 @@ import org.springframework.util.ClassUtils;
|
||||
* <entry key="mypackage.MyObject" value="mypackage.MyObjectEditor"/>
|
||||
* </map>
|
||||
* </property>
|
||||
* </bean></pre>
|
||||
*
|
||||
* <p>Also supports "java.lang.String[]"-style array class names and primitive
|
||||
* </bean>
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
* Note, that you shouldn't register {@link PropertyEditor} bean instances via
|
||||
* the {@code customEditors} property as {@link PropertyEditor}s are stateful
|
||||
* and the instances will then have to be synchronized for every editing
|
||||
* attempt. In case you need control over the instantiation process of
|
||||
* {@link PropertyEditor}s, use a {@link PropertyEditorRegistrar} to register
|
||||
* them.
|
||||
*
|
||||
* <p>
|
||||
* Also supports "java.lang.String[]"-style array class names and primitive
|
||||
* class names (e.g. "boolean"). Delegates to {@link ClassUtils} for actual
|
||||
* class name resolution.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user