Java 类org.springframework.context.support.ConversionServiceFactoryBean 实例源码

项目:opencucina    文件:ClientApplication.java   
private ConversionService conversionService(ApplicationContext applicationContext) {
    // TODO should be also able to resolve a url to a bean/method
    BeanFactoryResolver beanResolver = new BeanFactoryResolver(applicationContext) {
        @Override
        public Object resolve(EvaluationContext context, String beanName)
                throws AccessException {
            return super.resolve(context,
                    (beanName.startsWith("bean:") ? beanName.substring("bean:".length())
                            : beanName));
        }
    };

    ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
    Set<Converter<?, ?>> cons = new HashSet<Converter<?, ?>>();

    cons.add(new DtoCheckConverter(beanResolver));
    cons.add(new DtoOperationConverter(beanResolver));
    factoryBean.setConverters(cons);
    factoryBean.afterPropertiesSet();

    return factoryBean.getObject();
}
项目:winlet    文件:DaoFactoryBean.java   
/**
 * get ConversionService. If a service is defined in context with name
 * daoConversionService then use it, otherwise create a default one
 * 
 * @return
 */
private ConversionService getConversionService() {
    if (conversionService != null)
        return conversionService;

    try {
        conversionService = (ConversionService) ctx
                .getBean("daoConversionService");
        if (conversionService != null)
            return conversionService;
    } catch (Exception e) {
    }

    ConversionServiceFactoryBean factory = new ConversionServiceFactoryBean();
    factory.afterPropertiesSet();
    conversionService = factory.getObject();
    return conversionService;
}
项目:state-channels    文件:PropertyConvertersConfig.java   
@Bean(name="conversionService")
public ConversionServiceFactoryBean getConversionService() {
    ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean();

    Set<Converter> converters = new HashSet<>();

    converters.add(new DurationConverter());
    converters.add(new AddressConverter());

    bean.setConverters(converters);
    return bean;
}
项目:opencucina    文件:SecurityApplication.java   
/**
 *
 *
 * @return .
 */
@Bean
public ConversionService myConversionService(UserRepository userRepository) {
    ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean();

    bean.setConverters(getConverters(userRepository));
    bean.afterPropertiesSet();

    return bean.getObject();
}
项目:opencucina    文件:ProcessConfiguration.java   
@Bean
public ConversionService myConversionService() {
    ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
    Set<Converter<?, ?>> cons = new HashSet<Converter<?, ?>>();

    cons.add(new CheckDtoConverter());
    cons.add(new OperationDtoConverter());
    cons.add(new HistoryRecordDtoConverter());
    factoryBean.setConverters(cons);
    factoryBean.afterPropertiesSet();

    return factoryBean.getObject();
}
项目:opencucina    文件:I18nApplication.java   
/**
 * JAVADOC Method Level Comments
 *
 * @return JAVADOC.
 */
@Bean
public ConversionService myConversionService(MessageRepository messageRepository,
    I18nService i18nService) {
    ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean();

    bean.setConverters(getConverters(messageRepository, i18nService));
    bean.afterPropertiesSet();

    return bean.getObject();
}
项目:eMonocot    文件:ConversionServiceTest.java   
/**
 *
 */
@Before
public final void setUp() {
    Set<Converter> converters = new HashSet<Converter>();
    ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
    converters.add(new TaxonomicStatusConverter());
    factoryBean.setConverters(converters);
    factoryBean.afterPropertiesSet();
    conversionService = factoryBean.getObject();
}
项目:powop    文件:ConversionServiceTest.java   
/**
 *
 */
