001/* 002 * Copyright 2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.springframework.batch.integration.config.annotation; 017 018import org.springframework.batch.core.explore.JobExplorer; 019import org.springframework.batch.core.repository.JobRepository; 020import org.springframework.batch.integration.chunk.RemoteChunkingMasterStepBuilderFactory; 021import org.springframework.batch.integration.chunk.RemoteChunkingWorkerBuilder; 022import org.springframework.batch.integration.partition.RemotePartitioningMasterStepBuilderFactory; 023import org.springframework.batch.integration.partition.RemotePartitioningWorkerStepBuilderFactory; 024import org.springframework.beans.factory.annotation.Autowired; 025import org.springframework.context.annotation.Bean; 026import org.springframework.context.annotation.Configuration; 027import org.springframework.transaction.PlatformTransactionManager; 028 029/** 030 * Base configuration class for Spring Batch Integration factory beans. 031 * 032 * @since 4.1 033 * @author Mahmoud Ben Hassine 034 */ 035@Configuration 036public class BatchIntegrationConfiguration { 037 038 private JobExplorer jobExplorer; 039 040 private JobRepository jobRepository; 041 042 private PlatformTransactionManager transactionManager; 043 044 @Autowired 045 public BatchIntegrationConfiguration( 046 JobRepository jobRepository, 047 JobExplorer jobExplorer, 048 PlatformTransactionManager transactionManager) { 049 050 this.jobRepository = jobRepository; 051 this.jobExplorer = jobExplorer; 052 this.transactionManager = transactionManager; 053 } 054 055 @Bean 056 public RemoteChunkingMasterStepBuilderFactory remoteChunkingMasterStepBuilderFactory() { 057 return new RemoteChunkingMasterStepBuilderFactory(this.jobRepository, 058 this.transactionManager); 059 } 060 061 @Bean 062 public <I,O> RemoteChunkingWorkerBuilder<I, O> remoteChunkingWorkerBuilder() { 063 return new RemoteChunkingWorkerBuilder<>(); 064 } 065 066 @Bean 067 public RemotePartitioningMasterStepBuilderFactory remotePartitioningMasterStepBuilderFactory() { 068 return new RemotePartitioningMasterStepBuilderFactory(this.jobRepository, 069 this.jobExplorer, this.transactionManager); 070 } 071 072 @Bean 073 public RemotePartitioningWorkerStepBuilderFactory remotePartitioningWorkerStepBuilderFactory() { 074 return new RemotePartitioningWorkerStepBuilderFactory(this.jobRepository, 075 this.jobExplorer, this.transactionManager); 076 } 077 078}