当前位置: 首页>>代码示例>>Java>>正文


Java ItemReader类代码示例

本文整理汇总了Java中org.springframework.batch.item.ItemReader的典型用法代码示例。如果您正苦于以下问题:Java ItemReader类的具体用法?Java ItemReader怎么用?Java ItemReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ItemReader类属于org.springframework.batch.item包,在下文中一共展示了ItemReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hdfsFileReader

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
@Bean
@StepScope
ItemReader<Map<String, Object>> hdfsFileReader(HdfsResourceLoader resourceLoader, LineMapper<Map<String, Object>> lineMapper) throws IOException {
	MultiResourceItemReader<Map<String, Object>> multiReader = new MultiResourceItemReader<>();
	Resource[] resources = resourceLoader.getResources("/demo/influencers/*");
	multiReader.setResources(resources);	
	FlatFileItemReader<Map<String, Object>> itemReader = new FlatFileItemReader<>();
	itemReader.setLineMapper(lineMapper);
	multiReader.setDelegate(itemReader);
	return multiReader;
}
 
开发者ID:trisberg,项目名称:springone-2015,代码行数:12,代码来源:BatchHive2Configuration.java

示例2: importTicketStep

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
@Bean
public Step importTicketStep(final StepBuilderFactory stepBuilderFactory,
                             @Qualifier("jpaTransactionManagerForBatch")
                             final PlatformTransactionManager jpaTransactionManager,
                             final @Value("${ticket.chunk.size}") int chunkSize,
                             final ItemReader<Ticket> ticketReader,
                             final ItemWriter<Ticket> ticketWriter,
                             final ItemProcessor<Ticket, Ticket> importTicketProcessor) {
    return stepBuilderFactory.get("importTicketStep")
            .<Ticket, Ticket>chunk(chunkSize)
            .reader(ticketReader)
            .processor(importTicketProcessor)
            .writer(ticketWriter)
            .transactionManager(jpaTransactionManager)
            .build();
}
 
开发者ID:create1st,项目名称:spring-batch,代码行数:17,代码来源:BatchConfiguration.java

示例3: testRead

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
/**
 * Test method for {@link org.emonocot.harvest.common.CompositeItemReader#read()}.
 */
