Example usage for org.springframework.core.convert.support ConversionServiceFactory registerConverters

List of usage examples for org.springframework.core.convert.support ConversionServiceFactory registerConverters

Introduction

In this page you can find the example usage for org.springframework.core.convert.support ConversionServiceFactory registerConverters.

Prototype

public static void registerConverters(@Nullable Set<?> converters, ConverterRegistry registry) 

Source Link

Document

Register the given Converter objects with the given target ConverterRegistry.

Usage

From source file:com.asual.summer.core.spring.ConversionDiscoveryFactoryBean.java

@SuppressWarnings("rawtypes")
public ConversionService getObject() {
    ConversionService conversionService = super.getObject();
    if (conversionService instanceof ConverterRegistry) {
        ConverterRegistry registry = (ConverterRegistry) conversionService;
        if (cachedConverters == null) {
            cachedConverters = BeanUtils.getBeansOfType(Converter.class);
            ConversionServiceFactory.registerConverters(new LinkedHashSet<Converter>(cachedConverters.values()),
                    registry);//from ww  w.  j  a  v  a  2  s  .c  o  m
        }
    }
    return conversionService;
}

From source file:org.web4thejob.util.converter.MyConversionServiceFactoryBean.java

@SuppressWarnings("rawtypes")
@Override//from w  w  w  .j a  v a2  s  .co  m
public void afterPropertiesSet() throws Exception {
    this.conversionService = createConversionService();
    // ConversionServiceFactory.addDefaultConverters(this.conversionService);

    Set<Converter> customConverters = new HashSet<Converter>(3);
    customConverters.add(new StringToClassConverter());
    customConverters.add(new ClassToStringConverter());
    customConverters.add(new EntityToStringConverter());
    ConversionServiceFactory.registerConverters(customConverters, this.conversionService);
}

From source file:com.timeline.vpn.web.common.MyFormattingConversionServiceFactoryBean.java

@Override
public void afterPropertiesSet() {
    this.conversionService = new MyFormattingConversionService(this.embeddedValueResolver,
            this.registerDefaultFormatters);
    ConversionServiceFactory.registerConverters(this.converters, this.conversionService);
    registerFormatters();//from ww w . j  a v  a2s .c o  m
}