Java 类org.springframework.beans.factory.config.CustomEditorConfigurer 实例源码

项目:lodsve-framework    文件:MongoBeanDefinitionRegistrar.java   
private BeanDefinitionBuilder getWriteConcernPropertyEditorBuilder() {
    Map<String, Class<?>> customEditors = new ManagedMap<>();
    customEditors.put("com.mongodb.WriteConcern", WriteConcernPropertyEditor.class);

    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CustomEditorConfigurer.class);
    builder.addPropertyValue("customEditors", customEditors);

    return builder;
}
项目:FoDBugTrackerUtility    文件:SpringContextUtil.java   
/**
 * Get a basic Spring {@link GenericApplicationContext} with additional 
 * custom editors registered. The additional custom editors are automatically
 * loaded from com.fortify.util.spring.propertyeditor (sub-)packages
 * if they have the {@link Component} annotation.
 * @return Basic Spring ApplicationContext with custom editors registered.
 */
public static final GenericApplicationContext getBaseContext() {
    GenericApplicationContext context = new GenericApplicationContext();
    context.setClassLoader(SpringContextUtil.class.getClassLoader());

    CustomEditorConfigurer cec = new CustomEditorConfigurer();
    cec.setCustomEditors(PROPERTY_EDITORS);
    context.addBeanFactoryPostProcessor(cec);
    return context;
}
项目:bd-codes    文件:FXmain.java   
public static void iocStart() {
    // BeanFactory方式启动
    ConfigurableListableBeanFactory beanFactory = new XmlBeanFactory(
            new ClassPathResource("spring.xml"));

    // 读取外部properties文件属性值填充xml中的bean,property
    PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer();
    propertyPlaceholderConfigurer.setLocation(new ClassPathResource(
            "config.properties"));
    // 应用postProcessBeanFactory
    propertyPlaceholderConfigurer.postProcessBeanFactory(beanFactory);

    // 读取外部properties文件,覆盖xml中bean指定的property值
    PropertyOverrideConfigurer propertyOverrideConfigurer = new PropertyOverrideConfigurer();
    propertyOverrideConfigurer.setLocation(new ClassPathResource(
            "spring-adjustment.properties"));
    propertyOverrideConfigurer.postProcessBeanFactory(beanFactory);

    // CustomEditorConfigurer,对bean的property值,做类型转换支持
    CustomEditorConfigurer customEditorConfigurer = new CustomEditorConfigurer();
    Map customEditors = new HashMap();
    customEditors.put(Date.class, new DatePropertyEditor());
    customEditorConfigurer.setCustomEditors(customEditors);
    customEditorConfigurer.postProcessBeanFactory(beanFactory);

    FXNewsProvider newsProvider = (FXNewsProvider) beanFactory
            .getBean("newsProvider");
    System.out.println(newsProvider.getClientId());
    System.out.println(newsProvider.getBaseUrl());
    System.out.println(newsProvider.getAddDate().toLocaleString());
}
项目:GMM    文件:ApplicationConfiguration.java   
/**
 * @Value Path converter
 */
@Bean
public static CustomEditorConfigurer editorConfigurer() {
    final CustomEditorConfigurer conf = new CustomEditorConfigurer();
    final Map<Class<?>, Class<? extends PropertyEditor>>  map = new HashMap<>();

    map.put(Path.class, PathEditor.class);

    conf.setCustomEditors(map);
    return conf;
}
项目:jdal    文件:DefaultsBeanDefinitionParser.java   
/**
 * Register default CustomEditorConfigurer
 * @return default CustomEditorComfigurer ComponentDefinition
 */
private ComponentDefinition registerPropertyEditors(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder bdb = BeanDefinitionBuilder.genericBeanDefinition(
            CustomEditorConfigurer.class);
    Map<String, String> map = new HashMap<String, String>();
    map.put("com.vaadin.server.Resource", "org.jdal.vaadin.beans.VaadinResourcePropertyEditor");
    bdb.addPropertyValue("customEditors", map);
    BeanComponentDefinition bcd = new BeanComponentDefinition(bdb.getBeanDefinition(), 
            CUSTOM_EDITOR_CONFIGURER_BEAN_NAME);
    registerBeanComponentDefinition(element, parserContext, bcd);
    return bcd;
}
项目:jdal    文件:DefaultsBeanDefinitionParser.java   
/**
 * @return
 */
private ComponentDefinition registerPropertyEditors(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder bdb = BeanDefinitionBuilder.genericBeanDefinition(
            CustomEditorConfigurer.class);
    Map<String, String> map = new HashMap<String, String>();
    map.put("java.awt.Image", "org.jdal.beans.ImagePropertyEditor");
    map.put("javax.swing.Icon", "org.jdal.beans.IconPropertyEditor");
    bdb.addPropertyValue("customEditors", map);
    BeanComponentDefinition bcd = new BeanComponentDefinition(bdb.getBeanDefinition(), 
            CUSTOM_EDITOR_CONFIGURER_BEAN_NAME);
    registerBeanComponentDefinition(element, parserContext, bcd);
    return bcd;
}