Customeditorconfigurer in the Mina configuration

Source: Internet
Author: User

Customeditorconfigurer in the Mina configuration

The beautiful Life of the Sun Vulcan (http://blog.csdn.net/opengl_es)

This article follows "Attribution-non-commercial use-consistent" authoring public agreement

Reprint Please keep this sentence: Sun Vulcan's Beautiful Life-this blog focuses on Agile development and mobile and IoT device research: IOS, Android, HTML5, Arduino, Pcduino , Otherwise, the article from this blog refused to reprint or re-reproduced, thank you for your cooperation.


Recent analysis of a Mina practical application system, found in the Spring Dependency injection configuration file Customeditorconfigurer is not used by any address to assemble, but to remove it, will be error, indicating that the address of the string can not be converted to Inetsocketaddress Address:

<!--This section is implicitly used by Niosocketacceptor, without which it is reported that the string cannot be converted to inetsocketaddress--><bean id= "Customeditorconfigurer" class= "Org.springframework.beans.factory.config.CustomEditorConfigurer" ><property name= "Customeditors" >< Map><entry key= "java.net.SocketAddress" value= "Org.apache.mina.integration.beans.InetSocketAddressEditor"/ ></map></property></bean>

It can be thought that the conversion from string to SocketAddress will try to use the custom property editor.


The use of the specific property editor, but also need to further study, temporarily only know that it can be converted.



Check the Spring official documentation for the following Customeditorconfigurer class descriptions:

Org.springframework.beans.factory.configClass Customeditorconfigurer

    • Java.lang.Object
      • Org.springframework.beans.factory.config.CustomEditorConfigurer
  • All implemented Interfaces:
    beanfactorypostprocessor, Ordered

    customeditorconfigurerextends objectimplements beanfactorypostprocessor, Ordered
    BeanFactoryPostProcessor 接口的实现,它允许方便地注册自定义的 属性编辑器 。
    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 are 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> 

    Preferably by attribute     customeditors register     propertyeditor class. Spring creates an entirely new instance of the class for each edit intent:
    It's perfectly fine to register   propertyeditor   classes   via the   customeditors   property. Spring would 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>   

    Note that you cannot use properties to register the property editor in the following situations:
    Note, that's you shouldn ' t register PropertyEditor Bean instances via the customEditors property as PropertyEditorS is stateful and the instances would then has to be synchronized for every editing attempt. Need control over the instantiation process of PropertyEditors, use aPropertyEditorRegistrar To register them.

    Also supports "java.lang.string[]"-style array class names and primitive class names (e.g. "Boolean"). Delegates to for ClassUtils actual class name resolution.

    Note: Custom Property editors registered with this configurer does not apply to data binding. Custom editors for data binding need to being registered on the: use DataBinder a common base class or delegate to Commo n Propertyeditorregistrar implementations to reuse editor registration there.

    Since:
    27.02.2004
    Author:
    Juergen Hoeller
    See Also:
    PropertyEditor,   PropertyEditorRegistrar,   ConfigurableBeanFactory.addPropertyEditorRegistrar(org.springframework.beans.PropertyEditorRegistrar),   ConfigurableBeanFactory.registerCustomEditor(java.lang.Class<?>, java.lang.Class<? extends java.beans.PropertyEditor>), DataBinder.registerCustomEditor(java.lang.Class<?>, java.beans.PropertyEditor)











Customeditorconfigurer in the Mina configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.