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.chunk; 017 018import org.springframework.batch.core.repository.JobRepository; 019import org.springframework.transaction.PlatformTransactionManager; 020 021/** 022 * Convenient factory for a {@link RemoteChunkingMasterStepBuilder} which sets 023 * the {@link JobRepository} and {@link PlatformTransactionManager} automatically. 024 * 025 * @since 4.1 026 * @author Mahmoud Ben Hassine 027 */ 028public class RemoteChunkingMasterStepBuilderFactory { 029 030 private JobRepository jobRepository; 031 032 private PlatformTransactionManager transactionManager; 033 034 /** 035 * Create a new {@link RemoteChunkingMasterStepBuilderFactory}. 036 * 037 * @param jobRepository the job repository to use 038 * @param transactionManager the transaction manager to use 039 */ 040 public RemoteChunkingMasterStepBuilderFactory( 041 JobRepository jobRepository, 042 PlatformTransactionManager transactionManager) { 043 044 this.jobRepository = jobRepository; 045 this.transactionManager = transactionManager; 046 } 047 048 /** 049 * Creates a {@link RemoteChunkingMasterStepBuilder} and initializes its job 050 * repository and transaction manager. 051 * 052 * @param name the name of the step 053 * @return a {@link RemoteChunkingMasterStepBuilder} 054 */ 055 public <I, O> RemoteChunkingMasterStepBuilder<I, O> get(String name) { 056 return new RemoteChunkingMasterStepBuilder<I, O>(name) 057 .repository(this.jobRepository) 058 .transactionManager(this.transactionManager); 059 } 060 061}