@Before
public final void setUp() {
    Set<Converter> converters = new HashSet<Converter>();
    ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
    converters.add(new TaxonomicStatusConverter());
    factoryBean.setConverters(converters);
    factoryBean.afterPropertiesSet();
    conversionService = factoryBean.getObject();
}
项目:boot-camper    文件:ConversionConfiguration.java   
@Bean
public ConversionService conversionService()
{
    ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean();
    bean.setConverters(getConverters());
    bean.afterPropertiesSet();
    return bean.getObject();
}
项目:SocialDataImporter    文件:ConversionServiceProvider.java   
@Bean
public ConversionService getConversionService()
{
    ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean();
    bean.setConverters( getConverters() );
    bean.afterPropertiesSet();
    ConversionService object = bean.getObject();
    return object;
}
项目:eMonocot    文件:TaxonParsingTest.java   
@Before
public final void setUp() throws Exception {
    String[] names = new String[] {
            "http://rs.tdwg.org/dwc/terms/taxonID",
            "http://rs.tdwg.org/dwc/terms/scientificName",
            "http://rs.tdwg.org/dwc/terms/scientificNameID",
            "http://rs.tdwg.org/dwc/terms/scientificNameAuthorship",
            "http://rs.tdwg.org/dwc/terms/taxonRank",
            "http://rs.tdwg.org/dwc/terms/taxonomicStatus",
            "http://rs.tdwg.org/dwc/terms/parentNameUsageID",
            "http://rs.tdwg.org/dwc/terms/acceptedNameUsageID",
            "http://rs.tdwg.org/dwc/terms/genus",
            "http://rs.tdwg.org/dwc/terms/subgenus",
            "http://rs.tdwg.org/dwc/terms/specificEpithet",
            "http://rs.tdwg.org/dwc/terms/infraspecificEpithet",
            "http://rs.tdwg.org/dwc/terms/nomenclaturalStatus",
            "http://purl.org/dc/terms/modified",
            "http://purl.org/dc/terms/source"
    };
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    tokenizer.setDelimiter('\t');
    tokenizer.setNames(names);

    taxonService = EasyMock.createMock(TaxonService.class);
    Set<Converter> converters = new HashSet<Converter>();
    converters.add(new StringToIsoDateTimeConverter());
    converters.add(new TaxonomicStatusConverter());
    converters.add(new RankConverter());
    converters.add(new NomenclaturalStatusConverter());

    ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
    factoryBean.setConverters(converters);
    factoryBean.afterPropertiesSet();
    ConversionService conversionService = factoryBean.getObject();

    FieldSetMapper fieldSetMapper = new FieldSetMapper();
    fieldSetMapper.setFieldNames(names);
    fieldSetMapper.setDefaultValues(new HashMap<String, String>());
    fieldSetMapper.setConversionService(conversionService);
    DefaultLineMapper<Taxon> lineMapper
    = new DefaultLineMapper<Taxon>();
    lineMapper.setFieldSetMapper(fieldSetMapper);
    lineMapper.setLineTokenizer(tokenizer);

    flatFileItemReader.setEncoding("UTF-8");
    flatFileItemReader.setLinesToSkip(0);
    flatFileItemReader.setResource(content);
    flatFileItemReader.setLineMapper(lineMapper);
    flatFileItemReader.afterPropertiesSet();
}
项目:eMonocot    文件:ScratchpadExportTaxonParsingTest.java   
/**
 *
 */
@Before
public final void setUp() throws Exception {
    String[] names = new String[] {
            "http://rs.tdwg.org/dwc/terms/taxonID",
            "http://rs.tdwg.org/dwc/terms/scientificName",
            "http://rs.tdwg.org/dwc/terms/vernacularName",
            "http://rs.tdwg.org/dwc/terms/taxonomicStatus",
            "http://rs.tdwg.org/dwc/terms/taxonRank",
            "http://rs.tdwg.org/dwc/terms/scientificNameAuthorship",
            "http://purl.org/dc/terms/bibliographicCitation",
            "http://rs.tdwg.org/dwc/terms/parentNameUsageID"
    };
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    tokenizer.setDelimiter(',');
    tokenizer.setQuoteCharacter('\"');
    tokenizer.setNames(names);
    Set<Converter> converters = new HashSet<Converter>();
    converters.add(new TaxonomicStatusConverter());
    converters.add(new RankConverter());

    ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
    factoryBean.setConverters(converters);
    factoryBean.afterPropertiesSet();
    ConversionService conversionService = factoryBean.getObject();

    taxonService = EasyMock.createMock(TaxonService.class);

    FieldSetMapper fieldSetMapper = new FieldSetMapper();
    fieldSetMapper.setConversionService(conversionService);
    fieldSetMapper.setFieldNames(names);
    fieldSetMapper.setDefaultValues(new HashMap<String, String>());
    DefaultLineMapper<Taxon> lineMapper
    = new DefaultLineMapper<Taxon>();
    lineMapper.setFieldSetMapper(fieldSetMapper);
    lineMapper.setLineTokenizer(tokenizer);

    flatFileItemReader.setEncoding("UTF-8");
    flatFileItemReader.setLinesToSkip(0);
    flatFileItemReader.setResource(content);
    flatFileItemReader.setLineMapper(lineMapper);
    flatFileItemReader.afterPropertiesSet();
}
项目:eMonocot    文件:ReferenceParsingTest.java   
/**
 * @throws Exception if there is a problem
 */
