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