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


Java ItemProcessor类代码示例

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


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

示例1: importTicketStep

import org.springframework.batch.item.ItemProcessor; //导入依赖的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

示例2: createInventoryEntryStep

import org.springframework.batch.item.ItemProcessor; //导入依赖的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

示例3: userAnonymizedProcessor

import org.springframework.batch.item.ItemProcessor; //导入依赖的package包/类
@Bean(name = "sendSystemMessageJobUserAnonymizedProcessor", destroyMethod = "")
@StepScope
private ItemProcessor<UUID, MessageDestination> userAnonymizedProcessor()
{
	return new ItemProcessor<UUID, MessageDestination>() {
		@Value("#{jobParameters['messageText']}")
		private String messageText;

		@Override
		public MessageDestination process(UUID userAnonymizedId) throws Exception
		{
			logger.debug("Processing user anonymized with id {}", userAnonymizedId);
			UserAnonymizedDto userAnonymized = userAnonymizedService.getUserAnonymized(userAnonymizedId);

			MessageDestination messageDestination = messageDestinationRepository
					.findOne(userAnonymized.getAnonymousDestination().getId());
			messageDestination.send(SystemMessage.createInstance(messageText));

			return messageDestination;
		}
	};
}
 
开发者ID:yonadev,项目名称:yona-server,代码行数:23,代码来源:SendSystemMessageBatchJob.java

示例4: chunkStep

import org.springframework.batch.item.ItemProcessor; //导入依赖的package包/类
@Bean
public Step chunkStep() {
	final int chunkSize = 100;

	final ItemProcessor<String, String> processor = (item) -> {
		Thread.sleep(100);
		return item;
	};

	final ItemWriter<String> writer = (items) -> {
		Thread.sleep(1000);
	};

	return steps.get("Chunk Step") //
			.<String, String> chunk(chunkSize) //
			.reader(itemReader()) //
			.processor(processor) //
			.writer(writer) //
			.build();
}
 
开发者ID:phjardas,项目名称:spring-batch-tools,代码行数:21,代码来源:TestJobConfig.java

示例5: readCsvFileIntoTableStep

import org.springframework.batch.item.ItemProcessor; //导入依赖的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

示例6: itemProcessorAdapter

import org.springframework.batch.item.ItemProcessor; //导入依赖的package包/类
@Bean
public ItemProcessor<PartnerProduct, Product> itemProcessorAdapter() {
	ItemProcessorAdapter<PartnerProduct, Product> adapter = new ItemProcessorAdapter<>();
	adapter.setTargetObject(partnerProductMapper());
	adapter.setTargetMethod("map");

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

示例7: step2

import org.springframework.batch.item.ItemProcessor; //导入依赖的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

示例8: jobFactory

import org.springframework.batch.item.ItemProcessor; //导入依赖的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

示例9: toWorkerPool

import org.springframework.batch.item.ItemProcessor; //导入依赖的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

示例10: toProcessor

import org.springframework.batch.item.ItemProcessor; //导入依赖的package包/类
private ItemProcessor<?, ?> toProcessor(
		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) {
	if (this.task.equals(TASK_MATCH)) {
		return processorFactoryMatch.get();
	}
	if (this.task.equals(TASK_DEPENDENT)) {
		return processorFactoryDependent.get();
	}
	if (this.task.equals(TASK_DEPENDENCY)) {
		return processorFactoryDependency.get();
	}
	throw new IllegalArgumentException("Processor must be one of match, dependent or dependency");
}
 
开发者ID:maenu,项目名称:kowalski,代码行数:16,代码来源:WorkerPoolParser.java

示例11: lhClubImportStep

import org.springframework.batch.item.ItemProcessor; //导入依赖的package包/类
@Bean(name = IMPORT_STEP)
public Step lhClubImportStep(@Qualifier(IMPORT_STEP) FlatFileItemReader<LHHuntingClubCSVRow> reader,
                             @Qualifier(IMPORT_STEP) LHHuntingClubItemWriter writer,
                             ItemProcessor<LHHuntingClubCSVRow, LHHuntingClubCSVRow> processor) {
    return stepBuilderFactory.get(JOB_NAME)
            .<LHHuntingClubCSVRow, LHHuntingClubCSVRow>chunk(BatchConfig.BATCH_SIZE)
            .reader(reader)
            .processor(processor)
            .writer(writer)
            .listener(new LoggingBatchListener())
            .build();
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:13,代码来源:LHHuntingClubBatchConfig.java

示例12: step1

import org.springframework.batch.item.ItemProcessor; //导入依赖的package包/类
@Bean
public Step step1(ItemReader<Result> restMovieReader,
                    ItemProcessor<Result, Movie> moviesItemProcessor,
                    RepositoryItemWriter<Movie> movieRepositoryItemWriter) throws Exception {
    return stepBuilderFactory.get("step1")
            .<Result, Movie>chunk(10)
            .reader(restMovieReader)
            .processor(moviesItemProcessor)
            .writer(movieRepositoryItemWriter)
            .build();
}
 
开发者ID:RawSanj,项目名称:SpringRestBatch,代码行数:12,代码来源:JobConfiguration.java

示例13: step1

import org.springframework.batch.item.ItemProcessor; //导入依赖的package包/类
@Bean
public Step step1(StepBuilderFactory stepBuilderFactory,
				  ItemReader<NcaaStats> reader,
				  ItemWriter<NcaaStats> writer,
				  ItemProcessor<NcaaStats,NcaaStats> processor) {
	return stepBuilderFactory.get("step1")
			.<NcaaStats, NcaaStats>chunk(10)
			.reader(reader)
			.processor(processor)
			.writer(writer)
			.build();
}
 
开发者ID:mminella,项目名称:TaskMadness,代码行数:13,代码来源:NcaaStatConfiguration.java

示例14: job2

import org.springframework.batch.item.ItemProcessor; //导入依赖的package包/类
@Bean
public Job job2() throws Exception {

    AtomicInteger source = new AtomicInteger(1);
    Logger logger = LoggerFactory.getLogger(ChunkedBatch.class);

    ItemReader<Integer> reader = () -> {
        int value = source.getAndIncrement();
        if (value > 100) {
            //nullを返したらデータの読み取り終了とみなされる
            return null;
        }
        return value;
    };

    ItemProcessor<Integer, String> processor = item -> {
        //nullを返したらItemWriterには渡さない
        if (item % 2 == 0 && item > 10) {
            return null;
        }
        return String.format("*%d*", item);
    };

    ItemWriter<String> writer = items -> logger.info("{}", items);

    Step step = steps.get("step2")
            //10個ずつItemWriterに渡される
            .<Integer, String> chunk(10).reader(reader)
            .processor(processor).writer(writer).build();

    return jobs.get("job2").start(step).build();
}
 
开发者ID:backpaper0,项目名称:spring-boot-sandbox,代码行数:33,代码来源:ChunkedBatch.java

示例15: importTicketProcessor

import org.springframework.batch.item.ItemProcessor; //导入依赖的package包/类
@Bean
public ItemProcessor<Ticket, Ticket> importTicketProcessor(final TicketRepository ticketRepository,
                                                           final @Value("${ticket.metrics.count}") String countTicketType,
                                                           final TicketCounterUpdater ticketCounterUpdater,
                                                           final InternalTicketLatestCountUpdater internalTicketLatestCountUpdater) {
    final List<ItemProcessor<Ticket, Ticket>> delegates = Stream.of(
            new TicketUpdateItemProcessor(ticketRepository),
            new MetricItemProcessor<>(hasType(TicketType.valueOf(countTicketType)), ticketCounterUpdater),
            new MetricItemProcessor<>(ticket -> true, internalTicketLatestCountUpdater))
            .collect(Collectors.toList());
    final CompositeItemProcessor<Ticket, Ticket> processor = new CompositeItemProcessor<>();
    processor.setDelegates(delegates);
    return processor;
}
 
开发者ID:create1st,项目名称:spring-batch,代码行数:15,代码来源:BatchConfiguration.java


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