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

MongoBeanDefinitionRegistrar.java 文件源码 项目:lodsve-framework 阅读 47 收藏 0 点赞 0 评论 0
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;
}
SpringContextUtil.java 文件源码 项目:FoDBugTrackerUtility 阅读 85 收藏 0 点赞 0 评论 0
/**
 * 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;
}
FXmain.java 文件源码 项目:bd-codes 阅读 28 收藏 0 点赞 0 评论 0
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());
}
ApplicationConfiguration.java 文件源码 项目:GMM 阅读 30 收藏 0 点赞 0 评论 0
/**
 * @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;
}
DefaultsBeanDefinitionParser.java 文件源码 项目:jdal 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 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;
}
DefaultsBeanDefinitionParser.java 文件源码 项目:jdal 阅读 33 收藏 0 点赞 0 评论 0
/**
 * @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;
}


问题


面经


文章

微信
公众号

扫码关注公众号