|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.beans.factory.config.CustomEditorConfigurer
public class CustomEditorConfigurer
BeanFactoryPostProcessor
implementation that allows for convenient
registration of custom property editors
.
As of Spring 2.0, the recommended usage is to use custom
PropertyEditorRegistrar
implementations that in turn register
any desired editors 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>
Alternative configuration example with custom editor instances,
assuming inner beans for PropertyEditor
instances:
<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer"> <property name="customEditors"> <map> <entry key="java.util.Date"> <bean class="mypackage.MyCustomDateEditor"/> </entry> <entry key="mypackage.MyObject"> <bean id="myEditor" class="mypackage.MyObjectEditor"> <property name="myParam"><value>myValue</value></property> </bean> </entry> </map> </property> </bean>
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
,
ConfigurableBeanFactory.addPropertyEditorRegistrar(org.springframework.beans.PropertyEditorRegistrar)
,
ConfigurableBeanFactory.registerCustomEditor(java.lang.Class, java.beans.PropertyEditor)
,
DataBinder.registerCustomEditor(java.lang.Class, java.beans.PropertyEditor)
,
BaseCommandController.setPropertyEditorRegistrars(org.springframework.beans.PropertyEditorRegistrar[])
,
BaseCommandController.initBinder(javax.servlet.http.HttpServletRequest, org.springframework.web.bind.ServletRequestDataBinder)
Field Summary |
---|
Fields inherited from interface org.springframework.core.Ordered |
---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
Constructor Summary | |
---|---|
CustomEditorConfigurer()
|
Method Summary | |
---|---|
int |
getOrder()
Return the order value of this object, with a higher value meaning greater in terms of sorting. |
void |
postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
Modify the application context's internal bean factory after its standard initialization. |
void |
setBeanClassLoader(ClassLoader beanClassLoader)
Callback that supplies the bean class loader to
a bean instance. |
void |
setCustomEditors(Map customEditors)
Specify the custom editors to register via a Map , using the
class name of the required type as the key and the PropertyEditor
instance as the value. |
void |
setOrder(int order)
|
void |
setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars)
Specify the PropertyEditorRegistrars
to apply to beans defined within the current application context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CustomEditorConfigurer()
Method Detail |
---|
public void setOrder(int order)
public int getOrder()
Ordered
Normally starting with 0 or 1, with Ordered.LOWEST_PRECEDENCE
indicating greatest. Same order values will result in arbitrary
positions for the affected objects.
Higher value can be interpreted as lower priority, consequently the first object has highest priority (somewhat analogous to Servlet "load-on-startup" values).
Note that order values below 0 are reserved for framework purposes. Application-specified values should always be 0 or greater, with only framework components (internal or third-party) supposed to use lower values.
Ordered.LOWEST_PRECEDENCE
public void setPropertyEditorRegistrars(PropertyEditorRegistrar[] propertyEditorRegistrars)
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.
public void setCustomEditors(Map customEditors)
Map
, using the
class name of the required type as the key and the PropertyEditor
instance as the value.
customEditors
- said Map
of editors (can be null
)ConfigurableBeanFactory.registerCustomEditor(java.lang.Class, java.beans.PropertyEditor)
public void setBeanClassLoader(ClassLoader beanClassLoader)
BeanClassLoaderAware
class loader
to
a bean instance.
Invoked after the population of normal bean properties but
before an initialization callback such as
InitializingBean's
InitializingBean.afterPropertiesSet()
method or a custom init-method.
setBeanClassLoader
in interface BeanClassLoaderAware
beanClassLoader
- the owning class loader; may be null
in
which case a default ClassLoader
must be used, for example
the ClassLoader
obtained via
ClassUtils.getDefaultClassLoader()
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
BeanFactoryPostProcessor
postProcessBeanFactory
in interface BeanFactoryPostProcessor
beanFactory
- the bean factory used by the application context
BeansException
- in case of errors
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |