You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.6 KiB
83 lines
2.6 KiB
package de.superx; |
|
|
|
import java.util.HashMap; |
|
import java.util.Map; |
|
|
|
import javax.sql.DataSource; |
|
|
|
import org.apache.log4j.Logger; |
|
import org.junit.Ignore; |
|
import org.springframework.batch.core.configuration.JobRegistry; |
|
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; |
|
import org.springframework.batch.core.explore.JobExplorer; |
|
import org.springframework.batch.core.launch.JobLauncher; |
|
import org.springframework.batch.core.launch.JobOperator; |
|
import org.springframework.batch.core.launch.support.SimpleJobOperator; |
|
import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; |
|
import org.springframework.batch.core.repository.JobRepository; |
|
import org.springframework.beans.factory.annotation.Autowired; |
|
import org.springframework.context.annotation.Bean; |
|
import org.springframework.context.annotation.ComponentScan; |
|
import org.springframework.context.annotation.Configuration; |
|
import org.springframework.core.task.SyncTaskExecutor; |
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
|
import org.springframework.transaction.PlatformTransactionManager; |
|
|
|
import de.superx.spring.AppConfig; |
|
import de.superx.spring.batch.His1DataSources; |
|
|
|
@Ignore |
|
@Configuration |
|
@EnableBatchProcessing |
|
@ComponentScan(basePackages = {"de.superx.spring.service", "de.superx.spring.batch.tasklet", "de.superx.rest"}) |
|
public class TestAppConfig { |
|
|
|
|
|
private Logger logger = Logger.getLogger(TestAppConfig.class); |
|
|
|
@Autowired |
|
private JobRepository jobRepository; |
|
|
|
@Autowired |
|
private JobRegistry jobRegistry; |
|
|
|
@Autowired |
|
private JobExplorer jobExplorer; |
|
|
|
@Autowired |
|
DataSource dataSource; |
|
|
|
@Bean |
|
public PlatformTransactionManager transactionManager(DataSource dataSource) { |
|
return new DataSourceTransactionManager(dataSource); |
|
} |
|
|
|
@Bean |
|
public His1DataSources dataSources() { |
|
AppConfig.upgradeBatchSchema(dataSource); |
|
Map<String,DataSource> dataSources = new HashMap<>(); |
|
dataSources.put("eduetl", dataSource); |
|
return new His1DataSources(dataSources); |
|
} |
|
|
|
@Bean |
|
public JobLauncher jobLauncher() throws Exception { |
|
TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher(); |
|
jobLauncher.setJobRepository(jobRepository); |
|
jobLauncher.setTaskExecutor(new SyncTaskExecutor()); |
|
jobLauncher.afterPropertiesSet(); |
|
return jobLauncher; |
|
} |
|
|
|
@Bean |
|
public JobOperator jobOperator() throws Exception { |
|
SimpleJobOperator jobOperator = new SimpleJobOperator(); |
|
jobOperator.setJobLauncher(jobLauncher()); |
|
jobOperator.setJobExplorer(jobExplorer); |
|
jobOperator.setJobRepository(jobRepository); |
|
jobOperator.setJobRegistry(jobRegistry); |
|
return jobOperator; |
|
} |
|
|
|
|
|
} |