@Before
public final void setUp() throws Exception {

    String[] names = new String[] {
            "http://rs.tdwg.org/dwc/terms/taxonID",
            "http://purl.org/dc/terms/modified",
            "http://purl.org/dc/terms/created",
            "http://purl.org/dc/terms/identifier",
            "http://purl.org/dc/terms/bibliographicCitation",
            "http://purl.org/dc/terms/type",
            "http://purl.org/dc/terms/title",
            "http://purl.org/ontology/bibo/volume",
            "http://purl.org/ontology/bibo/number",
            "http://purl.org/ontology/bibo/pages",
            "http://purl.org/dc/terms/description",
            "http://purl.org/dc/terms/date",
            "http://purl.org/dc/terms/source",
            "http://purl.org/dc/terms/creator"
    };
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    tokenizer.setDelimiter('\t');
    tokenizer.setNames(names);
    Set<Converter> converters = new HashSet<Converter>();
    converters.add(new ReferenceTypeConverter());
    converters.add(new StringToIsoDateTimeConverter());

    ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
    factoryBean.setConverters(converters);
    factoryBean.afterPropertiesSet();
    ConversionService conversionService = factoryBean.getObject();


    taxonService = EasyMock.createMock(TaxonService.class);

    FieldSetMapper fieldSetMapper = new FieldSetMapper();
    HtmlSanitizer htmlSanitizer = new HtmlSanitizer();
    htmlSanitizer.afterPropertiesSet();
    fieldSetMapper.setHtmlSanitizer(htmlSanitizer);
    fieldSetMapper.setFieldNames(names);
    fieldSetMapper.setConversionService(conversionService);
    fieldSetMapper.setDefaultValues(new HashMap<String, String>());
    fieldSetMapper.setTaxonService(taxonService);
    DefaultLineMapper<Reference> lineMapper
    = new DefaultLineMapper<Reference>();
    lineMapper.setFieldSetMapper(fieldSetMapper);
    lineMapper.setLineTokenizer(tokenizer);

    flatFileItemReader.setEncoding("UTF-8");
    flatFileItemReader.setLinesToSkip(0);
    flatFileItemReader.setResource(content);
    flatFileItemReader.setLineMapper(lineMapper);
    flatFileItemReader.afterPropertiesSet();
}
项目:eMonocot    文件:ScratchpadReferenceParsingTest.java   
/**
 * @throws Exception if there is a problem
 */
