當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。