@Test
public void testRead() throws Exception {
	ItemReader<Object> mock1 = delegates.get(0);
	ItemReader<Object> mock2 = delegates.get(1);
	EasyMock.expect(mock1.read()).andReturn("from 1st delegate");
	EasyMock.expect(mock1.read()).andReturn("from 1st delegate");
	EasyMock.expect(mock1.read()).andReturn(null);
	EasyMock.expect(mock2.read()).andReturn("from 2nd delegate");
	EasyMock.expect(mock2.read()).andReturn(null);
	EasyMock.replay(mock1,mock2);
	CompositeItemReader<Object> composite = new CompositeItemReader<>();
	composite.setDelegates(delegates);

	for (int i = 1; i <= 2; i++) {
		assertEquals("Read " + (i) + " should have returned an object", "from 1st delegate", composite.read());
	}
	assertEquals("Read 3 should have returned an object", "from 2nd delegate", composite.read());
	assertNull("There should be no more items to read", composite.read());
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:23,代码来源:CompositeItemReaderTest.java

示例4: createInventoryEntryStep

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
@Bean
public Step createInventoryEntryStep(final BlockingSphereClient sphereClient,
                                     final ItemReader<ProductProjection> inventoryEntryReader,
                                     final ItemProcessor<ProductProjection, List<InventoryEntryDraft>> inventoryEntryProcessor,
                                     final ItemWriter<List<InventoryEntryDraft>> inventoryEntryWriter) {
    final StepBuilder stepBuilder = stepBuilderFactory.get("createInventoryEntryStep");
    return stepBuilder
            .<ProductProjection, List<InventoryEntryDraft>>chunk(1)
            .reader(inventoryEntryReader)
            .processor(inventoryEntryProcessor)
            .writer(inventoryEntryWriter)
            .faultTolerant()
            .skip(ErrorResponseException.class)
            .skipLimit(1)
            .build();
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-data,代码行数:17,代码来源:InventoryEntryCreationJobConfiguration.java

示例5: userAnonymizedIdReader

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
private ItemReader<UUID> userAnonymizedIdReader()
{
	try
	{
		JdbcPagingItemReader<UUID> reader = new JdbcPagingItemReader<>();
		final SqlPagingQueryProviderFactoryBean sqlPagingQueryProviderFactoryBean = new SqlPagingQueryProviderFactoryBean();
		sqlPagingQueryProviderFactoryBean.setDataSource(dataSource);
		sqlPagingQueryProviderFactoryBean.setSelectClause("select id");
		sqlPagingQueryProviderFactoryBean.setFromClause("from users_anonymized");
		sqlPagingQueryProviderFactoryBean.setSortKey("id");
		reader.setQueryProvider(sqlPagingQueryProviderFactoryBean.getObject());
		reader.setDataSource(dataSource);
		reader.setPageSize(USERS_CHUNK_SIZE);
		reader.setRowMapper(singleUUIDColumnRowMapper());
		reader.afterPropertiesSet();
		reader.setSaveState(true);
		logger.info("Reading users anonymized in chunks of {}", USERS_CHUNK_SIZE);
		return reader;
	}
	catch (Exception e)
	{
		throw YonaException.unexpected(e);
	}
}
 
开发者ID:yonadev,项目名称:yona-server,代码行数:25,代码来源:SendSystemMessageBatchJob.java

示例6: itemReader

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
@Bean
@StepScope
public ItemReader<String> itemReader() {
	final List<String> items = IntStream.range(0, 1000).mapToObj(String::valueOf).collect(toList());

	return new ListItemReader<String>(items);
}
 
开发者ID:phjardas,项目名称:spring-batch-tools,代码行数:8,代码来源:TestJobConfig.java

示例7: readCsvFileIntoTableStep

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
@Bean(name = readCsvFileIntoTableStep)
public Step readCsvFileIntoTableStep(
        StepBuilderFactory stepBuilderFactory,
        PlatformTransactionManager platformTransactionManager,
        @Qualifier(readCsvFileIntoTableStepReader) ItemReader<Customer> ir,
        @Qualifier(readCsvFileIntoTableStepProcessor) ItemProcessor<Customer, Customer> itemProcessor,
        @Qualifier(readCsvFileIntoTableStepWriter) ItemWriter<Customer> iw) {

    StepBuilder builder = stepBuilderFactory.get(readCsvFileIntoTableStep);

    return builder.<Customer, Customer>chunk(3)
            .reader(ir)
            .processor(itemProcessor)
            .writer(iw)
            .transactionManager(platformTransactionManager)
            .build();
}
 
开发者ID:joshlong,项目名称:javaconfig-ftw,代码行数:18,代码来源:BatchConfiguration.java

示例8: importProductsJob

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
@Bean
public Job importProductsJob(Tasklet decompressTasklet, ItemReader<Product> reader) {

    Step decompress = stepBuilders.get("decompress")
                                  .tasklet(decompressTasklet)
                                  .repository(jobRepository)
                                  .transactionManager(transactionManager)
                                  .build();

    Step readWriteProducts = stepBuilders.get("readWriteProducts")
                                         .<Product, Product>chunk(3)
                                         .reader(reader)
                                         .writer(writer())
                                         .faultTolerant()
                                         .skipLimit(5)
                                         .skip(FlatFileParseException.class)
                                         .build();

    return jobBuilders.get("importProductsJob")
                      .repository(jobRepository)
                      .listener(loggerListener)
                      .start(decompress)
                      .next(readWriteProducts)
                      .build();
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:26,代码来源:ImportProductJobConfiguration.java

示例9: productItemReader

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
@Bean
public ItemReader<Product> productItemReader() throws Exception {
    JpaPagingItemReader<Product> reader = new JpaPagingItemReader<Product>();
    reader.setEntityManagerFactory(emf);
    reader.setQueryString("select p from Product p");
    reader.setPageSize(5);
    reader.afterPropertiesSet();

    return reader;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:11,代码来源:JobStructureJpaConfig.java

示例10: productItemReader

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
@Bean
public ItemReader<Product> productItemReader() throws Exception {
	FlatFileItemReader<Product> reader = new FlatFileItemReader<Product>();
	reader.setResource(new ClassPathResource("/kr/spring/batch/chapter05/test/input/multi-products-delimited.txt"));
	reader.setLinesToSkip(1);
	reader.setLineMapper(productLineMapper());

	return reader;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:10,代码来源:JobStructureDelimitedMultiFlatFileConfig.java

示例11: step2

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
@Bean("step2")
public Step step2(StepBuilderFactory stepBuilderFactory, ItemReader<Employee> reader,
                   ItemProcessor<Employee, Permanent> processor) {
      return stepBuilderFactory.get("step2")
              .<Employee, Permanent>chunk(2)
              .reader(reader)
              .processor(processor)
              .writer(xmlWriter())
              .build();
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:11,代码来源:BatchConfig.java

示例12: jobFactory

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
@Bean
public Supplier<Job> jobFactory(JmsTemplate jmsTemplate, Artifact jreArtifact,
		GraphDatabaseService graphDatabaseService) throws SettingsBuildingException {
	return () -> {
		ItemReader<Page<Artifact, Artifact>> reader = new Reader(jmsTemplate, new ActiveMQQueue(this.output));
		ItemProcessor<Page<Artifact, Artifact>, Result> processor = new Processor(new AnalysisRunner(this.timeout),
				jreArtifact, new File(this.lastModifiedCache), this.groupIdFilter);
		ItemWriter<Result> writer = new Writer(graphDatabaseService);
		Step step = this.stepBuilderFactory.get("analysis").<Page<Artifact, Artifact>, Result>chunk(1)
				.faultTolerant().skipPolicy(new LoggingAlwaysSkipItemSkipPolicy()).noRollback(Throwable.class)
				.reader(reader).processor(processor).writer(writer).build();
		return this.jobBuilderFactory.get("analysis").start(step).build();
	};
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:15,代码来源:Configuration.java

示例13: toWorkerPool

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
public WorkerPool toWorkerPool(JmsTemplate jmsTemplate,
		Supplier<ch.unibe.scg.kowalski.worker.match.Processor> processorFactoryMatch,
		Supplier<ch.unibe.scg.kowalski.worker.dependent.Processor> processorFactoryDependent,
		Supplier<ch.unibe.scg.kowalski.worker.dependency.Processor> processorFactoryDependency) {
	ItemReader<?> reader = this.toReader(jmsTemplate);
	ItemProcessor<?, ?> processor = this.toProcessor(processorFactoryMatch, processorFactoryDependent,
			processorFactoryDependency);
	ItemWriter<?> writer = this.toWriter(jmsTemplate);
	return new WorkerPool(this.size, reader, processor, writer);
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:11,代码来源:WorkerPoolParser.java

示例14: toReader

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
private ItemReader<?> toReader(JmsTemplate jmsTemplate) {
	if (this.readLimit.isPresent()) {
		return new LimitedReader<>(jmsTemplate, this.input, this.readLimit.get());
	} else {
		return new Reader<>(jmsTemplate, this.input);
	}
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:8,代码来源:WorkerPoolParser.java

示例15: innofactorImportStep

import org.springframework.batch.item.ItemReader; //导入依赖的package包/类
@Bean(name = STEP_NAME)
public Step innofactorImportStep(@Qualifier(STEP_NAME) ItemReader<InnofactorImportFileLine> reader,
                                 @Qualifier(STEP_NAME) ItemWriter<MetsastajaRekisteriPerson> writer) {
    CompositeItemProcessor<InnofactorImportFileLine, MetsastajaRekisteriPerson>
            processorChain = new CompositeItemProcessor<>();

    processorChain.setDelegates(Arrays.asList(
            new InnofactorImportFormatter(),
            new MetsastajaRekisteriItemValidator()
    ));

    return stepBuilder.get(JOB_NAME)
            .<InnofactorImportFileLine, MetsastajaRekisteriPerson>chunk(BatchConfig.BATCH_SIZE)
            .reader(reader)
            .processor(processorChain)
            .writer(writer)
            .faultTolerant()
            .skipLimit(200)
            .skip(PersistenceException.class)
            .skip(org.hibernate.exception.ConstraintViolationException.class)
            .skip(DataIntegrityViolationException.class)
            .skip(InvalidHunterDateFieldException.class)
            .skip(InvalidHunterNumberException.class)
            .skip(InvalidSsnException.class)
            .skip(InvalidPersonName.class)
            .skip(InvalidRhyException.class)
            .listener(new LoggingBatchListener())
            .build();
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:30,代码来源:InnofactorImportConfig.java


注:本文中的org.springframework.batch.item.ItemReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。