@Before
public final void setUp() throws Exception {

    String[] names = new String[] {
            "http://rs.tdwg.org/dwc/terms/taxonID",
            "http://purl.org/dc/terms/identifier",
            "",
            "http://purl.org/ontology/bibo/doi",
            "http://purl.org/ontology/bibo/isbn",
            "http://purl.org/ontology/bibo/issn",
            "",
            "",
            "http://purl.org/dc/terms/bibliographicCitation",
            "http://purl.org/dc/terms/title",
            "http://purl.org/dc/terms/creator",
            "http://purl.org/dc/terms/source",
            "http://purl.org/dc/terms/description",
            "http://purl.org/dc/terms/subject",
            "http://purl.org/dc/terms/language",
            "http://purl.org/dc/terms/type",
            "http://purl.org/dc/terms/date",
            "http://purl.org/dc/terms/created",
            "http://purl.org/dc/terms/modified"
    };
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    tokenizer.setDelimiter(',');
    tokenizer.setQuoteCharacter('"');
    tokenizer.setNames(names);

    taxonService = EasyMock.createMock(TaxonService.class);

    Set<Converter> converters = new HashSet<Converter>();
    converters.add(new ReferenceTypeConverter());
    converters.add(new StringToIsoDateTimeConverter());

    ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
    factoryBean.setConverters(converters);
    factoryBean.afterPropertiesSet();
    ConversionService conversionService = factoryBean.getObject();
    FieldSetMapper fieldSetMapper = new FieldSetMapper();
    HtmlSanitizer htmlSanitizer = new HtmlSanitizer();
    htmlSanitizer.afterPropertiesSet();
    fieldSetMapper.setHtmlSanitizer(htmlSanitizer);
    fieldSetMapper.setConversionService(conversionService);
    fieldSetMapper.setFieldNames(names);
    fieldSetMapper.setDefaultValues(new HashMap<String, String>());
    fieldSetMapper.setTaxonService(taxonService);
    DefaultLineMapper<Reference> lineMapper
    = new DefaultLineMapper<Reference>();
    lineMapper.setFieldSetMapper(fieldSetMapper);
    lineMapper.setLineTokenizer(tokenizer);

    flatFileItemReader.setEncoding("UTF-8");
    flatFileItemReader.setLinesToSkip(0);
    flatFileItemReader.setResource(content);
    flatFileItemReader.setLineMapper(lineMapper);
    flatFileItemReader.afterPropertiesSet();
}
项目:powop    文件:TaxonParsingTest.java   
@Before
public final void setUp() throws Exception {
    String[] names = new String[] {
            "http://rs.tdwg.org/dwc/terms/taxonID",
            "http://rs.tdwg.org/dwc/terms/scientificName",
            "http://rs.tdwg.org/dwc/terms/scientificNameID",
            "http://rs.tdwg.org/dwc/terms/scientificNameAuthorship",
            "http://rs.tdwg.org/dwc/terms/taxonRank",
            "http://rs.tdwg.org/dwc/terms/taxonomicStatus",
            "http://rs.tdwg.org/dwc/terms/parentNameUsageID",
            "http://rs.tdwg.org/dwc/terms/acceptedNameUsageID",
            "http://rs.tdwg.org/dwc/terms/genus",
            "http://rs.tdwg.org/dwc/terms/subgenus",
            "http://rs.tdwg.org/dwc/terms/specificEpithet",
            "http://rs.tdwg.org/dwc/terms/infraspecificEpithet",
            "http://rs.tdwg.org/dwc/terms/nomenclaturalStatus",
            "http://purl.org/dc/terms/modified",
            "http://purl.org/dc/terms/source"
    };
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    tokenizer.setDelimiter(DelimitedLineTokenizer.DELIMITER_TAB);
    tokenizer.setNames(names);

    taxonService = EasyMock.createMock(TaxonService.class);
    Set<Converter> converters = new HashSet<Converter>();
    converters.add(new StringToIsoDateTimeConverter());
    converters.add(new TaxonomicStatusConverter());
    converters.add(new RankConverter());
    converters.add(new NomenclaturalStatusConverter());

    ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
    factoryBean.setConverters(converters);
    factoryBean.afterPropertiesSet();
    ConversionService conversionService = factoryBean.getObject();

    FieldSetMapper fieldSetMapper = new FieldSetMapper();
    fieldSetMapper.setFieldNames(names);
    fieldSetMapper.setDefaultValues(new HashMap<String, String>());
    fieldSetMapper.setConversionService(conversionService);
    DefaultLineMapper<Taxon> lineMapper
    = new DefaultLineMapper<Taxon>();
    lineMapper.setFieldSetMapper(fieldSetMapper);
    lineMapper.setLineTokenizer(tokenizer);

    flatFileItemReader.setEncoding("UTF-8");
    flatFileItemReader.setLinesToSkip(0);
    flatFileItemReader.setResource(content);
    flatFileItemReader.setLineMapper(lineMapper);
    flatFileItemReader.afterPropertiesSet();
}
项目:powop    文件:ScratchpadExportTaxonParsingTest.java   
@Before
public final void setUp() throws Exception {
    String[] names = new String[] {
            "http://rs.tdwg.org/dwc/terms/taxonID",
            "http://rs.tdwg.org/dwc/terms/scientificName",
            "http://rs.tdwg.org/dwc/terms/vernacularName",
            "http://rs.tdwg.org/dwc/terms/taxonomicStatus",
            "http://rs.tdwg.org/dwc/terms/taxonRank",
            "http://rs.tdwg.org/dwc/terms/scientificNameAuthorship",
            "http://purl.org/dc/terms/bibliographicCitation",
            "http://rs.tdwg.org/dwc/terms/parentNameUsageID"
    };
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    tokenizer.setDelimiter(DelimitedLineTokenizer.DELIMITER_COMMA);
    tokenizer.setQuoteCharacter('\"');
    tokenizer.setNames(names);
    Set<Converter> converters = new HashSet<Converter>();
    converters.add(new TaxonomicStatusConverter());
    converters.add(new RankConverter());

    ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
    factoryBean.setConverters(converters);
    factoryBean.afterPropertiesSet();
    ConversionService conversionService = factoryBean.getObject();

    taxonService = EasyMock.createMock(TaxonService.class);

    FieldSetMapper fieldSetMapper = new FieldSetMapper();
    fieldSetMapper.setConversionService(conversionService);
    fieldSetMapper.setFieldNames(names);
    fieldSetMapper.setDefaultValues(new HashMap<String, String>());
    DefaultLineMapper<Taxon> lineMapper
    = new DefaultLineMapper<Taxon>();
    lineMapper.setFieldSetMapper(fieldSetMapper);
    lineMapper.setLineTokenizer(tokenizer);

    flatFileItemReader.setEncoding("UTF-8");
    flatFileItemReader.setLinesToSkip(0);
    flatFileItemReader.setResource(content);
    flatFileItemReader.setLineMapper(lineMapper);
    flatFileItemReader.afterPropertiesSet();
}
项目:powop    文件:ReferenceParsingTest.java   
@Before
public final void setUp() throws Exception {

    String[] names = new String[] {
            "http://rs.tdwg.org/dwc/terms/taxonID",
            "http://purl.org/dc/terms/modified",
            "http://purl.org/dc/terms/created",
            "http://purl.org/dc/terms/identifier",
            "http://purl.org/dc/terms/bibliographicCitation",
            "http://purl.org/dc/terms/type",
            "http://purl.org/dc/terms/title",
            "http://purl.org/ontology/bibo/volume",
            "http://purl.org/ontology/bibo/number",
            "http://purl.org/ontology/bibo/pages",
            "http://purl.org/dc/terms/description",
            "http://purl.org/dc/terms/date",
            "http://purl.org/dc/terms/source",
            "http://purl.org/dc/terms/creator"
    };
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    tokenizer.setDelimiter(DelimitedLineTokenizer.DELIMITER_TAB);
    tokenizer.setNames(names);
    Set<Converter> converters = new HashSet<Converter>();
    converters.add(new ReferenceTypeConverter());
    converters.add(new StringToIsoDateTimeConverter());

    ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
    factoryBean.setConverters(converters);
    factoryBean.afterPropertiesSet();
    ConversionService conversionService = factoryBean.getObject();

    taxonService = EasyMock.createMock(TaxonService.class);

    FieldSetMapper fieldSetMapper = new FieldSetMapper();
    fieldSetMapper.setFieldNames(names);
    fieldSetMapper.setConversionService(conversionService);
    fieldSetMapper.setDefaultValues(new HashMap<String, String>());
    fieldSetMapper.setTaxonService(taxonService);
    DefaultLineMapper<Reference> lineMapper
    = new DefaultLineMapper<Reference>();
    lineMapper.setFieldSetMapper(fieldSetMapper);
    lineMapper.setLineTokenizer(tokenizer);

    flatFileItemReader.setEncoding("UTF-8");
    flatFileItemReader.setLinesToSkip(0);
    flatFileItemReader.setResource(content);
    flatFileItemReader.setLineMapper(lineMapper);
    flatFileItemReader.afterPropertiesSet();
}
项目:powop    文件:ScratchpadReferenceParsingTest.java   
@Before
public final void setUp() throws Exception {

    String[] names = new String[] {
            "http://rs.tdwg.org/dwc/terms/taxonID",
            "http://purl.org/dc/terms/identifier",
            "",
            "http://purl.org/ontology/bibo/doi",
            "http://purl.org/ontology/bibo/isbn",
            "http://purl.org/ontology/bibo/issn",
            "",
            "",
            "http://purl.org/dc/terms/bibliographicCitation",
            "http://purl.org/dc/terms/title",
            "http://purl.org/dc/terms/creator",
            "http://purl.org/dc/terms/source",
            "http://purl.org/dc/terms/description",
            "http://purl.org/dc/terms/subject",
            "http://purl.org/dc/terms/language",
            "http://purl.org/dc/terms/type",
            "http://purl.org/dc/terms/date",
            "http://purl.org/dc/terms/created",
            "http://purl.org/dc/terms/modified"
    };
    DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
    tokenizer.setDelimiter(DelimitedLineTokenizer.DELIMITER_COMMA);
    tokenizer.setQuoteCharacter('"');
    tokenizer.setNames(names);

    taxonService = EasyMock.createMock(TaxonService.class);

    Set<Converter> converters = new HashSet<Converter>();
    converters.add(new ReferenceTypeConverter());
    converters.add(new StringToIsoDateTimeConverter());

    ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
    factoryBean.setConverters(converters);
    factoryBean.afterPropertiesSet();
    ConversionService conversionService = factoryBean.getObject();
    FieldSetMapper fieldSetMapper = new FieldSetMapper();
    fieldSetMapper.setConversionService(conversionService);
    fieldSetMapper.setFieldNames(names);
    fieldSetMapper.setDefaultValues(new HashMap<String, String>());
    fieldSetMapper.setTaxonService(taxonService);
    DefaultLineMapper<Reference> lineMapper
    = new DefaultLineMapper<Reference>();
    lineMapper.setFieldSetMapper(fieldSetMapper);
    lineMapper.setLineTokenizer(tokenizer);

    flatFileItemReader.setEncoding("UTF-8");
    flatFileItemReader.setLinesToSkip(0);
    flatFileItemReader.setResource(content);
    flatFileItemReader.setLineMapper(lineMapper);
    flatFileItemReader.afterPropertiesSet();
}