java.lang.Object | |
↳ | org.springframework.beans.factory.config.CustomEditorConfigurer |
BeanFactoryPostProcessor
implementation that allows for convenient
registration of custom PropertyEditor 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 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
PropertyEditor
s, 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 DataBinder
:
Use a common base class or delegate to common PropertyEditorRegistrar
implementations to reuse editor registration there.
PropertyEditor
PropertyEditorRegistrar
addPropertyEditorRegistrar(PropertyEditorRegistrar)
registerCustomEditor(Class>, Class extends PropertyEditor>)
registerCustomEditor(Class, PropertyEditor)
setPropertyEditorRegistrars(PropertyEditorRegistrar[])
initBinder(HttpServletRequest, ServletRequestDataBinder)
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
org.springframework.core.Ordered
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
logger |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return the order value of this object, with a
higher value meaning greater in terms of sorting.
| |||||||||||
Modify the application context's internal bean factory after its standard
initialization.
| |||||||||||
Callback that supplies the bean
class loader to
a bean instance. | |||||||||||
Specify the custom editors to register via a
Map , using the
class name of the required type as the key and the class name of the
associated PropertyEditor as value. | |||||||||||
Set whether unresolvable editors should simply be skipped.
| |||||||||||
Specify the
PropertyEditorRegistrars
to apply to beans defined within the current application context. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.BeanClassLoaderAware
| |||||||||||
From interface
org.springframework.beans.factory.config.BeanFactoryPostProcessor
| |||||||||||
From interface
org.springframework.core.Ordered
|
Return the order value of this object, with a higher value meaning greater in terms of sorting.
Normally starting with 0, with Integer.MAX_VALUE
indicating the greatest value. Same order values will result
in arbitrary positions for the affected objects.
Higher values can be interpreted as lower priority. As a consequence, the object with the lowest value has highest priority (somewhat analogous to Servlet "load-on-startup" values).
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.
beanFactory | the bean factory used by the application context |
---|
BeansException |
---|
Callback that supplies the bean class loader
to
a bean instance.
Invoked after the population of normal bean properties but
before an initialization callback such as
InitializingBean's
afterPropertiesSet()
method or a custom init-method.
beanClassLoader | the owning class loader; may be null in
which case a default ClassLoader must be used, for example
the ClassLoader obtained via
getDefaultClassLoader()
|
---|
Specify the custom editors to register via a Map
, using the
class name of the required type as the key and the class name of the
associated PropertyEditor
as value.
Also supports PropertyEditor
instances as values; however,
this is deprecated since Spring 2.0.7!
Set whether unresolvable editors should simply be skipped. Default is to raise an exception in such a case.
This typically applies to either the editor class or the required type class not being found in the classpath. If you expect this to happen in some deployments and prefer to simply ignore the affected editors, then switch this flag to "true".
Specify the PropertyEditorRegistrars
to apply to beans defined within the current application context.
This allows for sharing PropertyEditorRegistrars
with
DataBinders
, etc.
Furthermore, it avoids the need for synchronization on custom editors:
A PropertyEditorRegistrar
will always create fresh editor
instances for each bean creation attempt.