BeanFactoryPostProcessor implementation that allows for convenient
registration of custom property editors.
In case you want to register PropertyEditor instances,
the recommended usage as of Spring 2.0 is to use custom
PropertyEditorRegistrar implementations that in turn register any
desired editor instances on a given
registry. Each
PropertyEditorRegistrar can register any number of custom editors.
<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="propertyEditorRegistrars">
<list>
<bean class="mypackage.MyCustomDateEditorRegistrar"/>
<bean class="mypackage.MyObjectEditorRegistrar"/>
</list>
</property>
</bean>
It's perfectly fine to register PropertyEditor classes via
the customEditors property. Spring will create fresh instances of
them for each editing attempt then:
<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.util.Date" value="mypackage.MyCustomDateEditor"/>
<entry key="mypackage.MyObject" value="mypackage.MyObjectEditor"/>
</map>
</property>
</bean>
Note, that you shouldn't register PropertyEditor bean instances via
the customEditors property as PropertyEditors 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
PropertyEditors, use a PropertyEditorRegistrar to register
them.
Also supports "java.lang.String[]"-style array class names and primitive
class names (e.g. "boolean"). Delegates to ClassUtils for actual
class name resolution.
Note
Custom property editors registered with this configurer do
not apply to data binding. Custom editors for data binding need to
be registered on the org.:
Use a common base class or delegate to common PropertyEditorRegistrar
implementations to reuse editor registration there.
java.beans.PropertyEditor , org.springframework.beans.PropertyEditorRegistrar , ConfigurableBeanFactory#addPropertyEditorRegistrar, ConfigurableBeanFactory#registerCustomEditor, org.springframework.validation.DataBinder#registerCustomEditor
| Modifier and Type | Field and Description |
|---|---|
| private Map | |
| protected final Log | |
| private int | |
| private PropertyEditorRegistrar[] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public int | |
| public void | postProcessBeanFactory(ConfigurableListableBeanFactory
the bean factory used by the application context beanFactory)Implements org. |
| public void | setCustomEditors(Map<Class<?>, Class<? extends PropertyEditor>> customEditors)
Specify the custom editors to register via a |
| public void | |
| public void | setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars)
Specify the |
| customEditors | back to summary |
|---|---|
| private Map<Class<?>, Class<? extends PropertyEditor>> customEditors
| |
| logger | back to summary |
|---|---|
| protected final Log logger | |
| order | back to summary |
|---|---|
| private int order | |
| propertyEditorRegistrars | back to summary |
|---|---|
| private PropertyEditorRegistrar[] propertyEditorRegistrars
| |
| CustomEditorConfigurer | back to summary |
|---|---|
| public CustomEditorConfigurer() | |
| getOrder | back to summary |
|---|---|
| public int getOrder() Implements org. Doc from org. Get the order value of this object. Higher values are interpreted as lower priority. As a consequence,
the object with the lowest value has the highest priority (somewhat
analogous to Servlet Same order values will result in arbitrary sort positions for the affected objects.
| |
| postProcessBeanFactory | back to summary |
|---|---|
| public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException Implements org. Doc from org. Modify the application context's internal bean factory after its standard initialization. All bean definitions will have been loaded, but no beans will have been instantiated yet. This allows for overriding or adding properties even to eager-initializing beans.
| |
| setCustomEditors | back to summary |
|---|---|
| public void setCustomEditors(Map<Class<?>, Class<? extends PropertyEditor>> customEditors) Specify the custom editors to register via a | |
| setOrder | back to summary |
|---|---|
| public void setOrder(int order) | |
| setPropertyEditorRegistrars | back to summary |
|---|---|
| public void setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars) Specify the This allows for sharing | |